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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-05-25 : 08:33:56
|
Navinder writes "I m having one table named "ENTRY' with columns names are: id, source, status [all are not NULL]
1)we can have these 5 different type of source only, in a "source" column S1, S2, S3, S4, S5 2)Status can be either of the four: 'positive', 'negative', rejected', 'pending'
now I want all "souce" with there "status" as 'pending'
For eg. we are having data in a table as:
ID SOURCE STATUS -------------------- 1 S1 pending 2 S2 negative 3 S1 pending 4 S4 positive 5 S3 pending 6 S1 rejected 7 S1 pending 8 S3 pending 9 S2 positive 10 S5 positive It means 1)S1 is having a total of 3 pending cases 2)S2 is having a total of 0 pending cases 3)S3 is having a total of 2 pending cases 4)S4 is having a total of 0 pending cases 5)S5 is having a total of 0 pending cases
and I need the output as: SOURCE STATUS -------------- S1 3 S2 0 S3 2 S4 0 S5 0
I am using SQL statement: "select source,count(status1) from ENTRY where status='pending' group by source"
BUT I m getting the output after using above query as: SOURCE STATUS ------------------ S1 3 S3 2
I need the S2,S4,S5 should also can be seen in the output.
Please help as soon as possible I need it very badly. I know it is a bit hard, But I belive in u guys. waiting for a favourable reply early
Thanks amd regards, Navinderjit" |
|
|
|
|
|
|
|