Select trim(WorkHistory.Employee) as Employee, trim(WorkHistory.accounts) as accounts,Badd.money1 as money1,Bdel.money2 as money2,trim(WorkHistory.affair) as affair From ((WorkHistory left join (Select id,Month_Price as money1 from WorkHistory where Month_Price>0 ) as Badd on WorkHistory.id= Badd.id) left join (Select id,Month_Price as money2 from WorkHistory where Month_Price<0 ) as Bdel on WorkHistory.id= Bdel.id) Where " & SelectWhere
看看这的写法是你所要的。
看看这的写法是你所要的。
我没试,我的SQL SERVER坏了,不知道有没有错误,现在我只是不知道这两个表是如何连接的,但是我想我的思路可能会给您一些提示吧
1。在表中找出你>0的临时表
(Select id,Month_Price as money1 from WorkHistory where Month_Price>0 ) as Badd 并与主表关联
2.用同样的言式找出<0的临时表关与主表关联
3。从两个临时表与主表中取出你要的字段就ok了
as colB from TB