Converting Oracle SQL Select into PostgreSQL select

后端 未结 2 1277
心在旅途
心在旅途 2021-01-20 17:40

I have this SQL statement:

SELECT ABX.ABX_APO_NUMBER,
       COUNT(A1.PROCESS_MODE) AS NUM_PLANNING,
       COUNT(A2.PROCESS_MODE) AS NUM_SETUP,
       COUNT         


        
2条回答
  •  感情败类
    2021-01-20 18:33

    Here is your query re-written using ANSI-92 JOIN syntax:

      SELECT a.abx_apo_number,
             COUNT(ap1.process_mode) AS NUM_PLANNING,
             COUNT(ap2.process_mode) AS NUM_SETUP,
             COUNT(ap3.process_mode) AS NUM_OUTPUT
         FROM ABX a
    LEFT JOIN USER_INSTANCE u ON u.abx_apo_number = a.abx_apo_number
    LEFT JOIN ACTIVE_PROCESS ap1 ON ap1.process_instance_number = u.instance_number
                                AND ap1.process_mode = 'PLANNING'
    LEFT JOIN ACTIVE_PROCESS ap2 ON ap2.process_instance_number = u.instance_number
                                AND ap2.process_mode = 'SETUP'
    LEFT JOIN ACTIVE_PROCESS ap3 ON ap3.process_instance_number = u.instance_number
                                AND ap3.process_mode = 'OUTPUT'
     GROUP BY a.abx_apo_number
    

    The (+) is Oracle specific LEFT OUTER JOIN syntax. To remove it, would require that each USER_INSTANCE.instance_number would have to have values for the process modes being all three: PLANNING, SETUP, and OUTPUT - omit one, and the abx_apo_number would not be displayed in the output.

提交回复
热议问题