i never use sql server ROW_NUMBER() function. so i read some article regarding ROW_NUMBER(),PARTITION & RANK() etc but still not clear to me.
i found the syntax is like
SELECT top 10 ROW_NUMBER() OVER(ORDER BY JID DESC) AS 'Row Number',
JID,Specialist, jobstate, jobtype FROM bbajobs
SELECT top 10 ROW_NUMBER() OVER(PARTITION BY JID ORDER BY JID DESC) AS 'Row Number',
JID,Specialist, jobstate, jobtype FROM bbajobs
i have few question
1) what over() function does. why we need to specify column name in over function like OVER(ORDER BY JID DESC)
2) i saw sometime people use PARTITION keyword. what it is?
it is also used in over function like OVER(PARTITION BY JID ORDER BY JID DESC)
3) in what type of situation we have to use PARTITION keyword
4) when we specify PARTITION keyword in over then also we need to specify order by also why. only PARTITION keyword can not be used in over clause.
5) what type of situation one should use RANK function
6) what is CTE and what is the advantage of using CTE. it is just like temporary view.
anyone get any performance boost if he/she use CTE other than reusability?
please discuss my points in detail. it will be very much helpful if some one make me understand with small & easy example for all the keyword like ROW_NUMBER(),PARTITION & RANK(). thanks