Reputation: 9
I try to make SQL query for my chart graph. and I've some problem with clause WHERE and AS. I try to show S and B in my table. How is the right query SQL?
if I try my SQL just show 0 in pekerjaan
SELECT lulus
FROM lulusan, COUNT((pekerjaan)
WHERE pekerjaan='S' AND 'B') AS pekerjaan
GROUP BY lulus
Upvotes: 0
Views: 94
Reputation: 5453
I think you can use this query :
SELECT lulus, COUNT(*)
FROM lulusan
WHERE pekerjaan in('S', 'B')
GROUP BY lulus
Upvotes: 4
Reputation: 13237
I guess you are looking for CASE WHEN
for this scenario:
SELECT lulus, COUNT(CASE WHEN pekerjaan IN ('S', 'B') THEN 1 END) AS pekerjaan
FROM lulusan
GROUP BY lulus
Upvotes: 2