一佳一

记录像1+1一样简洁的代码

导航

整合查询和临时表

Posted on 2010-10-27 10:20  一佳一  阅读(199)  评论(0编辑  收藏  举报

--创建临时表

with 临时表名 as

(

--整合查询(两个查询结果合并)

--比如把父级和对应的子级查出

select * from a where a.id =3

union

select * from a where  a.kid = 3

)

--查询统计零时表

select Sum(Famount) from 临时表名