sql server - PIvot query for month wise sql server2008 -
select rname, [4] apr, [5] mai, [6] jun, [7] jul, [8] aug, [9] sep, [10] oct (select rname, billamt, datepart(mm,date1) tmonth #temp pivot ( sum(billamt) tmonth in ([4],[5],[6],[7],[8],[9],[10]) )as pvtmonth
this query. getting error in query.
i need show monthwise billamount rname. pls help find out error. wrong syntax near 'pvtmonth'. construction of table
rname |billamt |date1| aaa | 400 | 1-04-2014| bbb | 200 |23-3-2014 | bbb | 500 |12-04-2014|
| 100 |1-04-2014 |i need name |mar | apr aaa |400 | 0 bbb |200 |500 | 0 |100
try u missed close braces , alias name inner query
select rname, [4] apr, [5] mai, [6] jun, [7] jul, [8] aug, [9] sep, [10] oct (select rname, billamt, datepart(mm, date1) tmonth #temp) -- u missed pivot ( sum(billamt) tmonth in ([4], [5], [6], [7], [8], [9], [10]) )as pvtmonth
sql-server vb.net
No comments:
Post a Comment