Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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
Posted
Comments
Siva Hyderabad 4-Mar-14 7:55am    
+4
Siva Hyderabad 4-Mar-14 23:45pm    
tell me?
Sai Prasad anumolu 25-Mar-14 6:46am    
dtgetdetails = objMyBAL.getLogindetails(objPL);

if (dtgetdetails.Rows.Count > 0)
{
Session["username"] = dtgetdetails.Rows[0]["username"].ToString();
Session["lastlogin"] = dtgetdetails.Rows[0]["lastlogin"].ToString();
Session["roletype"] = dtgetdetails.Rows[0]["roletype"].ToString();

Response.Redirect("AddEmployee.aspx");

}

SQL
Select sum(Tbl_StartupBanner.Price + Tbl_SignInBanner.Price + Tbl_SignOutBanner.Price) as Total from Tbl_StartupBanner,Tbl_SignInBanner,Tbl_SignOutBanner



SQL
Select (Tbl_StartupBanner.Price + Tbl_SignInBanner.Price + Tbl_SignOutBanner.Price) as Total from Tbl_StartupBanner,Tbl_SignInBanner,Tbl_SignOutBanner
 
Share this answer
 
Comments
Sai Prasad anumolu 3-Mar-14 1:31am    
Tried sir .. When i was remove sum Total is not display
King Fisher 3-Mar-14 1:46am    
what do you getting?
Sai Prasad anumolu 3-Mar-14 1:51am    
Above Query is working sir , But First two table count price value is 1 , 1 but third table there is no price value .. I need total tables count is 2
King Fisher 3-Mar-14 2:00am    
can show your three table structure with value and expected result Format..
Siva Hyderabad 4-Mar-14 7:54am    
dont call sir to any one ?
try this if table has record but price is null

SQL
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

SQL
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
 
Share this answer
 
v2
Comments
Sai Prasad anumolu 3-Mar-14 1:50am    
kk..If Price value is 1 in datatable . Total comming ..It is working but . I dont have price value in datatable . Frist two table price value is 1, 1 but third table there is not price value . I need total tables count is 2 ..
george4986 3-Mar-14 2:39am    
solution updated plz check
Sai Prasad anumolu 3-Mar-14 3:20am    
Thank u your Code working sir ......
george4986 3-Mar-14 3:41am    
happy to hear gud luck ;-)
Sai Prasad anumolu 3-Mar-14 3:45am    
I have so many douts in database ... Can u please send me you email Id Sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900