Sunday, March 28, 2010

Oracle Query Help!

Hi all, do you see any error with query? It is not functioning...Thank u all.

SELECT EMP_EID as EID,

CASE WHEN AVG(AHT) IS NULL THEN 0 ELSE AVG(AHT) END As Value,

?CASE WHEN AVG(AHT) IS NULL then 1 ELSE 0 END As Invalid

?FROM?OPS$RMS.SCM_TEST

?WHERE

?Start_date = {d '2009-07-01'} AND

?End_date = {d '2009-07-31'} AND

?EID IN ( (param 1) , (param 2) , (param 3) , (param 4) , (param 5) )

?GROUP BY EID

?ORDER BY EID

Oracle Query Help!

Just a tip: when you're asking a question along the lines of ''this doesn't work, why?'' it's helpful if you include the error message (or other symptom)?which makes you think it's not working.

- What error are you getting?

- is {d '2009-07-01'} a valid format to express a date in Oracle?

--

Adam

Oracle Query Help!

That is a product of createodbcdate...

That is a product of createodbcdate...

The problem is probably with the dates but please post the source code and not the debug information in that case. I suppose that your ''dates variables'' are string, so you can do something like:

SELECT EMP_EID as EID,

CASE WHEN AVG(AHT) IS NULL THEN 0 ELSE AVG(AHT) END As Value,

?CASE WHEN AVG(AHT) IS NULL then 1 ELSE 0 END As Invalid

?FROM?OPS$RMS.SCM_TEST

?WHERE

?TO_CHAR(Start_date,'YYYY-MM-DD') = '2009-07-01' AND

?TO_CHAR(End_date,'YYYY-MM-DD') = '2009-07-31' AND

?EID IN ( (param 1) , (param 2) , (param 3) , (param 4) , (param 5) )

?GROUP BY EID

?ORDER BY EID

It will work fine with = but if you want to compare %26lt;%26gt; then you need to go with TO_DATE on the strings.

Thank you...

No comments:

Post a Comment