The below query should return only 4 rows (24-12-2017 to 27-12-2017). I'm using enterprise Postgres with Oracle compatibility.
But some how the last line of the query is not working. It should be because of the ROWNUM. It's ignoring the ROWNUM condition and displaying the number of records in all_objects of db. Could you please help.
WITH a
AS (
Select
date(TRUNC(date(sysdate), 'WW')) FROM_DATE,
date(sysdate)-1 TO_DATE
From dual)
select
date(date(a.FROM_DATE) + rownum -1) from
all_objects,a
where rownum <= date(a.TO_date)+1-date(a.FROM_DATE)+1;
As per comment, adding more information. When I put a random date in the place of sysdate in the above query. the FROM_DATE is supposed to be the start of the week's date. When given 27-12-2017 --> the start date of the week is 24-12-2017(week starts from Monday). So the query should print from 24th - 27th dates. If I give 20-12-2017 --> it should print from 18 to 20th dates. I hope this helps.