答案 0 :(得分:3)
您不需要在tbl_AccountLedger
子句中再次阅读select
数据,因为您已经joins
(通过相同的连接/条件)已经拥有该数据,只需替换您的(select......) ll
部分l.ledgerName
喜欢这个
select l.ledgerName, sum(m.debit), sum (m.credit),
from tbl_LedgerPosting as m
left join [dbo].[tbl_VoucherType] as v on m.voucherTypeId=v.voucherTypeId
left join [dbo].[tbl_AccountLedger] as l on m.ledgerId=l.ledgerId
group by v.coucherTypeName, m voucherNo, l.ledgerName
order by v.coucherTypeName, m voucherNo