I need to calculate the measure value from the first of this month to
todays date… I read thro the forum topics for month to date and came up with this sql statement… but it doesnt seem to work…it gives zeros…
avg(case when (TRUCK_UTLIZATION_FACT.SHP_DT>= trunc(SYSDATE,'month') and TRUCK_UTLIZATION_FACT.SHP_DT< =SYSDATE) then TRUCK_UTLIZATION_FACT.INBOUND_TRUCK_UTILIZATION
end )
pls help me…also i need to generate an object for the same month last year …
thanks in advance
newbee
[edited, changed topic title. Please, choose a more meaningful title for your topic other than “urgent help” next time. Thank you, Andreas]
avg(case when
to_char(TRUCK_UTLIZATION_FACT.SHP_DT,'MM-YYYY') >= to_char(SYSDATE,'MM-YYYY')
and TRUCK_UTLIZATION_FACT.SHP_DT <=SYSDATE
then
TRUCK_UTLIZATION_FACT.INBOUND_TRUCK_UTILIZATION
else 0
end)
…now Im left with generating the same object for previous year(from sysdate)…
forgot to mention…i tried add_months but it wouldnt work
it gives me missing right paranthesis error…I m sorry it is a pretty crude way to code …
avg(case when
to_char((add_months(TRUCK_UTLIZATION_FACT.SHP_DT,-12),'YYYY')] >= to_char(add_months(SYSDATE,-12),'YYYY')
and (add_months(TRUCK_UTLIZATION_FACT.SHP_DT,-12) <=add_months(SYSDATE,-12) ]
then TRUCK_UTLIZATION_FACT.OUBOUND_TRUCK_UTILIZATION end )
avg(case when
to_char((add_months(TRUCK_UTLIZATION_FACT.SHP_DT,-12),'MM-YYYY')] >= to_char(add_months(SYSDATE,-12),'MM-YYYY')
and (add_months(TRUCK_UTLIZATION_FACT.SHP_DT,-12) <=add_months(SYSDATE,-12) ]
then TRUCK_UTLIZATION_FACT.OUBOUND_TRUCK_UTILIZATION end )