Totaling numbers from two seperate tables..

Results 1 to 2 of 2

Thread: Totaling numbers from two seperate tables..

  1. #1
    Join Date
    Dec 1969

    Default Totaling numbers from two seperate tables..

    I have two tables that I want to take the value from one table and then add another value from another and get a total that can be declared as a variable. Here the select statements to get the two values now how do I add them together. Note both data types are the same (Money)<BR><BR>Declare @AmbTot money, @HosTot money<BR><BR>Set @AmbTot = (Select PaidAmt From dbo.PCExtAmbTotImp<BR><BR>WHERE data_src = @datasrcAmb)<BR><BR>Set @HosTot = (Select PaidAmt From dbo.PCExtHosTotImp<BR><BR>WHERE data_src = @datasrcHos)<BR><BR><BR>Now I need to add both numbers up<BR><BR>Declare @TotalAmbHos varchar(15)<BR><BR>Set @TotalAmbHos = ??????<BR><BR>I originally thought that I could do this:<BR><BR>Set @TotalAmbHos = (CONVERT(varchar,@AmbTot)) + (CONVERT(varchar, @HosTot))<BR><BR>But being that I have converted them it rights out the literal of SELECT TotalAmbHos <BR><BR>

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default uh.....been drinking a lot lately?? :p

    why are you converting them to varchar? how can you ADD strings? you can only concatinate them....convert them to int or float if you want...though you MAY not need to since you have declared them as money<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts