From keyword not found where expected oracle ошибка

    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;

I have been getting the error ORA-00923: FROM keyword not found where expected and do not know why, please help

asked Sep 16, 2013 at 14:34

user2784327's user avatar

1

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

answered Sep 16, 2013 at 14:35

a_horse_with_no_name's user avatar

0

Add comma after SELECT QUERY


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 comma after the SELECT BANK_NAME line.

The correct query is:

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

answered Jun 23, 2020 at 20:21

Gabriel Arghire's user avatar

Gabriel ArghireGabriel Arghire

1,9031 gold badge19 silver badges34 bronze badges

0

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

answered Dec 12, 2020 at 2:04

user239512's user avatar

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;

answered Sep 16, 2013 at 14:37

Rahul Tripathi's user avatar

Rahul TripathiRahul Tripathi

167k31 gold badges277 silver badges331 bronze badges

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;

answered Sep 16, 2013 at 14:37

Srini V's user avatar

Srini VSrini V

11k14 gold badges66 silver badges89 bronze badges

1

Similar error will be their when you have invalid select columns like below.
try below SQL and see yourself.

SELECT
    1 ,
    2 ,
    S /*FF               */
    NULL,
    4 ,
    /*FF       */
    NULL,
    /*FF        */
    NULL,
    /*FF                */
FROM
    dual;

answered Dec 10, 2022 at 12:59

Vaibs's user avatar

VaibsVaibs

2,00822 silver badges29 bronze badges

totn Oracle Error Messages


Learn the cause and how to resolve the ORA-00923 error message in Oracle.

Description

When you encounter an ORA-00923 error, the following error message will appear:

  • ORA-00923: FROM keyword not found where expected

Cause

You tried to execute a SELECT statement, and you either missed or misplaced the FROM keyword.

Resolution

The option(s) to resolve this Oracle error are:

Option #1

This error can occur when executing a SELECT statement that is missing the FROM keyword.

For example, if you tried to execute the following SELECT statement:

SELECT *
suppliers;

You could correct this SELECT statement by including the FROM keyword as follows:

SELECT *
FROM suppliers;

Option #2

This error can also occur if you use an alias, but do not include the alias in double quotation marks.

For example, if you tried to execute the following SQL statement:

SELECT owner AS 'owner column'
FROM all_tables;

You could correct this SELECT statement by using double quotation marks around the alias:

SELECT owner AS "owner column"
FROM all_tables;

Option #3

This error can also occur if you add a calculated column to a SELECT * statement.

For example, if you tried to execute the following SQL statement:

SELECT *, CAST((FROM_TZ(CAST(last_modified_date AS timestamp),'+00:00') at time zone 'US/Pacific') AS date) AS "Local Time"
FROM suppliers;

You could correct this SELECT statement by including the table name qualifier in front of the wildcard:

SELECT suppliers.*, CAST((FROM_TZ(CAST(last_modified_date AS timestamp),'+00:00') at time zone 'US/Pacific') AS date) AS "Local Time"
FROM suppliers;

Option #4

You can also generate this error by having an unbalanced set of parenthesis.

For example, if you tried to execute the following SQL statement:

SELECT COUNT(*)) AS "Total"
FROM suppliers;

You could correct this SELECT statement by removing the extra closing parenthesis just prior to the alias:

SELECT COUNT(*) AS "Total"
FROM suppliers;

You need an alias for both derived tables. And the outer pair around the from clause is useless.

SELECT DISTINCT t1.unique_id AS uid, t1.confidence_is_same
FROM ( --<< only one opening parenthesis
  SELECT unique_id,
         confidence_is_same,
         first_name,
         last_name,
         postal_code
  FROM daniel.unique_physician
  WHERE daniel.unique_physician.first_name = ''
  AND   daniel.unique_physician.last_name = ''
  AND   daniel.unique_physician.is_root_phys = 0
  AND   daniel.unique_physician.postal_code = ''
) t1 ---<< the alias for the derived table is missing
  INNER JOIN (
    SELECT max(confidence_is_same) OVER (PARTITION BY root_id) max_conf
    FROM daniel.unique_physician
    WHERE daniel.unique_physician.first_name = ''
    AND   daniel.unique_physician.last_name = ''
    AND   daniel.unique_physician.is_root_phys = 0
    AND   daniel.unique_physician.postal_code = ''
  ) t2 ON t1.confidence_is_same = t2.max_conf

But the join isn’t needed in the first place. Your query can be simplified to:

SELECT DISTINCT t1.unique_id AS uid, t1.confidence_is_same
FROM (
  SELECT unique_id,
         confidence_is_same,
         max(confidence_is_same) OVER (PARTITION BY root_id) max_conf
  FROM daniel.unique_physician unq
  WHERE unq.first_name = ''
  AND   unq.last_name = ''
  AND   unq.is_root_phys = 0
  AND   unq.postal_code = ''
) t1
where confidence_is_same = max_conf;

You don’t need to select first_name, last_name and postal_code in the inner select as you don’t use them in the outer select. This can make the query potentially more efficient.

Additionally, the condition unq.last_name = '' won’t do what you think it does. Oracle does not have an «empty string». A string with length zero ('') will be stored as NULL, so what you really want is probably:

SELECT DISTINCT t1.unique_id AS uid, t1.confidence_is_same
FROM (
  SELECT unique_id,
         confidence_is_same,
         max(confidence_is_same) OVER (PARTITION BY root_id) max_conf
  FROM daniel.unique_physician unq
  WHERE unq.first_name is null
  AND   unq.last_name is null
  AND   unq.is_root_phys = 0
  AND   unq.postal_code is null
) t1
where confidence_is_same = max_conf;

