SELECTing top N rows without ROWNUM?

后端 未结 5 1246
遇见更好的自我
遇见更好的自我 2020-12-18 09:19

I hope you can help me with my homework :)

We need to build a query that outputs the top N best paid employees.

My version works perfectly fine.
For exam

5条回答
  •  旧巷少年郎
    2020-12-18 09:46

    The reason you must wrap the statement with another select is because the outer select statement is the one that limits your result set to the row numbers desired. Here's a helpful link on analytics. If you run the inner select by itself you'll see why you have to do this. Analytics are applied AFTER the where clause is evaluated, which is why you get the error that myorder is an invalid identifier.

提交回复
热议问题