Error (ORA-00923: FROM keyword not found where expected)

后端 未结 5 1897
悲哀的现实
悲哀的现实 2020-12-17 08:50
    select 
      country_olympic_name, 
      SUM(part_gold) as \'Number of Gold Medals\'
    From
      games.country,
      games.participation
   where
      par         


        
相关标签:
5条回答
  • 2020-12-17 09:13

    Identifiers need to be quoted with double quotes ("). Single quotes (') denote a character value (not a "name").

    Therefor you need to use:

    SUM(part_gold) as "Number of Gold Medals"
    

    More details in the manual:

    • Database Object Names and Qualifiers
    • Text literals
    0 讨论(0)
  • 2020-12-17 09:23

    In my case, I had this query

    SELECT BANK_NAME
    DECODE (SWIFT_CODE, 'BRDEROBU', 'BRD',
                       'NO RESULT') RESULT
    FROM BANK_GAR;
    

    As you may see, I didn't had the semicolon after the SELECT BANK_NAME line.

    The correct query is:

    SELECT BANK_NAME,
    DECODE (SWIFT_CODE, 'BRDEROBU', 'BRD',
                       'NO RESULT') RESULT
    FROM BANK_GAR;
    
    0 讨论(0)
  • 2020-12-17 09:23

    Check reserved words. This was my issue. For whatever reason using "size" as a column alias caused oracle to spit that exact error out and it had me scratching my head for a while.

    select 1 size, 1 id from dual
    
    0 讨论(0)
  • 2020-12-17 09:33

    You may try doing this:-

    select 
      country_olympic_name, 
      SUM(part_gold) as "Number of Gold Medals"
    From
      games.country,
      games.participation
    where
      participation.country_isocode = country.country_isocode
    group by
      country_olympic_name;
    
    0 讨论(0)
  • 2020-12-17 09:33

    Try this...

    SELECT
          COUNTRY_OLYMPIC_NAME,
          SUM ( PART_GOLD ) AS NUMBER_OF_GOLD_MEDALS
    FROM
          GAMES.COUNTRY,
          GAMES.PARTICIPATION
    WHERE
          PARTICIPATION.COUNTRY_ISOCODE = COUNTRY.COUNTRY_ISOCODE
    GROUP BY
          COUNTRY_OLYMPIC_NAME;
    
    0 讨论(0)
提交回复
热议问题