Wednesday 20 February 2013

Sql: Over And Partition By Clause


Over(): Over() looks over the result set rows of the aggregation functions.Hence  OVER() is implemented in the aggregation functions, it allow-us to access the details of the rows that have been aggregated by the aggregate functions.


Partition by: Over and partition by clause is used to wire up the result on the basis of particular field value.
e.g.
We have a table sample For Ranking Functions with the following records.

Sql: Over And Partition By Clause

Now we want to show the sum of salary by grouping them by salary. We have four records with salary 14 therefore sum is 56 and in second group we have two records with salary 20 hence sum is 40. The query will be:


Sql: Over And Partition By Clause

The output of the above query will be as:

The output of the above query

No comments:

Post a Comment

How to get code from a published ASP.Net build where we don't have source code?

If you have ever lost or misplaced your source code for an ASP.Net web application, you might wonder if there is a way to recover it from th...