0

Hi I'm trying to get a row number but I keep getting the error subquery in FROM must have an alias not sure what I'm doing wrong here.

Here is my code:

await pool.query('SELECT row_number() Over(lvls), * FROM (SELECT guild_id FROM levels WHERE guild_id = $1)', [message.guild.id]) `
Jasme
  • 87
  • 5
  • The subquery (derived table) is unnecessary to begin with. –  Sep 10 '21 at 15:43
  • @a_horse_with_no_name why so? could you provide an example of how to query the row number? – Jasme Sep 10 '21 at 16:43
  • Your query can be simplified to `SELECT row_number() Over(lvls), guild_id FROM levels WHERE guild_id = $1` - but in reality both will result in an error as `over(lvls)` is invalid to begin with. –  Sep 10 '21 at 16:51

0 Answers0