Friday, May 21, 2010

Group by SQL Query

0 comments
To extract Country wise sales count for the period  MAY-2010 use below code.


Select c.country_name, count(s.id)
from tbl_sales s inner join tbl_country c on s.country_id=c.country_id
where s.saels_date between '2010-05-01 00:00:00' and '2010-05-31 23:59:59'
group by c.coutnry_name 

0 comments: