开发者

SQL command not properly ended

开发者 https://www.devze.com 2023-03-22 03:35 出处:网络
SELECT /*+ PARALLEL(aae,4) */ DISTINCT nvl(aae.voucher_group_id,-1)voucher_group_id, aae.nominal_transaction_amount unit_price,
SELECT /*+ PARALLEL(aae,4) */ DISTINCT nvl(aae.voucher_group_id,-1)  voucher_group_id,
                           aae.nominal_transaction_amount unit_price,
                           aae.original_currency_type currency_type,
                           aae.segmentation_id
             FROM air_account_events aae
            WHERE aae.time_hour_id >= m_start_thid
              AND aae.time_hour_id < m_end_thid
              AND aae.nominal_transaction_amount is not null 
           MINUS
           SELECT vg.voucher_group_id,
                  vg.unit_price,
                  vg.currency_type,
                  vg.segmentation_id
             FROM wh_voucher_groups_dim vg) ahm
    ON (whm.voucher_group_id = ahm.voucher_group_id AND whm.unit_price = ahm.unit_price 
    AND whm.currency_type = ahm.currency_type AND whm.segmentation_id=ahm.segmentation_id) ahm

When i run the following PL/SQL there is an error as

         FROM wh_voucher_groups_dim vg) ahm
                                      *

ERROR at line 14: ORA-00933: SQL command not properly ended

开发者_开发知识库

Can u pls guide where is a error and pls also guide to change



You are missing a JOIN condidition in this line:

FROM wh_voucher_groups_dim vg) ahm
   JOIN ???????
   ON (whm.voucher_group_id ....


EDIT : Based on your comment below... You are probably looking for this..? You need to include the complete inner Query in braces ,give it an alias and then join it to the other table. There is no need to use "USING".

select * from wh_voucher_groups_dim whm,
( SELECT /*+ PARALLEL(aae,4) */ 
         DISTINCT nvl(aae.voucher_group_id,-1)  voucher_group_id,
                           aae.nominal_transaction_amount unit_price,
                           aae.original_currency_type currency_type,
                           aae.segmentation_id
             FROM air_account_events aae
            WHERE aae.time_hour_id >= m_start_thid
              AND aae.time_hour_id < m_end_thid
              AND aae.nominal_transaction_amount is not null 
           MINUS
           SELECT vg.voucher_group_id,
                  vg.unit_price,
                  vg.currency_type,
                  vg.segmentation_id
             FROM wh_voucher_groups_dim vg
 ) ahm
    WHERE  (whm.voucher_group_id = ahm.voucher_group_id AND 
            whm.unit_price = ahm.unit_price AND
            whm.currency_type = ahm.currency_type AND 
            whm.segmentation_id=ahm.segmentation_id)

You probably had an ANSI join syntax earlier and you removed that part in the second query?

SELECT vg.voucher_group_id,
                  vg.unit_price,
                  vg.currency_type,
                  vg.segmentation_id
             FROM wh_voucher_groups_dim vg) ahm
    ON (whm.voucher_group_id = ahm.voucher_group_id AND 
        whm.unit_price = ahm.unit_price AND
        whm.currency_type = ahm.currency_type AND  
        whm.segmentation_id=ahm.segmentation_id) ahm

FROM wh_voucher_groups_dim vg) ahm ON (whm.voucher_group_id = ahm.voucher_group_id AND

Should there be another table aliased whm here?


In order to use the ON keyword, you need a join preceding it. I added JOIN keyword below. You'll need to decide for yourself whether it needs to be a standard join, outer, inner, etc.

             FROM wh_voucher_groups_dim vg) ahm JOIN <table>
    ON (whm.voucher_group_id = ahm.voucher_group_id AND whm.unit_price = ahm.unit_price 
    AND whm.currency_type = ahm.currency_type AND whm.segmentation_id=ahm.segmentation_id) ahm 


My guess is that this is a part from a bigger query and somehow the start part was removed:

SELECT ...                  --- missing part
FROM ...                    --- missing part
    sometable whm           --- missing part
        SOME JOIN           --- missing part
    (                       --- missing part

      SELECT /*+ PARALLEL(aae,4) */ DISTINCT ...
      ...
      FROM wh_voucher_groups_dim vg
    ) ahm
      ON ( whm.voucher_group_id = ahm.voucher_group_id 
       AND whm.unit_price = ahm.unit_price 
       AND whm.currency_type = ahm.currency_type 
       AND whm.segmentation_id=ahm.segmentation_id
         )
0

精彩评论

暂无评论...
验证码 换一张
取 消