Re: Counting two columns with where causes for each

From: John Keller <john_w_keller_at_yahoo.com>
Date: 12 Sep 2002 20:49:14 -0700
Message-ID: <12c0a6d6.0209121949.436f4a32_at_posting.google.com>


I would do it with the help of a couple of views:

view1 ->
select district, race, count(*) countjobs from info
where job = 15
group by district, race

view2 ->
select district, race, count(*) countdate from info
where date_raised is not null
group by district, race

then your query ->
select i.district, i.race, countjobs, countdate from info i, view1 v1, view2 v2
where i.district = v1.district(+) and i.race = v1.race(+) and i.district = v2.district(+) and i.race = v2.race(+)

I don't think it can be done in a single query...

  • john

aeaas_at_yahoo.com (Matt Novinger) wrote in message news:<19809582.0209101203.682279bf_at_posting.google.com>...
> I apologize for the typo, job=15 was in my initial query, not job=18
>
> Thank you for the reply Mike, but I think I wasn't clear with what I
> need displayed in my original post, I need something like this:
>
> district | race | Count_of_Job | Count_of_Date
> 4 3 11 0
> 7 5 3 25
>
> I need a count of the number of people with job 15 in a certain
> district and of a certain race along with a count of the people who
> have a date to be raised on in any given district and race as well,
> the query Mike gave seems to only return one count?
Received on Fri Sep 13 2002 - 05:49:14 CEST

Original text of this message