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.
| Author |
Topic |
|
e106199
Starting Member
13 Posts |
Posted - 2006-01-23 : 21:44:13
|
| Hi all,how can i get the below table from the above one?my table:col1 col2---- --------abc 1/1/2006abd 2/1/2006abc 3/1/2006abb 3/2/2006abc 3/3/2006from above table i want to get the below:month countof ABC countof abd----- ----------- -----------jan 06 1 0feb 06 0 1mar 06 2 0 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-23 : 21:58:16
|
| [code]select convert(varchar(6), col2, 112) as mth_yr, sum(case when col1 = 'abc' then 1 else 0 end) as [count of abc], sum(case when col1 = 'abb' then 1 else 0 end) as [count of abb] from mytablegroup by convert(varchar(6), col2, 112) order by mth_yr[/code]----------------------------------'KH'I do work from home but I don't do homework |
 |
|
|
e106199
Starting Member
13 Posts |
Posted - 2006-01-23 : 22:56:47
|
| that was greatthank you-shane |
 |
|
|
|
|
|