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 |
|
charul
Starting Member
18 Posts |
Posted - 2008-10-17 : 01:46:37
|
| I have a query like thisSelect ORG4 as [ORGDESC],[CONFIRMED IN MONTHS],Count(*) as Counts from Confirmation_Details WHERE [EMPLOYEE CODE] IS NOT NULL group by ORG4,[CONFIRMED IN MONTHS]The output is like belowORGDESC CONFIRMED IN MONTHS CountsCommon 0 2Common 02 2Common 03 31Common -03 5Common 13 8I need to modify the query such thatfor [Confirmed in Months] less than 1 , the sums should add upand for greater than 12 , the sums should add up |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-10-17 : 02:12:30
|
[code]SELECT org4 AS orgDesc, CASE WHEN confirmedInMonths < 1 THEN 'A' WHEN confirmedInMonths > 1 THEN 'B' ELSE confirmedInMonths END AS confirmedInMonths COUNT(*) AS CountsFROM confirmationDetailsWHERE employeeCode IS NOT NULLGROUP BY org4, CASE WHEN confirmedInMonths < 1 THEN 'A' WHEN confirmedInMonths > 1 THEN 'B' ELSE confirmedInMonths END[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
charul
Starting Member
18 Posts |
Posted - 2008-10-17 : 02:29:31
|
| Thanks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-10-17 : 02:38:20
|
ooops! > 1 should be > 12Sorry... E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|