Re: Getting matching and non-matching results (long)

From: Roberto Mello <rmello(at)cc(dot)usu(dot)edu>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Getting matching and non-matching results (long)
Date: 2001-12-05 21:54:35
Message-ID: 20011205145435.A9169@cc.usu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, Dec 05, 2001 at 01:07:20PM -0800, Stephan Szabo wrote:
> >
> > SELECT COUNT(incident_id), drug_name, grade_name
> > FROM sds_offenders o, sds_drugs d, sds_drug_offenses do, sds_grades g
> > WHERE o.drug_p = 't'
> > AND o.offender_id = do.offender_id
> > AND d.drug_id = do.drug_id
> > GROUP BY drug_name, grade_name, d.sort_key
> > ORDER BY d.sort_key
>
> I think you need a
> g.gradeid=o.gradeid
> in the where clause as well to constrain g to
> the grade for which the offender belonged, right?

Yes, I figured this mistake minutes after sending the message to the list.
The problem is that with g.grade_id = o.grade_id there it gives me _only_
the grades that have incidents in them, instead of _all_ the grades with
0's for those without incidents.

-Roberto

--
+----| http://fslc.usu.edu USU Free Software & GNU/Linux Club |------+
Roberto Mello - Computer Science, USU - http://www.brasileiro.net
http://www.sdl.usu.edu - Space Dynamics Lab, Developer
"Carrier detected." Go to the dentist...

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-12-05 22:05:33 Re: Getting matching and non-matching results (long)
Previous Message Jan Wieck 2001-12-05 21:29:04 Re: PL/pgSQL examples NOT involving functions