group by clause of SQL

It is used with from clause. it is used to arrange records category wise. before using by keyword in aggregate function on any column in select clause. having keyword is used to combine condition with group by. we learn following table to understand group by -
·         store -
Store_city
Sells
Indore
100000
Ujjain
70000
Barwani
35000
Dhar
49000
Indore
1500000
Ujjain
90000
Barwani
37000
Indore
80000










syntax :- 
select column_name, aggregate_function (column_name) from table_name group by column_name;

example:-
1.) Give total sells from store table city wise ?

i/p:-
select Store_city, Sum(sells) from store group by Store_city;

o/p :-

Store_city
Sum (sells)
Indore
330000
Ujjain
160000
Barwani
72000
Dhar
49000

No comments:

Post a Comment

Nested SQL Query or SQL Sub Query in hindi in english

if a SQL query is used inside another SQL query then this type of SQL query is called sub-query.  यदि किसी SQL क्वेरी का उपयोग, किसी अन्य SQ...