两表全连接与聚合函数问题
select m.学号,SUM(欠费合计) from table1 as m where m.学号 not like '%人' group by m.学号 order by m.学号
select n.* from table2 as n where n.欠费金额 != 0 AND n.学号 is not null order by n.学号
table1与table2按学号是否相等如何实现全连接 ???
[解决办法]
select *
from
(
select m.学号,SUM(欠费合计) as t
from table1 as m
where m.学号 not like '%人'
group by m.学号
)a
full join
(
select n.* from table2 as n
where n.欠费金额 != 0 AND n.学号 is not null
)b
on a.学号 = b.学号
select *
from
(
select m.学号,SUM(欠费合计) as t
from table1 as m
where m.学号 not like '%人'
group by m.学号
)a
full join
(
select n.* from table2 as n
where n.欠费金额 != 0 AND n.学号 is not null
)b
on a.学号 = b.学号
where isnull(a.欠费,0) <> isnull(b.欠费,0)