Re: Stupid SQL Question:

From: shawn everett <everett(at)pgweb(dot)com>
To: Michael Fork <mfork(at)toledolink(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Stupid SQL Question:
Date: 2000-11-15 00:55:55
Message-ID: Pine.LNX.4.30.0011141650490.11590-100000@alder.pgweb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Putting the WHERE clause before the GROUP BY clause worked. I'm too
stupid or too tired to think clearly. :)

Thanks all

Shawn

On Tue, 14 Nov 2000, Michael Fork wrote:

> Try these queries...
>
> SELECT injdate, outcome, count(outcome) FROM safety GROUP BY
> injdate,outcome;
>
> or
>
> SELECT outcome, count(outcome) FROM safety WHERE injdate='2000-11-14'
> GROUP BY outcome;
>
>
>
> Michael Fork - CCNA - MCP - A+
> Network Support - Toledo Internet Access - Toledo Ohio
>
> On Tue, 14 Nov 2000, shawn everett wrote:
>
> > I have a table defined as follows:
> >
> > CREATE TABLE safety (
> > sid SERIAL,
> > side INTEGER,
> > InjDate DATE,
> > InjType INTEGER,
> > Outcome INTEGER,
> > PRIMARY KEY (sid)
> > );
> >
> > What I'm trying to generate is a list of all outcomes and how many of each
> > that occured for a particular range of dates.
> >
> > This works but doesn't do dates:
> >
> > SELECT outcome,count(outcome) from safety
> > GROUP BY outcome;
> >
> > How do I incorporte dates into this query.
> >
> > Adding a WHERE clause to the query doesn't work for example:
> >
> > SELECT outcome,count(outcome) from safety
> > GROUP BY outcome
> > WHERE InjDate='2000-11'14';
> >
> > Any tips or advice would be apreciated.
> >
> > Shawn
> >
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2000-11-15 01:37:42 Strange problem upgrading to 7.0.3x
Previous Message Michael Fork 2000-11-15 00:49:18 Re: Stupid SQL Question: