# 多结果返回

select count(*) num1 from orders;
select count(*) num1 from orders where state=1;
select Sum(Price) num2 from orders where state=1;
select count(*) num3 from orders where state=0;
select Sum(Price) num4 from orders where state=0;
...全文
52 点赞 收藏 8

8 条回复

ojuju10 2009-12-29
[Quote=引用 4 楼 abstruct 的回复:]
select count(1) as num,
count(case when state = 1 then '1' end) as num1,
sum(case when state = 1 then price end) as num2,
count(case when state = 0 then '1' end) as num3,
sum(case when state = 0 then price end) as num4
from orders
[/Quote]

fuyou001 2009-12-29
[Quote=引用 3 楼 sql_xep 的回复:]

[/Quote]

Phoenix_99 2009-12-29
select count(*) num,sum(decode (state,1,1,0)) num1,sum(decode (state,1,Price,0)) num2,sum(decode (state,0,1,0)) num3,sum(decode (state,0,Price,0)) from ordrs

select count(1) as num,
count(case when state = 1 then '1' end) as num1,
sum(case when state = 1 then price end) as num2,
count(case when state = 0 then '1' end) as num3,
sum(case when state = 0 then price end) as num4
from orders

qq82296344 2009-12-29
select count(*) num,sum(decode (state,1,1,0)) num1,sum(decode (state,1,Price,0)) num2,sum(decode (state,0,1,0)) num3,sum(decode (state,0,Price,0)) num4 from ordrs

qq82296344 2009-12-29
select count(*) num1 from orders;
select count(*) num1 from orders where state=1;
select Sum(Price) num2 from orders where state=1;
select count(*) num3 from orders where state=0;
select Sum(Price) num4 from orders where state=0;

select count(*) num,sum(decode (state,1,1,0)) num1,sum(decode (state,1,Price,0)) num2,sum(decode (state,0,1,0)) num3,sum(decode (state,0,Price,0)) from ordrs

1.6w+

Oracle开发相关技术讨论