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 |
|
tskmjk
Starting Member
11 Posts |
Posted - 2009-09-25 : 09:16:51
|
| Hi, I am designing a reporting tool where a requirement says to get count of columns where the text is 'yes'. For example: Data is Calltable changed_custname changed_custmobno-------------------------------------------------------------- TEST2 yes no TEST3 no yes The result should be by calltable wise and count of the two columns only for 'yes' the result should be like.. Calltable No. of custname changes no. of custmobno changes-------------------------------------------------------------------- TEST2 1 0 TEST3 0 1kINDLY help me with the sql query? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-25 : 09:20:47
|
| select Calltable, sum(case when changed_custname='yes' then 1 else 0 end) as [no of custname changes],sum(case when changed_custmobno='yes' then 1 else 0 end) as [no of custmobno changes]from your_tablegroup by CalltableMadhivananFailing to plan is Planning to fail |
 |
|
|
tskmjk
Starting Member
11 Posts |
Posted - 2009-09-25 : 09:24:19
|
| Super!! thanks for your help.... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-25 : 09:26:04
|
quote: Originally posted by tskmjk Super!! thanks for your help....
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|