Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: ANSI Join improvement

Re: ANSI Join improvement

From: Dieter Noeth <dnoeth_at_gmx.de>
Date: Wed, 21 Jun 2006 22:11:22 +0200
Message-ID: <e7c95t$ihd$1@online.de>


kvnkrkptrck_at_gmail.com wrote:

> SELECT DEPT.Dept_id "Department ID", Name "Department Name",
> SUM(Salary) "Total Salary"
> FROM DEPT JOIN EMP
> ON EMP.Dept_id = DEPT.Dept_id
> GROUP BY DEPT.Dept_id, Name;
>
> I would love to see a middle ground:
> SELECT Dept_id "Department ID", Name "Department Name", SUM(Salary)
> "Total Salary"
> FROM DEPT JOIN EMP ON Dept_id
> GROUP BY Dept_id, Name;

You almost got it...
It's already there since SQL92, the syntax is sligthly different :-)

<named columns join> ::=
USING <left paren> <join column list> <right paren>

SELECT Dept_id "Department ID", Name "Department Name", SUM(Salary) "Total Salary"
FROM DEPT JOIN EMP USING (Dept_id)
GROUP BY Dept_id, Name;

Some DBMSes support it, e.g. Oracle, PostgreSQL, mysql

Dieter Received on Wed Jun 21 2006 - 15:11:22 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US