Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Update Question
Here is your SQL command:
SQL> UPDATE DEPT D SET TOT_SAL=(SELECT SUM(SAL) FROM EMP E WHERE D.DEPTNO=E.DEPTNO) Good luck. Quentin.
Teatinos 120, Santiago, Chile Working Fax: 56-2 6921701 e-mail: qxue@sii.cl WWW: http://www.sii.cl -------------------------------------------------------------
shirushah_at_hotmail.com escribió en artÃculo
<737ulf$skt$1_at_nnrp1.dejanews.com>...
> Table Name: Emp
>
> ename sal dnum
> John Chen 1,000 15
> Tom Hanks 2,000 12
> Amy Hall 2,500 15
> Don Fonz 3,000 12
>
> Table Name: Dept
>
> dnum dname tot_sal
> 15 Sales
> 12 R&D
> 14 Marketing
>
> I need to Update DEPT by setting tot_sal equal to the total salary of
> employees in each department. If a department has no employees, tot_sal
> should be set to zero. (I need to use only one sql statement)
>
> So at the end of the update dep should look like this.
> dnum dname tot_sal
> 15 Sales 3,500
> 12 R&D 5,000
> 14 Marketing 0
>
> Thanks
> SS
> ‰
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
Received on Tue Nov 24 1998 - 00:00:00 CST