sql 2000 语句求助啊,急!求高手指点
SELECT (case when t.客户代码 is null then '合计' else t.客户代码 end) as 客户代码,t.客户名称,sum(打款)-sum(销售货款) as 货款余额,sum(返利)-sum(销售返利) as 返利余额 FROM (SELECT q.fnumber as 客户代码,q.fname as 客户名称,w.* FROM
(SELECT * FROM t_Organization) as q,(select * FROM dbo.vw_gree_xiaoshoufan) as w where q.fitemid=w.客户) as t
WHERE ((t.销售货款 <> 0) OR
(t.销售返利 <> 0) OR
(t.打款 <> 0) OR
(t.返利 <> 0) OR
(t.货款余额 <> 0) OR
(t.返利余额 <> 0)) AND t.日期<='########'
group by t.客户代码,t.客户名称 with rollup
having t.客户代码 is null OR t.客户名称 is not null
ORDER BY t.客户代码
执行后说:货款余额、返利余额列名无效啊!!!