Thursday, 18 August 2011

Explain GROUPBY function in SQL Server.

The GROUPBY function is used to group the results fetched from one or more columns. It is widely used with aggregate functions.
Ex :
Select EmployeeName, sum(EmployeeSalary) from Employees
Group by EmployeeName
This Query will display the total sum(Employee Salary) of each employee and group by the employees name.

Labels:


Bookmark this Blog in your Favorites

Wednesday, 3 August 2011

Explain LAST function in SQL Server.

The LAST function displays the last value of the selected column.

Ex :
Select last(EmployeeID) as LastEmployeeID from Employees
This Query will display the last value of “EmployeeID” column, the output will be displayed with the column name “LastEmployeeID”.

Labels:


Bookmark this Blog in your Favorites

Monday, 1 August 2011

Explain FIRST function in SQL Server.

The FIRST function displays the first value of the selected column.

Ex :
Select first(EmployeeID) as FirstEmployeeID from Employees

This Query will display the first value of “EmployeeID” column, the output will be displayed with the column name “FirstEmployeeID”.

Labels:


Bookmark this Blog in your Favorites