Operating System - HP-UX
1754393 Members
2871 Online
108813 Solutions
New Discussion юеВ

select week and year 1 year in the past

 
SOLVED
Go to solution
Eric Antunes
Honored Contributor

Re: select week and year 1 year in the past

31-03-2004 is week 14 and Q1

01-04-2004 is week 14 but Q2

Week 14 have some days in Q1 and some others in Q2. So it is not very correct to do a quarter analysis just with weeks. That't why you should consider having just a data column...

Best Regards,

Eric Antunes
Each and every day is a good day to learn.
Yogeeraj_1
Honored Contributor
Solution

Re: select week and year 1 year in the past

hi,

you can use the query below to clear all confusions about quarters!:

yd@MYDB.MU> r
1 select dt, to_char(dt,'Q'), mod(to_char(dt,'Q')+1,4)+1
2 from (select add_months(trunc(sysdate,'y'), rownum-1 ) dt
3* from all_objects where rownum <= 12 )

DT T MOD(TO_CHAR(DT,'Q')+1,4)+1
__________ _ __________________________
01/01/2005 1 3
01/02/2005 1 3
01/03/2005 1 3
01/04/2005 2 4
01/05/2005 2 4
01/06/2005 2 4
01/07/2005 3 1
01/08/2005 3 1
01/09/2005 3 1
01/10/2005 4 2
01/11/2005 4 2
01/12/2005 4 2

12 rows selected.

Elapsed: 00:00:00.02
yd@MYDB.MU>

regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Thierry Poels_1
Honored Contributor

Re: select week and year 1 year in the past

hi,

This is about statistics reporting, so a variance might be accepted. It's not about for example interest on your bank account which you want to be correct to the day.

A real date might simplify things, but you can do without. It always depends; maybe you cannot/may not change the table.

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Petr Simik_1
Valued Contributor

Re: select week and year 1 year in the past

Thank u for all advices they are all very conductive.

U r right that Q statistics are not very exact but I have my data only in week resolution than how to make a avg and sum over part of the week?

I can change that table however I want.
I just get this data from excel sheets and they are stored there in this format. I used the same format and thats it.


Mod function is very usefull it solves quite a lot ;-))