问题描述
嗨!
我有一个棘手的SQL问题(使用MS SQL Server 2008):
这是显示软件订单和配置的表格:
Hi!
I have a tricky SQL problem (with MS SQL Server 2008):
Thats the table that shows software orders and provisionings:
BookingID |ServiceID|OrderType|PaymentAmount|InstallationBooking
BOO0025958|SRV00979 |10 | 55.00 |NULL
BOO0025959|SRV00749 |10 | 0.00 |NULL
BOO0025960|SRV00971 |10 | 25.00 |NULL
BOO0025961|SRV00812 |10 | 10.00 |NULL
BOO0025962|SRV00820 |10 | 60.00 |NULL
BOO0025963|SRV00812 |20 | 0.00 |BOO0025960
BOO0025965|SRV00788 |10 |165.00 |NULL
BOO0025966|SRV00789 |10 | 45.00 |NULL
...
OrderType 10是一个安装,OrderType 20是一个卸载(总是免费)和InstallationBooking是一个引用原始安装预订的卸载。这意味着在我的示例中,BOO0025960现在已卸载,不应包含在任何计算中。
那么查询是否考虑了ServiceID挂起的ServiceAmount总和卸载的软件???
我没有权利写入表格!
谢谢
彼得
OrderType 10 is an installation, OrderType 20 is an deinstallation (always cost free) and InstallationBooking is a deinstallation that refers to the original installation booking. That means in my example BOO0025960 is now deinstalled and should not be included in any calculation.
So whats the query to get a sum of PaymentAmount grouped by ServiceID taking into account of deinstalled software ???
And I don't have rights to write into the table!
Thanks
Peter
推荐答案
这篇关于棘手的SQL查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!