Click here to Skip to main content
15,897,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear friends

SELECT * FROM A
1 A ACCEPT
2 A ACCEPT
3 C ACCEPT
4 C ACCEPT
5 B HOLD
6 G HOLD
7 G HOLD
8 B REJECT
9 G REJECT
10 H REJECT
11 H REJECT
12 A NEW
13 H REJECT
14 H NEW
15 C NEW
16 D NEW
17 E NEW
18 D ACCEPT
19 D ACCEPT
20 F ACCEPT
21 I NULL

This is my table.

SELECT DISTINCT(PROD) FROM A
A
B
C
D
E
F
G
H
I

These are the products i have.

SELECT PROD,ISNULL(COUNT(*),0) FROM A WHERE STATUS='ACCEPT' GROUP BY PROD
A 2
C 2
D 2
F 1

When i execute this i am getting the above result

But my requirement :

A 2
B 0
C 2
D 2
E 0
F 0
G 0
H 0
I 1

How to achieve it.

please help me

thanks in advance
Posted

1 solution

SELECT PROD,ISNULL(COUNT(*),0) FROM A WHERE STATUS='ACCEPT' GROUP BY All PROD
 
Share this answer
 
Comments
Member 9409254 25-Jan-14 0:28am    
Thanks a lot my friend
This post was very much help to me
all key word was new to me thanks to introduce
karthik Udhayakumar 25-Jan-14 0:36am    
Welcome and all the best:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900