Here's what I'm up to: I have some data that represents a goal that students are supposed to reach by a given benchmark (in this case, June 15th). I'm looking at a transactional table and running some rollup queries that attempt to figure out how many students were 'on track' at a given point in time, using the techniques described in 'Filling Gaps in Data' and 'Filling Gaps in an Inventory Table' to calculate running/cumulative totals and densify the data. http://download.oracle.com/docs/cd/B28359_01/server.111/b28313/analysis.htm#i1014934
To express student 'progress to the goal' at each row in the table, I'm trying to figure out fractionally how much of the year is left until June 15th, allowing me to compare the running total to a pro-rated version of the goal.
My data looks like:
Measure Goal Year Week Date (YYYY-WW)
106141 400000 2011 42 2011-42
128886 400000 2011 43 2011-43
145449 400000 2011 44 2011-44
156921 400000 2011 45 2011-45
I have a workaround, but it's really hacky and awful.
,case
when year = 2012 then 24 - week
when year = 2011 then (52 - week) + 24
else null
end as weeks_to_june_15
(June 15th is the 24th week of 2012). Is there a more elegant even marginally correct way to do this? Every time I attempt the calculations using date functions I get illegal number or literal does not match format string errors.
It seemed like someone accomplished something somewhat related to what I was trying to do here: https://forums.oracle.com/forums/thread.jspa?threadID=633028 but I'm not sure if rebuilding that date using IYYY and IW would get me where I want to go.
Using Oracle 11gR2 Express and want to do this in the database, if at all possible.
Thanks!