Ora 00923 ошибка

    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,8731 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;

I am trying to concatenate some fields to return a single string for each row from an oracle table. This is in 10g. Here is my query:

SELECT t.value || '|' || t.label || '|' t.label_abbrv || '||' "mylist" 
  FROM list_value t
 WHERE t.value BETWEEN 195001 AND 195300;

I’m getting the «FROM keyword not found where expected» error. This is really annoying. It’s a simple query. I’m sure it’s something simple I’m missing.

OMG Ponies's user avatar

OMG Ponies

324k80 gold badges520 silver badges499 bronze badges

asked Sep 17, 2009 at 13:51

Theresa's user avatar

If you used SQLPLUS client, it would have saved you a little time:

SQL> SELECT value || '|' || label || '|' label_abbrv || '||' "mylist"
  2  from list_value where (value between 195001 and 195300);
SELECT value || '|' || label || '|' label_abbrv || '||' "mylist"
                                                *
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

You can break up your query to multiple lines to isolate the problem:

SQL> edit
Wrote file afiedt.buf

  1  SELECT value || '|'
  2  || label ||
  3  '|' label_abbrv ||
  4  '||' "mylist"
  5  from list_value
  6  where
  7* (value between 195001 and 195300)
SQL> /
'|' label_abbrv ||
                *
ERROR at line 3:
ORA-00923: FROM keyword not found where expected

You might find SQLPLUS to be «primitive,» but, hmmm, that’s good for another question. Let me see if anyone else has asked about it yet.

answered Sep 17, 2009 at 14:04

ericp's user avatar

ericpericp

6112 gold badges11 silver badges17 bronze badges

2

D’oh! I found the problem. I’m missing a concat!

SELECT value || '|' || label || '|' ****||**** label_abbrv || '||' "mylist"
from list_value where (value between 195001 and 195300);

answered Sep 17, 2009 at 13:52

Theresa's user avatar

TheresaTheresa

3,49510 gold badges42 silver badges47 bronze badges

3

I think your answer to your own question is still wrong — it should be:

SELECT value || '|' || label || '|' || label_abbrv || '||' "mylist" 
                                   ^^^^

answered Sep 17, 2009 at 14:01

Tony Andrews's user avatar

Tony AndrewsTony Andrews

129k21 gold badges220 silver badges259 bronze badges

ORA-00923

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

Причина:

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

Действие:

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

oracle tutorial webinars

ORA-00923

ORA-00923 is a commonly seen error that is easily resolved by simply correcting its syntax. Keep in mind ORA-00923 does not occur in Oracle 10g.

The Problem

When you are faced with this error, you will see the following message:

ORA-00923 FROM keyword not found where expected

ORA-00923 occurs when you try to execute a SELECT or REVOKE statement without a FROM keyword in its correct form and place. If you are seeing this error, the keyword FROM is spelled incorrectly, misplaced, or altogether missing. In Oracle, the keyword FROM must follow the last selected item in a SELECT statement or in the case of a REVOKE statement, the privileges. If the FROM keyword is missing or otherwise incorrect, you will see ORA-00923.

The Solution

To resolve ORA-00923, the user should make sure three possible causes are corrected. First, the user must correct the syntax. Make sure you have placed the keyword FROM in its correct place, and that no spelling errors have occurred. Secondly, if you used quotation marks in an alias, make sure that they have properly enclosed the alias and that they are double quotation marks. Lastly, make sure no reserved words were used as an alias. See the Oracle appendix for reserved words to view a complete list. For practical application of these practices on how to resolve ORA-00923, see the following examples.

In the following example, the query is missing the keyword FROM:

SELECT *

employees;

To correct the statement, insert the FROM keyword in the correct place, and run again:

SELECT *

FROM employees;

Another example of the ORA-00923 error is when quotation marks do not properly enclose the alias, as in the following:

SELECT manager AS manager column

FROM all_tables;

The alias—in this example, manager column—is not enclosed in double quotation marks. Resolve ORA-00923 by fixing this syntax mistake.

SELECT manager AS “manager column”

FROM all_tables;

Looking Forward

Avoiding ORA-00923 in the future is a matter of keeping to the proper syntax when executing SELECT or REVOKE statements. While correcting this error is not difficult, simply remember the following rules to avoid seeing this error.

Remember:

  1. The FROM keyword should follow the last selected item. Make sure it is not misspelled, misplaced, or missing.
  2. Make sure you have enclosed the alias in double quotation marks.
  3. Make sure no Oracle reserved word was used as an alias.

If you continue to experience this error, you may consider contacting your database administrator or a licensed Oracle consultant. Always check your consultant’s credentials and experience to ensure they meet your needs.

Понравилась статья? Поделить с друзьями:
  • Ora 00920 ошибка
  • Ora 00907 missing right parenthesis ошибка
  • Ora 00900 invalid sql statement ошибка
  • Ora 00604 ошибка на рекурсивном sql уровне
  • Ora 00600 код внутренней ошибки аргументы