1 Reply Latest reply on Dec 16, 2015 11:02 AM by To-Dai

    Define/declare dates and use in CTE

    To-Dai

      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!