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 Sapariya159 reputationPosted Mar 2, 2014, 9:46 PM EST
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 :)
Girish Sapariya159 reputationPosted Mar 2, 2014, 9:10 PM EST
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 :)
Sai Prasad Anumolu175 reputationPosted Mar 2, 2014, 9:15 PM EST
Girish Sapariya159 reputationPosted Mar 2, 2014, 9:19 PM EST
Girish Sapariya159 reputationPosted Mar 2, 2014, 9:20 PM EST
that will help to understand
Sai Prasad Anumolu175 reputationPosted Mar 2, 2014, 9:22 PM EST
Sai Prasad Anumolu175 reputationPosted Mar 2, 2014, 9:25 PM EST
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
Jignesh TrivediRank #16 · 50.3K reputationPosted Mar 2, 2014, 10:00 PM EST
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.