Skip to content

SELECT

Specifies the columns to be returned by the query.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
USE AdventureWorks2012;
GO
SELECT *
FROM Production.Product
ORDER BY Name ASC;
-- Alternate way.
USE AdventureWorks2012;
GO
SELECT p.*
FROM Production.Product AS p
ORDER BY Name ASC;
GO

GROUP BY

It groups the data

1
2
select city,sum(salary) from emp
group by city

**** orther than aggregate function what ever columns we used in select that should mention in in GROUP BY clause ,other wise error will occure.

where :

it filters the data

1
2
select * from emp 
where empname='john'

HAVING :

It is same as WHERE clause. In aggregate function WHERE clause does not works so thats why we are using HAVING clause.

1
2
select sum(salary) from emp
having sum(salary)>20000