From: Frank Bax <fbax@sympatico.ca>
To: pgsql-sql@postgresql.org
Subject: Re: simple? join
Date: Mon, 07 Jan 2002 17:08:28 -0500
Message-ID: <3.0.6.32.20020107170828.0099e8b0@pop6.sympatico.ca> (raw)
In-Reply-To: <Pine.LNX.4.30.0201060020420.2868-100000@peter.localdomain>
References: <3.0.6.32.20020104121000.00996cb0@pop6.sympatico.ca>
At 12:22 AM 1/6/02 -0500, Peter Eisentraut wrote:
>Frank Bax writes:
>> EMPLOYEE table contains: emp, first, last (emp is unique key)
>> TIMESHEET table contains: emp, timestamp, hours
>> I want to report employee name and total hours.
>> SELECT first, last, sum(ts.hours)
>> FROM timesheet ts, employee emp
>> WHERE ts.emp = emp.emp
>> GROUP by emp.emp, first, last
>> ORDER BY last, first;
>>
>> It seems silly to specify extraneous "group by" fields.
>
>There's nothing "extraneous" there. Both first and last could be
>duplicated, so you need to group by each one.
But first and last can't be duplicated if emp is defined as unique. If I
am also selecting a dozen or so other fields from "employee" table, must I
also include them all in the GROUP BY clause, even though I know "emp"
identifies a unique row in this table?
Frank
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: fbax@sympatico.ca
Subject: Re: simple? join
In-Reply-To: <3.0.6.32.20020107170828.0099e8b0@pop6.sympatico.ca>
* 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