Let's say that I have a range of SQL tables called name_YYYY_WW
, where YYYY = year and WW = week number. If I call a function that leads a user-defined date to the desired table.
If the entered date is "20110101"
:
SELECT EXTRACT (WEEK FROM DATE '20110101')
returns 52 and
SELECT EXTRACT (YEAR FROM DATE '20110101')
returns 2011.
So far there is nothing wrong with these results, I want "20110101"
point to the table name_2010_52
or name_2011_01
, and not name_2011_52
, as it happens now when I combine the results to form a query for the table.
Any elegant solutions to this problem?
Joshua
source share