SQL语句,求高手帮忙。。
select 客户编号,用户名称,地址,水表号,
grade.水价 as 单价,电话,
cust.余额-(select sum(应收费用) from acct2013 a where 标志 in (1,3) and a.客户ID=cust.ID) 余额,
--cust.余额
,cust.备注
from customer cust
left join waterroad water on water.ID = cust.水路号
left join custgrade grade on cust.用水分类=grade.ID
--right join acct2013 acct on acct.客户ID=cust.ID
--where acct.标志 in (1,3)
--where (cust.余额-(select sum(应收费用) from #c where 客户ID=cust.ID)>0.000009) or 余额-0>0.000009
group by cust.ID,客户编号,用户名称,地址,水表号,grade.水价,电话,cust.备注,cust.余额
order by 余额
select 客户编号,用户名称,地址,水表号,
grade.水价 as 单价,电话,
cust.余额-(select isnull(sum(应收费用),0) from acct2013 a where 标志 in (1,3) and a.客户ID=cust.ID) 余额,
--cust.余额
,cust.备注
from customer cust
left join waterroad water on water.ID = cust.水路号
left join custgrade grade on cust.用水分类=grade.ID
--right join acct2013 acct on acct.客户ID=cust.ID
--where acct.标志 in (1,3)
--where (cust.余额-(select sum(应收费用) from #c where 客户ID=cust.ID)>0.000009) or 余额-0>0.000009
group by cust.ID,客户编号,用户名称,地址,水表号,grade.水价,电话,cust.备注,cust.余额
order by 余额
select 客户编号,用户名称,地址,水表号,
grade.水价 as 单价,电话,
cust.余额-(select isnull(sum(应收费用),0) from acct2013 a where 标志 in (1,3) and a.客户ID=cust.ID) 余额,
--cust.余额
,cust.备注
from customer cust
left join waterroad water on water.ID = cust.水路号
left join custgrade grade on cust.用水分类=grade.ID
--right join acct2013 acct on acct.客户ID=cust.ID
--where acct.标志 in (1,3)
--where (cust.余额-(select sum(应收费用) from #c where 客户ID=cust.ID)>0.000009) or 余额-0>0.000009
group by cust.ID,客户编号,用户名称,地址,水表号,grade.水价,电话,cust.备注,cust.余额
order by 余额