Re: Counting two columns with where causes for each

From: Michael J. Moore <hicamel_x_the_spam_at_attbi.com>
Date: Fri, 13 Sep 2002 18:42:32 GMT
Message-ID: <rkqg9.92995$Jo.25234_at_rwcrnsc53>


What do you mean John? Doesn't this do it?

SELECT district,race,count(jobs),count(date_for_raise) FROM info
WHERE district||race IN

           (SELECT distinct district||race
           FROM   info
           WHERE job=15 or date_for_raise is  not null)
GROUP BY district,race

"John Keller" <john_w_keller_at_yahoo.com> wrote in message news: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 - 20:42:32 CEST

Original text of this message