Home About US Matrimonial Education Recipis Inquiry Contact US
USER ID PASSWORD
New Member Forget Password
 
Member
24 Gaam
Hospital Project
School Project
Vibrant Newsletter
Events / News
Essay
Entertament
Services
Business
Health
Religion
Arts / Calture
Other Samaj
Help
 
 
  EDUCATION
   
 
Education :- Computer :- SQL TUTORIAL :- GROUP BY & HAVING

One special use of GROUP BY is to associate an aggregate function (especially COUNT; counting the number of rows in each group) with groups of rows. First, assume that the Antiques table has the Price column, and each row has a value for that column. We want to see the price of the most expensive item bought by each owner. We have to tell SQL to group each owner's purchases, and tell us the maximum purchase price:

SELECT BUYERID, MAX(PRICE)
FROM ANTIQUES
GROUP BY BUYERID;

Now, say we only want to see the maximum purchase price if the purchase is over $1000, so we use the HAVING clause:

SELECT BUYERID, MAX(PRICE)
FROM ANTIQUES
GROUP BY BUYERID
HAVING PRICE 1000;

 

 
 
 
 
 
 
 
 
Site Design By :- www.ebeesinfo.com
Site Best View in 1024 X 768
Home | About US | Terms and conditions | Education | Matrimonial | Resipis | Inquiry | Contact US
Copy Right 2008, www.24gaam.com