Received: from tomts20-srv.bellnexxia.net (tomts20.bellnexxia.net [209.226.175.74]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g04HAVm71465 for ; Fri, 4 Jan 2002 12:10:31 -0500 (EST) (envelope-from fbax@sympatico.ca) Received: from ACER ([65.93.0.190]) by tomts20-srv.bellnexxia.net (InterMail vM.4.01.03.16 201-229-121-116-20010115) with SMTP id <20020104171035.CJCC9253.tomts20-srv.bellnexxia.net@ACER> for ; Fri, 4 Jan 2002 12:10:35 -0500 Message-Id: <3.0.6.32.20020104121000.00996cb0@pop6.sympatico.ca> X-Sender: b1wudu74@pop6.sympatico.ca X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Fri, 04 Jan 2002 12:10:00 -0500 To: pgsql-sql@postgresql.org From: Frank Bax Subject: simple? join Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Archive-Number: 200201/36 X-Sequence-Number: 6127 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. So far, I've come up with: SELECT min(emp.first) as first, min(emp.last) as last, sum(ts.hours) FROM timesheet ts, employee emp WHERE ts.emp = emp.emp GROUP by emp.emp ORDER BY last, first; It seems silly to specify "min" when I know there is only one value per emp! 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. Is there a 'better' way to write this SQL? Frank