A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
oracle sql - case statement and count
Joined: May 31, 2007
Jun 19, 2009 14:20:27
Hi All friendly people
I have 2 tables table1 and table2
table 1 and table 2 have got ids.
my condition is ,
if table1.id=table2.id then i will need the count on the table2 ids, else if table1.id is not present in table2.id then for the table1.id the count should be 0.
This is what i have done so far.
select table1.id, ( COUNT( CASE when table1.id = table2.referer_id --WHEN did_date = 1 THEN table2.referer_id ELSE 0 END ) ) AS count
I am not able to figure it out. Please help.
author & internet detective
Joined: May 26, 2003
Jun 19, 2009 20:56:56
What happens when you run the code you posted - error message, unexpected result, etc?
How To Ask Questions The Smart Way
Blogging on Certs:
SCEA Part 1
Part 2 & 3
Core Spring 3
TOGAF part 1
subject: oracle sql - case statement and count
Composite Foreign Key that maps to Unique Constraint
Help with a query?
Hibernate: Different Join in Save() and Get()
database design help needed
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014