-1

Inside the database (SQL) I have a table called wp_lb_leads_confirmations where for each ID I have N-rows. I need to select the 5th row for each ID.

I used the query (above), but the command ROW_NUMBER() give me the following error message:

SQL Error [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ROW_NUMBER() OVER (ORDER BY creationdate ASC) AS rownumber,' at line 1

Actually, I'm using DBeaver (V. 21.3.4)

SELECT * FROM (
  SELECT
    ROW_NUMBER() OVER (ORDER BY creationdate ASC) AS rownumber,
    columns
   wp_lb_leads_confirmations
) 
WHERE rownumber = 5

Any suggestion? Thanks in advance

  • 1
    It would be helpful if you provided a minimal schema and sample data. The above is missing a table so it's an incomplete snippet of a query (which you may or may not know). – Allan Wind May 16 '22 at 11:23
  • 1
    row_number() is a mysql 8 feature. What version of mysql are you using? I don't know anything about dbeaver but the client is probably not relevant. – Allan Wind May 16 '22 at 11:25
  • https://stackoverflow.com/questions/1895110/row-number-in-mysql might be of interest to you. – Allan Wind May 16 '22 at 11:27
  • 1
    you are selecting but you are not telling your query from where to select.. (in your subquery) – Demeteor May 16 '22 at 11:29
  • I do not see FROM clause in the subquery. – Akina May 16 '22 at 12:37

0 Answers0