Thread: SQL date problems
12-27-13, 16:20 #1Registered User
- Join Date
- Aug 2011
Unanswered: SQL date problems
I've been asked to create a weekly report that has year over year - YTD and year over year - Week over Week, can someone help me pull these dates into a temp table so i can pull this report with one query?
I have a DATE_DIM table: YEAR, WEEK_NUM, FULL_DATE etc...
I'm looking for the cleanest way to pull the following dates into a temp table so i can match them to my data tables in a sum statement.
fyi: my company's fiscal year starts Aug 1st and our week starts from SUN - SAT
I need to get the following date ranges:
Current year -> week 01 to current_week - 1 as CURRENT_YTD,
Last year -> week 01 to current week - 1 as LAST_YEAR_YTD
Current Year -> Last week_num
Last Year -> Last week_num
the goal of my report is to compare how the sales are doing Week over Week and year to date.
can someone help? I dont want to write 2 queries unless I really have to!- Using Oracle 11g with Toad v12
12-27-13, 20:16 #2Registered User
Provided Answers: 1
- Join Date
- Aug 2003
- Where the Surf Meets the Turf @Del Mar, CA
> can someone help me pull these dates into a temp table
More often than not, temp tables are not required in Oracle.
Why not just CREATE VIEW that presents the data in the desired format?
we speak SQL.
do you speak SQL?
please post CREATE TABLE statement for the table from which the data needs to be extracted.
>fyi: my company's fiscal year starts Aug 1st and our week starts from SUN - SAT
but this year 1 August is on Thursday; so which actual dates should be included in Week 01?
which actual dates should be included in Week 02?You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Good judgement comes from experience. Experience comes from bad judgement.