CASE statement in WHERE Clause - Weird one
Date: Wed, 21 May 2014 20:59:10 -0700 (PDT)
Message-ID: <eebebd14-6371-42f8-91d5-bdf4dffea93e_at_googlegroups.com>
Hi,
I have this statement in my PL/SQL code:
SELECT ROUND(AVG(pct_total),2)
AND period = v_period;
Pretty straight forward. However, if the value of v_period is 1, I actually want the statement to read:
SELECT ROUND(AVG(pct_total),2)
AND period IN (0,1);
For any other value, it can read:
SELECT ROUND(AVG(pct_total),2)
INTO v_average
FROM pfp_to_buyer_agg
WHERE registration_period >= '01-OCT-2012'
INTO v_average
FROM pfp_to_buyer_agg
WHERE registration_period >= '01-OCT-2012'
INTO v_average
FROM pfp_to_buyer_agg
WHERE registration_period >= '01-OCT-2012'
AND period = v_period;
How can I made the WHERE clause conditional enough to know it should use an IN or an = ? Can this be done?
Thanks! Received on Thu May 22 2014 - 05:59:10 CEST