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
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

Girish SapariyaPosted Mar 3, 2014, 2:46 AM
try this sort of code
declare
@sum1 int= (Select sum(ISNULL(Tbl_StartupBanner.price,0)) from Tbl_StartupBanner),
@sum2 int= (Select sum(ISNULL(Tbl_SignInBanner.price,0)) from Tbl_SignInBanner),
@sum3 int= (Select sum(ISNULL(Tbl_SignOutBanner.price,0)) from Tbl_SignOutBanner)
select (ISNULL(@sum1,0) + ISNULL(@sum2,0) + ISNULL(@sum3,0)) as Total
Hope this helps you :)
Jignesh TrivediPosted Mar 3, 2014, 3:00 AM
Hi,
there is no record in table Tbl_SignOutBanner so you get null result in inner join...
use leftouter join inseted of.
try...
Select sum(isnull(Tbl_StartupBanner.Price,0) + isnull(Tbl_SignInBanner.Price,0) + isnull(Tbl_SignOutBanner.Price,0)) as Total from Tbl_StartupBanner
Inner join Tbl_SignInBanner on 1=1 -- specify the relation between Tbl_StartupBanner and Tbl_SignInBanner
Left outer join Tbl_SignOutBanner on 1=1 -- specify the relation between Tbl_StartupBanner or Tbl_SignInBanner and Tbl_SignOutBanner
hope this will help you.
Sai Prasad AnumoluPosted Mar 3, 2014, 2:25 AM
create Table Tbl_StartupBanner(ImageId int primary key identity(1,1) check(ImageId between 0 and 1), ImagePath nvarchar(Max) NOT Null, Price Money )
This is table Query
Sai Prasad AnumoluPosted Mar 3, 2014, 2:22 AM
Girish SapariyaPosted Mar 3, 2014, 2:20 AM
that will help to understand
Girish SapariyaPosted Mar 3, 2014, 2:19 AM
Sai Prasad AnumoluPosted Mar 3, 2014, 2:15 AM
Girish SapariyaPosted Mar 3, 2014, 2:10 AM
Try this, hope this will work?
Select (sum(ISNULL(Tbl_StartupBanner.Price,0)) + sum(ISNULL(Tbl_SignInBanner.Price,0)) + sum(ISNULL(Tbl_SignOutBanner.Price,0))) as Total from Tbl_StartupBanner,Tbl_SignInBanner,Tbl_SignOutBanner
Thank you :)
Mark it as answer if work for you :)