Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Define/declare dates and use in CTE

To-DaiDec 9 2015 — edited Dec 16 2015

Hello all,

I can't seem to find a working solution to my problem, so now I'm trying my luck here

Basically I want to define a start_date and an end_date which I can then use with a CTE query like this:

WITH OPL

AS (

Select *

FROM TBL_OPLAG

WHERE NR = '11'

     AND OPL_DATE BETWEEN start_date AND end_date

,REK

AS (

SELECT *

FROM REK

WHERE NR = '12'

    AND REK_DATE BETWEEN start_date AND end_date

SELECT *

FROM OPL

JOIN REK ON OPL.OPL_DATE = REK.REK_DATE

So my question is, how can I make this work?

Thanks in advance!

This post has been answered by To-Dai on Dec 16 2015
Jump to Answer

Comments

Solomon Yakobson
Answer
select  to_char(trunc(entry_date,'MM'),'MM YYYY),
        sum(qty) qty
  from  your_table_name
  group by trunc(entry_date,'MM')
  order by trunc(entry_date,'MM')
/

SY.

Marked as Answer by SANPAT · Aug 9 2022
1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 13 2016
Added on Dec 9 2015
1 comment
847 views