SQL Interview Questions | Alternative of TOP Clause
Question
What is alternative for TOP clause in SQL? Anyone having knowledge of SQL is aware about TOP clause, but only a person with deep understanding can answer this question.
(Hint-You might discuss various alternatives to get the same work done)
in progress
0
SQL
55 years
2 Answers
1108 views
Great Grand Master 0
Answers ( 2 )
We can use ROW_NUMBER() to assign numbers to each row starting from 1. Then we can use WHERE clause with row number less than or equal to N.
We can use ORDER BY followed by LIMIT
IF YOU WANT TOP N USE THIS –
SELECT
FROM
WHERE
ORDER BY
LIMIT N