The column is varchar. the column either has a plus or minus sign at the end. For example 00096.45- or 00089.44+ . I need to check to see if the column has a '+' or a '-' sign. if it has a plus sign i multiply by 1 if it has a minus sign i have to multiply by -1 then get the sum. This statement needs to be done in a left join, I am not able to post the table. Is this possible?
            Asked
            
        
        
            Active
            
        
            Viewed 113 times
        
    0
            
            
        - 
                    1If you cannot post the table, can you at least post your attempts at writing the query to show what work you've already done and give us a place to start? – PausePause Dec 03 '18 at 21:35
- 
                    1check out using a case statement. https://stackoverflow.com/questions/10256848/can-i-use-case-statement-in-a-join-condition – Jeremy Dec 03 '18 at 21:37
1 Answers
1
            So you really just want the absolute value...
select 
    t1.column
   ,sum(t2.column) theSum
from 
    table1 t1
    left join
       table2 t2 on t1.column = left(t2.column,len(t2.column) - 1)
group by
    t1.column
Note here I'm dropping your sign which would return the absolute value which usually would be done with the abs function if this wasn't a varchar
 
    
    
        S3S
        
- 24,809
- 5
- 26
- 45
