如何在一个表结果中放入不同的计数查询

时间:2016-07-18 10:46:32

标签: sql oracle11g oracle-sqldeveloper toad

如果我有这三个计数查询,例如:

首先:

Select count(*)   as red
from A 

result = 10

第二

Select count(*)   as yellow
from B

result = 15

第三

Select count (*)  as green
from C

result = 20

如何使用oracle使结果像

一样
red      yellow      green
10         15          20

2 个答案:

答案 0 :(得分:0)

select (Select count(*) from a) red, (Select count(*) from b) yellow, (Select count(*) from b) green from dual;

答案 1 :(得分:0)

类似的东西:

select * from (Select count(*) as red from A) as count_A
 ,(Select count(*)   as yellow from B) as count_B
 ,(Select count (*)  as green from C) as count_C