A表里有30条数据。
B表里有40条数据。如何用sql语句算出共有70条语句。我用
select count(a1.*)+count(a2.*) 总数 from a1,a2.这样统计出来的数目,比实际大很多。
B表里有40条数据。如何用sql语句算出共有70条语句。我用
select count(a1.*)+count(a2.*) 总数 from a1,a2.这样统计出来的数目,比实际大很多。
解决方案 »
- 高分求一条简单的sql语句
- 如何用sql语句返回近一年中每月的数据统计?
- select top 1 * from talk这条语句为什么在oracle中会出错呢?
- 请问有没SQL SERVER 存储过程转成Oracle 存储过程的工具?
- 用什么方法可以查到表空间(如USERDATA)上有哪些表?
- 求一oracle中文教程,立刻给分!!!
- 请教如何在powerDesigner中给字段赋默认值
- 今天一个回复都发不出去,CSDN怎么了?
- 菜鸟问题,大量的数据中怎么删除表中重复行?
- ORA-12514: TNS:listener does not currently know of service requested in connect
- pl/sql 日期问题
- 查询语句问题
--这样
select (select count(*) from a1)+(select count(*) from a2) from dual;
select count(*) from (select col_a from a
union all
select col_b from b) x
;with as c(select * from A
union all
select * from B
)
select count(*) from c
----对于A、B表结构不相同的话
select (select count(a1.*) from A)+(select count(a2.*) from B)
from dual
SQL> select count(*) from emp; COUNT(*)
----------
14SQL> select count(*) from dept; COUNT(*)
----------
4SQL> select
2 (select count(*) from emp)+
3 (select count(*) from dept)
4 sum
5 from dual; SUM
----------
18
from (
select count(*) count1 from a1
union
select count(*) count1 from a2
)