pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roberto Mello <rmello@cc.usu.edu>
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Getting matching and non-matching results (long)
Date: Wed, 5 Dec 2001 14:54:35 -0700
Message-ID: <20011205145435.A9169@cc.usu.edu> (raw)
In-Reply-To: <20011205130527.W17641-100000@megazone23.bigpanda.com>
References: <20011205123703.A2725@cc.usu.edu>
	<20011205130527.W17641-100000@megazone23.bigpanda.com>

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...



view thread (4+ messages)  latest in thread

Message-ID: <20011205145435.A9169@cc.usu.edu>
Permalink:  ../20011205145435.A9169@cc.usu.edu/
Also on:    postgresql.org/message-id/20011205145435.A9169@cc.usu.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rmello@cc.usu.edu, sszabo@megazone23.bigpanda.com
  Subject: Re: Getting matching and non-matching results (long)
  In-Reply-To: <20011205145435.A9169@cc.usu.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox