ORACLE MINUS关键字的ANSI SQL标准

时间:2014-09-26 12:56:46

标签: oracle ansi-sql ansi-sql-92

我有Query,我希望ANSI SQL标准兼容。在这 oracle查询使用MINUS密钥工作,我想要ANSI SQL 放置MINUS关键字

SELECT   'F' selected,
         UPPER ((   a.business
                 || ' '
                 || a.data_source
                 || ' '
                 || a.frequency
                 || ' '
                 || a.case_symbol
                )
               ) AS display_name,
         SUBSTR ((   a.business
                  || '_'
                  || a.data_source
                  || '_'
                  || a.frequency
                  || (CASE
                         WHEN a.case_symbol IS NULL
                            THEN ''
                         ELSE '_' || a.case_symbol
                      END
                     )
                 ),
                 0,
                 30
                ) AS summary_schema_name,
                 (SELECT ef.frequency_name
            FROM etl_frequencies@etlmgr_srv_ubatchh_lx ef
           WHERE ef.frequency = a.frequency) data_frequency_name,
         a.case_symbol subset_key, '' subset_name
    FROM (SELECT DISTINCT ebdf.business, ebdf.data_source, ebdf.frequency,
                          c.case_symbol
                     FROM  etl_bus_datasrc_frequencies@etlmgr_srv_ubatchh_lx ebdf INNER JOIN etl_rulesets@etlmgr_srv_ubatchh_lx er
                          ON (    ebdf.business = er.business
                              AND ebdf.data_source = er.data_source
                              AND ebdf.frequency = er.frequency
                             )
                          LEFT OUTER JOINe etl_db_output_fact_rules@etlmgr_srv_ubatchh_lx r
                          ON er.ruleset_id = r.ruleset_id
                          LEFT OUTER JOIN etl_db_output_fact_cases@etlmgr_srv_ubatchh_lx c
                          ON r.db_output_fact_rule_id =
                                                      c.db_output_fact_rule_id
          MINUS
          SELECT c.business_unit_key, e.data_source_key, f.data_frequency_key,
                 g.data_source_subset
            FROM  tb_module_summary_schema a INNER JOIN  tb_module b
                 ON a.module = b.module
                 INNER JOIN  tb_business_unit c
                 ON b.business_unit_id = c.business_unit_id
                 INNER JOIN  tb_summary_source_type d
                 ON a.summary_source_type_id = d.summary_source_type_id
                 INNER JOIN  tb_data_source e
                 ON d.data_source_id = e.data_source_id
                 INNER JOIN  tb_data_frequency f
                 ON d.data_frequency_id = f.data_frequency_id
                 LEFT OUTER JOIN  tb_data_source_subset g
                 ON d.data_source_subset_id = g.data_source_subset_id
                 ) a
ORDER BY a.business, a.data_source, a.frequency, a.case_symbol   

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

select <columns>
  from (
        select 'SRC' as data_source, <columns>
          from source_table 
         union all
        select 'TRG' as data_source, <columns>
         from target_table
       )
 group by <columns>
having max(data_source) = 'SRC';