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 |
|
pradeep_iete
Yak Posting Veteran
84 Posts |
Posted - 2008-06-09 : 04:31:03
|
| I have the following result setapplicationID statusID1734 22910 21734 441734 482910 462910 381734 462910 202910 212910 22Now i want to check for a paricular statusID for all applicationID.That is i want to check that how many application have not attainted that status.What shud be the query ? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-09 : 04:53:34
|
| [code]SELECT applicationIDFROM TableGROUP BY applicationIDHAVING SUM(CASE WHEN statusID=yourvalue THEN 1 ELSE 0 END) =0[/code] |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-06-09 : 05:01:22
|
| declare @app table (applicationID int,statusID int)insert into @appselect 1734,2 UNION ALLselect 2910, 2 UNION ALLselect 1734 ,44 UNION ALLselect 1734,48 UNION ALLselect 2910,46 UNION ALLselect 2910,38 UNION ALLselect 1734 ,46 UNION ALLselect 2910, 20 UNION ALLselect 2910, 21 UNION ALLselect 2910 , 22declare @status int select @status = 44 < for example >select applicationIDfrom @appwhere statusID <> @status |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-09 : 05:17:02
|
quote: Originally posted by raky declare @app table (applicationID int,statusID int)insert into @appselect 1734,2 UNION ALLselect 2910, 2 UNION ALLselect 1734 ,44 UNION ALLselect 1734,48 UNION ALLselect 2910,46 UNION ALLselect 2910,38 UNION ALLselect 1734 ,46 UNION ALLselect 2910, 20 UNION ALLselect 2910, 21 UNION ALLselect 2910 , 22declare @status int select @status = 44 < for example >select applicationID, statusidfrom @appwhere statusID = @status
This will still give application id which still have record with status as 441734 ,44 for ex:your query returns 1734,2 which still has Status of 44 in |
 |
|
|
|
|
|
|
|