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

WooCommerce an WordPress open-source e-commerce plugin

WooCommerce is an WordPress open-source e-commerce plugin. WooCommerce is a free WordPress plugin that have e-commerce functionality to your...