July 26, 2011 at 10:04 pm
hi, i have output table as :
groupname month count
A 1 3
A 2 10
A 3 11
A 4 12
how to display this output as :
groupname/month JAN FEB MARCH APRIL
A 3 10 11 12
am a beginner.. i have no idea on doing this.. can this be implemented in SQL ?? seeking for your help.. thank you.
July 27, 2011 at 12:41 am
groupname/month JAN FEB MARCH APRIL
A 3 10 11 12
A- groupname
3- count
10,11,12 - ???? months ?
need some explanation..
July 27, 2011 at 7:23 am
Use a matrix with your months at the top, your groups on the side, and your count as the data.
July 27, 2011 at 8:16 am
SELECT GroupName,
DATENAME(mm,'2000-' + RIGHT('0' + CAST([month] as varchar(13)), 4) + '-01') [month],
[Count]
FROM (SELECT 'A' groupname, 1 [month], 3 [Count] UNION ALL
SELECT 'A', 2, 10 UNION ALL
SELECT 'A', 3, 11 UNION ALL
SELECT 'A', 4, 12) A
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply