Re: [plain SQL Problem] Group By

From: Date: Wed, 28 May 2003 14:12:30 +0000
Subject: Re: [plain SQL Problem] Group By
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-28122@lists.php.net to get a copy of this message
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

« previous php.db (#28122) next »