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 |
|
pragneshmpatel@gmail.com
Starting Member
3 Posts |
Posted - 2008-05-29 : 10:17:24
|
hi all,I want to user "If ElseIf else .." in Select Statement with Group By .The Following statement is working in MS Access. Which got only If Else. But i want to implement same thing with more condition in Sql 2005.SELECT IIf([Water Depth (M)]<500,"<500",">=500") AS DEPTH, Count([Operator Name]) AS [CountOfOperator Name],FROM [tblDepth]GROUP BY IIf([Water Depth (M)]<500,"<500",">=500");Waiting for any help!!ThanksPragnesh  |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-05-29 : 10:21:24
|
| SELECT case when [Water Depth (M)]<500 then '<500' else '>=500' end AS DEPTH, Count([Operator Name]) AS [CountOfOperator Name],FROM [tblDepth]GROUP BY case when [Water Depth (M)]<500 then '<500' else '>=500' endMadhivananFailing to plan is Planning to fail |
 |
|
|
pragneshmpatel@gmail.com
Starting Member
3 Posts |
Posted - 2008-05-29 : 10:26:48
|
| ThanksMadhivananIt Works!!SELECT case when [Water Depth (M)]<500 then '<500' when [Water Depth (M)]>500 then '>500'else '>=500' end AS DEPTH, Count([Operator Name]) AS [CountOfOperator Name]FROM [tblDepth]GROUP BY case when [Water Depth (M)]<500 then '<500' when [Water Depth (M)]>500 then '>500' else '>=500' end |
 |
|
|
|
|
|