SELECT count(*) FROM A a,B b,C c WHERE A.YEAR>=2002 AND B.YEAR>=2002 AND
C.YEAR>2002
???
这样做统计不正确,请问正确的写法该怎么写?
...全文
4616打赏收藏
请教:这个SQL语句怎么写?在线给分
有三个表 A,B,C中分别有字段YEAR来储存年份,现在要统计三个表中所有年份>2002的记录总数,SQL语句该怎么写? SELECT count(*) FROM A a,B b,C c WHERE A.YEAR>=2002 AND B.YEAR>=2002 AND C.YEAR>2002 ??? 这样做统计不正确,请问正确的写法该怎么写?
select sum(t) from ((select count(*) as t from a where a.year>2002) union (select count(*) as t from b where b.year>2002) union (select count(*) as t from b where b.year>2002))
select distinct ((select count(*) from a where a.year>2002) + (select count(*) from b where b.year>2002)+ (select count(*) from b where b.year>2002)) as 11 from a