Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Simple SQL?
I like your inner view approach. It can be reduced, however, just to:
select ssal, dno from
(select sum(sal) ssal from emp),
(select sum(deptno) dno from dept)
Putting those 'select' statements into columns like this
select
(select sum(sal) ssal from emp),
(select sum(deptno) dno from dept)
from dual
is against pure relationist's taste.
In article <RZSM6.5779$6j3.511096_at_www.newsranger.com>, Mikito Harakiri says...
>
>Here is a trick how to put 2 aggregates together into one row.
>
>Given
>
>select sal from emp
>
>SAL
>----------
>800
>1600
>1250
>2975
>1250
>2850
>2450
>3000
>5000
>1500
>1100
>950
>3000
>1300
>
>and
>
>SELECT DEPTNO FROM DEPT
>
>DEPTNO
>----------
>10
>20
>30
>40
>
>we get
>
>select s, max(deptno), sum(deptno) from (
>select sum(sal) s, d.deptno from emp, dept d
>group by d.deptno
>) group by s
>
>S MAX(DEPTNO SUM(DEPTNO
>---------- ---------- ----------
>29025 40 100
>
>
>
>
>In article <9e0me6$fcfl$1_at_ID-86706.news.dfncis.de>, Stefan Peschke says...
>>
>>Hi,
>>is there a 'simple' SQL-statement for the following problem?
>>
>>I have 3 tables
>>
>>Tbl a
>>a
>>1
>>
>>Tbl b
>>b1 b2
>>1 1
>>1 2
>>
>>Tbl c
>>c1 c2
>>1 3
>>1 4
>>1 5
>>
>>
>>Relationen
>>a -->> b
>>a -->> c
>>
>>and I want
>>a sum(b) sum(c)
>>
>>in ONE row:
>>
>>a sum(b2) sum(c2)
>>1 3 12
>>
>>Does anyone have a clue?
>>
>>Thank You,
>>
>>Stefan Peschke
>>
>>
>
>
Received on Thu May 17 2001 - 14:25:55 CDT