April 25, 2018 at 8:14 pm
I have to split the first three months into weeks. All the weeks should end on saturday and start on friday.
Any suggestions as to how I can accomplish this? Thanks
April 26, 2018 at 4:04 am
First three months of what..? Perhaps you might want to consider investing in a Calendar table: http://www.sqlservercentral.com/articles/calendar/145206/
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
April 26, 2018 at 9:29 am
soldout6000 - Wednesday, April 25, 2018 8:14 PMI have to split the first three months into weeks. All the weeks should end on saturday and start on friday.
Any suggestions as to how I can accomplish this? Thanks
What happens with weeks that include 2 different months?
April 26, 2018 at 10:04 am
dts
as
(
select date '2017-01-01' + rownum-1 dt
from dual
connect by level <= 366
),
rpt_fri_sat as
(
select dt,
case when to_char(dt, 'fmday') = 'friday' then dt end fridays,
case when to_char(dt, 'fmday') = 'friday' then rownum end fri_id,
case when to_char(dt, 'fmday') = 'saturday' then dt end saturdays,
case when to_char(dt, 'fmday') = 'saturday' then rownum end sat_id
from dts
where extract(month from dt) < 4
)
select *
from rpt_fri_sat
The problem is that I want to create appropriate Friday id and Saturday id. How could I do that and how could I get rid of the blank columns?
April 26, 2018 at 10:09 am
I can post a solution for this but it would work on SQL Server. You're working with Oracle, so you should check on an Oracle forum or http://stackoverflow.com/
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply