Link to home
Create AccountLog in
Avatar of JRockFL
JRockFLFlag for United States of America

asked on

SQL Help, Add case statement?

In the table OR_TransactionHeader there are two columns Amt_Age_Prd_3 and Amt_Age_Prd_4.
If either of these are columns are greater than 0 then
SET note_5 = CAST(b.CurrentBalance AS VARCHAR(5))  + ' OrthoRewards Points'
else
SET note_5 = CAST(b.NewBalance AS VARCHAR(5))  + ' OrthoRewards Points'

Is that possible to do?
DECLARE @LastInsert DateTime
SELECT @LastInsert = MAX(DateAdded) FROM OR_TransactionHeader 
 
UPDATE a
SET note_5 = CAST(b.NewBalance AS VARCHAR(5))  + ' OrthoRewards Points'
FROM Macola.Data.dbo.ARCUSFIL_SQL a
INNER JOIN OR_TransactionHeader b
ON a.Cus_No = b.Cus_No
WHERE b.DateAdded = @LastInsert

Open in new window

SOLUTION
Avatar of appari
appari
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of JRockFL

ASKER

Thank you everyone