Week in where clause [message #627576] |
Wed, 12 November 2014 15:14 |
|
Omother
Messages: 11 Registered: November 2014
|
Junior Member |
|
|
Hi,
I am looking to create an output which gives me data by week number of the year.
following is my where clause criteria I need help with.
from date table
where report_week = last_week.
I need help creating this filter. I need to automate this so I cannot use week number.
I hope someone can help.
Thanks,
O'mother
|
|
|
|
|
|
|
|
|
|
Re: Week in where clause [message #627651 is a reply to message #627650] |
Thu, 13 November 2014 12:41 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
If I analyzed your post more closely, I may be able to figure out what you are saying, but I don't really have the time for a puzzle right now.
If you provided table descriptions with sample data and actual code run, with the output, it would take the mystery away.
[Updated on: Thu, 13 November 2014 12:43] Report message to a moderator
|
|
|
|
Re: Week in where clause [message #627654 is a reply to message #627650] |
Thu, 13 November 2014 12:49 |
|
EdStevens
Messages: 1376 Registered: September 2013
|
Senior Member |
|
|
Omother wrote on Thu, 13 November 2014 12:37I need to get data for last 6 weeks. I have to automate it so I cannot enter date range. This is my query:
select * from Date_dim where report_date_week >= sysdate(Week,-6);
Report_date_week shows week. Such as 2014 Week 14, 2014 Week 15, 2014 week 16.
So it appears that report_date_week is a varchar containing a character string. A charcter string that YOU see as specifying some date information, but Oracle sees as no different than the character string "Here's your sign.".
Quote:This query is giving error.
I don't see any error. If you have one, why not post it .. in context.
Quote:Date_dim table is a date table and has data at calender day level too. I am joining this with agent table which has following data:
Agent_ID call_date
anc12 16-10-2014
lmo 24 17-10-2014
I need to get data where I can get call_date data for last 6 weeks at week level not by a day.
I hope I provided enough info.
Thanks,
No, you are NOT providing enough. you are providing your interpretation of what you have. People have been asking for actual table definitions. We speak SQL (as in CREATE TABLE .) We assume you do, as well.
But what I can tell is you seem to not understand the difference between DATE and string of characters that humans (but not computers) recognize as representing a date.
see: - But I want to store my date as ...
|
|
|
|
|
|
|
|
|
Re: Week in where clause [message #627699 is a reply to message #627667] |
Fri, 14 November 2014 18:14 |
|
Omother
Messages: 11 Registered: November 2014
|
Junior Member |
|
|
I am not trying to ignore anyone's question but at times I get your responses after I reply to anyone's question.
report_week is a varchar.
call_date is a date.
My report week is between Sunday and Saturday. If I need to extract data then I need data from Sunday to Saturday. That's why it helped. If I run my query between (sysdate -7) and sysdate then it will not adjust my day report date from Sunday to Saturday.
My requirement is to get call_date data data for last 6 weeks for 2014 and also for same 6 weeks for 2013 for comparison. I also need same call date data from YTD 2014 and 2013.
Thanks,
[Updated on: Fri, 14 November 2014 18:25] Report message to a moderator
|
|
|
|
Re: Week in where clause [message #627701 is a reply to message #627700] |
Fri, 14 November 2014 18:41 |
|
Omother
Messages: 11 Registered: November 2014
|
Junior Member |
|
|
Yes, you are correct. I want to compare numbers between week 36 and 42 of 2014 and week 36 an 42 of 2013. I need same YOY comparison for 2014 and 2013 for example: Jan-October 2014 and Jan -October 2013 comparison.
I am done with rest of my query but date is holding me back.
[Updated on: Fri, 14 November 2014 18:43] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: Week in where clause [message #627718 is a reply to message #627709] |
Sat, 15 November 2014 00:40 |
|
Michel Cadot
Messages: 68647 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
Michel Cadot wrote on Thu, 13 November 2014 20:00
What don't you understand in "provide CREATE TABLE and INSERT statements"?
What don't you understand in the links we gave you?
If you don't give what we ask, if you don't make any effort in helping us to help you, why should we make any effort to help you?
Do you deserve to be helped?
|
|
|