Super new with SQL and just was wanting a nudge in the right direction I have a payment table with column a) payment date and column b) dispute date. I want to pull all transactions where the dispute date exceeds the payment date by 120 days. I think it should have something to do with a CASE function but again super new to this!
SELECT merch_ref, payment_method, payment_date, dispute_date CASE WHEN dispute_date > (payment_date,120 dd) THEN 'NotLegit' ELSE LEGIT END FROM payment_table
This is my first question and was slightly anxious as I know there is a format that you guys like so, any hints and tips on how to improve my structure of questioning would also be super helpful. On ORACLE
Advertisement
Answer
I want to pull all transactions where the dispute date exceeds the payment date by 120 days. I think it should have something to do with a CASE function but again super new to this!
What you are describing sounds more like filtering, which is WHERE
, not CASE
:
SELECT merch_ref, payment_method, payment_date, dispute_date FROM payment_table WHERE disputer_date > payment_date + interval '120' day;
You would use a CASE
expression to return a new column on each row, but (without a WHERE
) all rows would be returned, not just the ones meeting your condition.