如何从多个表中总价? [英] How to Sum of total price from multiple tables?
问题描述
我需要来自多个表的总价格值。
这是SQL SERVER查询
选择总和(Tbl_StartupBanner.Price + Tbl_SignInBanner。价格+ Tbl_SignOutBanner.Price)总计来自Tbl_StartupBanner,Tbl_SignInBanner,Tbl_SignOutBanner
Tbl_StartupBanner - 价格值 - 1
Tbl_SignInBanner - 价格值 - 1
Tbl_SignOutBanner - 价格值为无..此表中没有记录...
但是我需要的总数是:2
选择sum(Tbl_StartupBanner .Price + Tbl_SignInBanner.Price + Tbl_SignOutBanner.Price) as 总计来自 Tbl_StartupBanner,Tbl_SignInBanner,Tbl_SignOutBanner
选择(Tbl_StartupBanner.Price + Tbl_SignInBann er.Price + Tbl_SignOutBanner.Price) as 总计来自 Tbl_StartupBanner,Tbl_SignInBanner,Tbl_SignOutBanner
如果表有记录但价格为空则试试这个
选择(ISNULL(Tbl_StartupBanner.Price, 0 )+ ISNULL(Tbl_SignInBanner.Price, 0 )+ ISNULL(Tbl_SignOutBanner.Price, 0 )) 总来自 Tbl_StartupBanner,Tbl_SignInBanner,Tbl_SignOutBanner
if table没有记录试试这个
SELECT ((选择 ISNULL(SUM(Tbl_SignOutBanner.Price), 0 ) FROM Tbl_SignOutBanner)+
(选择 ISNULL(SUM(Tbl_SignInBanner.Price), 0 ) FROM Tbl_SignInBanner)+
(选择 ISNULL(SUM(Tbl_StartupBanner.Price), 0 ) FROM Tbl_StartupBanner)
) as total
I need Total Price Value From multiple tables .
This is SQL SERVER Query
Select sum(Tbl_StartupBanner.Price + Tbl_SignInBanner.Price + Tbl_SignOutBanner.Price) as Total from Tbl_StartupBanner,Tbl_SignInBanner,Tbl_SignOutBanner
Tbl_StartupBanner - Price Value - 1
Tbl_SignInBanner - Price Value - 1
Tbl_SignOutBanner - Price Value is None .. There is No record in This table ...
But i need total count is : 2
Selectsum(Tbl_StartupBanner.Price + Tbl_SignInBanner.Price + Tbl_SignOutBanner.Price) as Total from Tbl_StartupBanner,Tbl_SignInBanner,Tbl_SignOutBanner
Select (Tbl_StartupBanner.Price + Tbl_SignInBanner.Price + Tbl_SignOutBanner.Price) as Total from Tbl_StartupBanner,Tbl_SignInBanner,Tbl_SignOutBanner
try this if table has record but price is null
Select (ISNULL(Tbl_StartupBanner.Price,0) + ISNULL(Tbl_SignInBanner.Price,0) + ISNULL(Tbl_SignOutBanner.Price,0)) as Total from Tbl_StartupBanner,Tbl_SignInBanner,Tbl_SignOutBanner
if table has no records try this
SELECT( (Select ISNULL(SUM(Tbl_SignOutBanner.Price),0) FROM Tbl_SignOutBanner) + (Select ISNULL(SUM(Tbl_SignInBanner.Price),0) FROM Tbl_SignInBanner)+ (Select ISNULL(SUM(Tbl_StartupBanner.Price),0) FROM Tbl_StartupBanner) ) as total
这篇关于如何从多个表中总价?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!