ORA-00923

ORA-00923: ключевое слово FROM не было найдено, где оно ожидалось

Причина:

В операторах SELECT или REVOKE ключевое слово FROM скорее всего пропущено, неправильно размещено, или неправильно написано. Ключевое слово FROM должно сопровождаться последним элементом в SELECT операторе, или привилегией в REVOKE операторе.

Действие:

Вставьте ключевое слово FROM где это следует. Выбранный вами список сам по себе может быть ошибочным.

Any suggestions on what is wrong with my code?
Perhaps it’s not possible to use Left Joins?

I keep getting the error «FROM keyword not found where expected» when my Advanced Editor uses the following code:

let
Source = Oracle.Database(«my server name«, [HierarchicalNavigation=true, Query=»
SELECT ND_EMARS.M_CLM_TB.PD_DT AS Date_Paid, ND_EMARS.M_CLM_TB.TCN_ID AS TCN, ND_EMARS.M_CLM_TB.STATE_COS_CD AS COS, ND_EMARS.M_CLM_TB.FUND_SRC_CD AS FUND_CODE, ND_EMARS.M_CLM_TB.FDOS_DT,
ND_EMARS.M_CLM_TB.LDOS_DT, Sum(ND_EMARS.M_CLM_TB.CMS_RPT_PD_AMT) AS PAID_AMT, Sum(ND_EMARS.M_CLM_TB.CMS_RPT_FED_PD_AMT) AS FEDERAL_AMT,
Sum(ND_EMARS.M_CLM_TB.CMS_RPT_OTHER_PD_AMT) AS DPI_STATE_AMT], ND_EMARS.M_MBR_TB.MBR_NAM_FIRST, ND_EMARS.M_MBR_TB.MBR_NAM_LAST, ND_EMARS.M_MBR_TB.MBR_ALT_ID, ND_EMARS_M_PROV_TB.PROV_ID, ND_EMARS_M_PROV_TB.PROV_NAM_SORT,
ND_EMARS.M_CLM_TB.FIN_RSN_CD, ND_EMARS.M_CLM_TB.FIN_RSN_C, ND_EMARS.M_CLM_TB.PROV_BLNG_SYS_ID, ND_EMARS.M_CLM_TB.MBR_SYS_ID
FROM (ND_EMARS.M_CLM_TB LEFT JOIN ND_EMARS_M_PROV_TB ON ND_EMARS.M_CLM_TB.PROV_BLNG_SYS_ID = ND_EMARS_M_PROV_TB.PROV_SYS_ID) LEFT JOIN
(SELECT ND_EMARS.M_MBR_TB.MBR_SYS_ID, ND_EMARS.M_MBR_TB.MBR_NAM_FIRST, ND_EMARS.M_MBR_TB.MBR_NAM_LAST, ND_EMARS.M_MBR_TB.MBR_ALT_ID
FROM ND_EMARS_M_MBR_TB
GROUP BY ND_EMARS.M_MBR_TB.MBR_SYS_ID, ND_EMARS.M_MBR_TB.MBR_NAM_FIRST, ND_EMARS.M_MBR_TB.MBR_NAM_LAST, ND_EMARS.M_MBR_TB.MBR_ALT_ID)
ON ND_EMARS.M_CLM_TB.MBR_SYS_ID = ND_EMARS.M_MBR_TB.MBR_SYS_ID
WHERE ND_EMARS.M_CLM_TB.SUM_CLM_IND = ‘Y’ AND ND_EMARS.M_CLM_TB.CLM_INC_IND = ‘Y’ AND
ND_EMARS.M_CLM_TB.FIN_RSN_CD <> ‘248’ AND ND_EMARS.M_CLM_TB.FIN_RSN_CD <> ‘249’
GROUP BY ND_EMARS.M_CLM_TB.PD_DT, ND_EMARS.M_CLM_TB.TCN_ID, ND_EMARS.M_CLM_TB.STATE_COS_CD, ND_EMARS.M_CLM_TB.FUND_SRC_CD, ND_EMARS.M_CLM_TB.FDOS_DT, ND_EMARS.M_CLM_TB.LDOS_DT,
ND_EMARS.M_MBR_TB.MBR_NAM_FIRST, ND_EMARS.M_MBR_TB.MBR_NAM_LAST, ND_EMARS.M_MBR_TB.MBR_ALT_ID, ND_EMARS_M_PROV_TB.PROV_ID, ND_EMARS_M_PROV_TB.PROV_NAM_SORT, ND_EMARS.M_CLM_TB.PRCS_PER_YM,
ND_EMARS.M_CLM_TB.FIN_RSN_C, ND_EMARS.M_CLM_TB.PROV_BLNG_SYS_ID, ND_EMARS.M_CLM_TB.MBR_SYS_ID
HAVING (ND_EMARS.M_CLM_TB.FUND_SRC_CD = ‘00700’ Or ND_EMARS.M_CLM_TB.FUND_SRC_CD = ‘00710’) AND Sum(ND_EMARS.M_CLM_TB.CMS_RPT_PD_AMT) <> 0 AND
ND_EMARS.M_CLM_TB.PRCS_PER_YM= ‘2022112’
«])
in
#»Source»

  • From flask import flask ошибка
  • From docx import document ошибка
  • From django db import models ошибка
  • From django contrib import admin ошибка
  • From crypto cipher import aes выдает ошибку