本文介绍了如何在sql server中查询此报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have this tables "CashMovementTbl","SalesTbl" & "ExpensesTbl" which include data like that:





]



我想显示以下数据:



[]



那么如何在SQL Server中进行查询以显示这样的数据。



http://i.stack.imgur.com/koH6C.jpg[^]

And I want to show my data such as following:

http://i.stack.imgur.com/0jPAl.jpg[^]

So how can I do a query in SQL Server to show data like that.

推荐答案

SELECT CM.CashDate,
	CASE WHEN CM.CashType='IN' THEN S.BillNo ELSE E.ExpnsType END 'Details',
	CASE WHEN CM.CashType='IN' THEN CM.Amount ELSE 0.000 END 'In',
	CASE WHEN CM.CashType='Out' THEN CM.Amount ELSE 0.000 END 'Out'
FROM CashMovementTbl CM
LEFT OUTER JOIN SalesTbl S ON S.SalesID=CM.SalesID
LEFT OUTER JOIN ExpendesTbl E ON E.ExpnsID=CM.ExpenseID





问候,

GVPrabu。



Regards,
GVPrabu.


这篇关于如何在sql server中查询此报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-10 23:08