Re: [plain SQL Problem] Group By

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Em Wed, 28 May 2003 14:54:19 +0200
Sapporo <sapporo@land.ru> escreveu:

> Hi,
> 
> sorry if this is off topic. I hope you don't mind a plain SQL question 
> here.

Maybe this works...

SELECT D.dept_name, MIN(E1.emp_age) AS YOUNGEST_AGE, 
       MAX(E2.emp_age) AS OLDEST_AGE, E1.emp_name AS YOUNGEST_NAME,
       E2.emp_name AS OLDEST_NAME
FROM dept D, emp E1, emp E2
WHERE E1.emp_dept_id = D.dept_id
AND E2.emp_dept_id = D.dept_id
AND E1.emp_id <> E2.emp_id
GROUP BY D.dept_name, E1.emp_name, E2.emp_name

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux