【发布时间】:2018-04-03 07:30:56
【问题描述】:
我试过的查询
select '' as Date,'opening Balance' as Descriptions ,0.00 as credit,0.00 as
debit,Opening as Balance from dbo.Setting
where Opening!=0
union all
select (convert(Varchar(20),EDate,105)) as Date,LocName as
Descriptions,Amount as credit,0.00 as debit,Opening+Amount as Balance
from dbo.CashInward
inner join dbo.OutletMst ON dbo.OutletMst.LocId = CashInward.OutletId
cross join setting
where Edate=convert(Datetime,'03/Apr/2018',105) and deletes!=1 and
Outletmst.Active=1 and Amount!=0
union all
select (convert(Varchar(20),EDate,105)) as Date,AcName as
Descriptions,Amount as credit,0.00 as debit,Opening+Amount as Balance
from dbo.IncExpEntry
inner join dbo.AccountMst ON dbo.AccountMst.Acid = IncExpEntry.Acid
cross join setting
where ETYpe =1 and Edate=convert(Datetime,'03/Apr/2018',105) and Amount!=0
union all
select (convert(Varchar(20),EDate,105)) as Date,AcName as Descriptions,0.00
as credit,Amount as debit,Opening-Amount as Balance from dbo.IncExpEntry
inner join dbo.AccountMst ON dbo.AccountMst.Acid = IncExpEntry.Acid
cross join setting
where ETYpe =2 and Edate=convert(Datetime,'03/Apr/2018',105) and Amount!=0
o/p
我希望余额作为贷方,然后 6700000+贷方,否则借方 6700000-借方,但 2nd,3rd,... 行我想要 6700000+credit+Amount else 670000-debit-amount
【问题讨论】:
-
更新期初余额?加入中
-
无法清楚理解你的预期输出,请同时发布预期输出
-
你使用的是什么版本的
SQL Server? -
这个很不清楚。发布问题的一个重要部分是(令人惊讶地)提出问题。它们以问号 (
?) 结尾。你还没有真正问过。我建议,首先,解释你的目标并提出你的问题。然后提供一些我们可以使用的示例数据。例如Forum Etiquette: How to post Sample data for a T-SQL Question,最后是您的预期结果。该图像看起来不像 SSMS,或者它是旧版本(可能是 SSMS 2005?)。你真的在使用这么旧的 SQL Server 版本吗? -
您正在使用
SQL Server 2000吗?如果不确定,可以在查询窗口中找到版本号,执行PRINT @@VERSION
标签: sql asp.net sql-server