Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Need Query for below reqt

Author  Topic 

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-10-12 : 10:07:18
Hi, I have below table with data.

Name Grade1 Grade2
Alen A B
Jony A,C B,Y,L
Alen A,D,E B,F
Syam A B,Y
Syam A D,Y


I want to know the count of grades for each name. The output i am looking is as below. Plz let me know how can i query for this.

Name Grade1Cnt Grade2Cnt
Alen A=2,D=1,E=1 B=2,F=1
Jony A=1,C=1 B=1,Y=1,L=1
Syam A=2,B=1 D=1,Y=2



developer :)

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-10-12 : 22:10:44
you have multiple value (A, D, E) in the column ? And you want the result in CSV ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-10-12 : 22:21:43
No, As i said above, i want the count of grades for each name. For name "Alen" The count of grade columns is
<code>
Name Grade1Cnt Grade2Cnt
Alen A=2,D=1,E=1 B=2,F=1
</code>
quote:
Originally posted by khtan

you have multiple value (A, D, E) in the column ? And you want the result in CSV ?


KH
[spoiler]Time is always against us[/spoiler]





developer :)
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-10-12 : 22:32:57
this is a pretty bad design of the table. Any chances to change that ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-10-12 : 22:52:05
No... The design is ok as per the requirement.

quote:
Originally posted by khtan

this is a pretty bad design of the table. Any chances to change that ?


KH
[spoiler]Time is always against us[/spoiler]





developer :)
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-10-12 : 22:53:26
quote:
Originally posted by satish.gorijala

No... The design is ok as per the requirement.

quote:
Originally posted by khtan

this is a pretty bad design of the table. Any chances to change that ?


KH
[spoiler]Time is always against us[/spoiler]





developer :)



ok


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -