Saturday, July 24, 2010

Write a SQL query which displays geography names where Value for same month data more than 70 from the following table

Geography table
Geography Name 
Period
Value 
Korea 
2009-04-30  
10 
Spain 
2009-06-30 
20 
Sweden 
2009-04-28
30 
Switzerland 
2009-06-30 
40
Taiwan 
2009-08-31 
70 
Thailand 
2009-04-16
100 
Sweden 
2009-08-13
120 


select
Geography,right(convert(varchar(30), Period,103),7),SUM(value) from DW.FactGeographyExposure                                                                                                                                                            group by Geography,right(convert(varchar(30), Period,103),7) having sum(value)>0

No comments:

Post a Comment


All Rights Reserved @ Raju Das