我想做一个 sql 查询,它将采用两个视图并比较数据的差异并仅显示非零的那些。到目前为止,我有以下内容,但它出现了一个错误,说“子查询返回了超过 1 个值”。使用 SQL Server 2008
select * from stl_wk_vw where
ABS((select sum(missing+non_missing) as total from tdn_summary as b join stl_wk_vw as a on a.id = b.id group by b.id)
-
(select sum(st_total) from stl_wk_vw as a join tdn_summary as b on a.id = b.id where standard not like '%non' group by b.id)) > 0