Re: SQL Question
From: Mark <nwa_at_protocom.com>
Date: 1996/05/20
Message-ID: <4noql0$m2q_at_tracy.protocom.com>#1/1
Date: 1996/05/20
Message-ID: <4noql0$m2q_at_tracy.protocom.com>#1/1
In article <4nm320$6ip_at_newsboy.mtc.ti.com> bradyd_at_ti.com (Brady D'Andrea) wrote:
> Hi,
>
> For the life of me, I can't figure out the proper SQL statement to return the
> information I need. I'm searching a table based on two criteria. I need a
> count of all rows returned that match the second criteria grouped by the first
> critera, but I need items from the first criteria that don't match the second
> to return a count of 0
Just make a small adjustment to your original
(SELECT person, COUNT(tool) FROM A WHERE city IN ('DALLAS') AND tool IN ('Hammer') GROUP BY person) UNION (SELECT person, '0' FROM A WHERE city IN ('DALLAS') AND tool NOT IN ('Hammer') GROUP BY person);
Regards, Mark Received on Mon May 20 1996 - 00:00:00 CEST