04pallav
9/13/2017 - 9:53 PM

ROW_NUMBER()

ROW_NUMBER()

SELECT row_number() over(ORDER BY trip_no) num, ##this will create a numbereed column

 trip_no, id_comp
FROM trip
WHERE ID_comp < 3
ORDER BY id_comp, trip_no;


row_number() over(ORDER BY col1 asc) num1,


SELECT row_number() over(partition BY id_comp ORDER BY id_comp,trip_no) num,
 trip_no, id_comp 
FROM trip
WHERE ID_comp < 3
ORDER BY id_comp, trip_no;


SELECT Salary FROM
(
    SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT 10
) AS Emp ORDER BY Salary LIMIT 1;