Oracle Database - SQL - With clause

Table of Contents

2 - Example

WITH
  myFirstBlock AS
  (
    SELECT
      Table1.Code       ,
      Table1.Description,
      Table1.Action     ,
      Table2.Team
    FROM
      Table1,
      Table2
    WHERE
      Table1.Id=Table2.Id
    AND
      Table1.Id <>-1
    AND
      Table1.Id <>-2
  )
  ,
  mySecondBlock AS
  (
    SELECT DISTINCT Code  FROM myFirstBlock 
  )
SELECT
  *
FROM
  myFirstBlock
WHERE
  Code IN
  (
    SELECT Code FROM myFirstBlock HAVING COUNT(*) > 1 GROUP BY Code
  )
ORDER BY
  Code
db/oracle/with.txt ยท Last modified: 2017/09/06 19:29 by gerardnico