simple? join

Поиск
Список
Период
Сортировка
От Frank Bax
Тема simple? join
Дата
Msg-id 3.0.6.32.20020104121000.00996cb0@pop6.sympatico.ca
обсуждение исходный текст
Ответы Re: simple? join  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-sql
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 empWHERE ts.emp =
emp.empGROUPby emp.empORDER 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 empWHERE ts.emp = emp.emp GROUP by emp.emp, first,
lastORDERBY last, first;
 

It seems silly to specify extraneous "group by" fields.

Is there a 'better' way to write this SQL?

Frank


В списке pgsql-sql по дате отправления:

Предыдущее
От: Andrew Perrin
Дата:
Сообщение: Telling how many records are joined
Следующее
От: Bill Cunningham
Дата:
Сообщение: Re: Telling how many records are joined