Re: sum(field) as total group with a where condition...

From: dave(at)hawk-systems(dot)com (Dave)
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: sum(field) as total group with a where condition...
Date: 2001-09-09 23:22:51
Message-ID: DBEIKNMKGOBGNDHAAKGNKEEEIGAA.dave@hawk-systems.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>> and want it to find all those that match a particular date (field2),
>then return
>> sums for each field1... using the above table should generate the following
>> result for field2=12345
>
>select
> field1,field2,sum(field3) as total
>from
> table
>where
> field2=12345
>group by
> field1, field2
>;

forgot to group by both fields that were not in the sum function...
beautiful... thanks to those who responded.

Dave

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2001-09-09 23:46:38 Re: Idea: jobs.postgresql.org
Previous Message Justin Clift 2001-09-09 22:04:23 Re: Idea: jobs.postgresql.org