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
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
![]()
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
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 ArghireGabriel Arghire
1,6431 gold badge16 silver badges33 bronze badges
0
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 TripathiRahul Tripathi
165k31 gold badges271 silver badges327 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
![]()
SriniVSriniV
10.9k14 gold badges63 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
![]()
VaibsVaibs
1,98022 silver badges29 bronze badges
The ORA-00923: FROM keyword not found where expected error occurs when the FROM keyword is missing, misspelled, or misplaced in the Oracle SQL statement such as select or delete. The FROM keyword is used to identify the table name. If an error occurs when checking for the FROM keyword, the table name cannot be found. If the the FROM keyword is missing from the SQL query, misspelled, or misplaced in the select statement, Oracle parser will fail to detect the FROM keyword. If the FROM keyword is not found where it should be, an error message ORA-00923: FROM keyword not found where expected will be displayed.
The FROM keyword is used in the select statement to specify the table or view name. The select statement could not identify the table names if the FROM keyword was missing, misspelled, or misplaced. The issue is caused by the FROM keyword or the code written before the FROM keyword. The issue ORA-00923: FROM keyword not found where expected will be fixed if you rewrite the select query along with the FROM keyword.
When this ORA-00923 error occurs
The error will occur in the Oracle database if the FROM keyword is missing, misspelled, or misplaced in the select statement. The error will occur if there are any errors in the code written before the FROM keyword. If you examine the sql query in and around the FROM keyword, you may be able to rectify the error.
select id,name emp;
ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
*Cause:
*Action:
Error at Line: 9 Column: 18
Root Cause
The FROM keyword will be used in the select statement to specify the table or view name from which the data will be retrieved. If the FROM keyword is missing, misplaced, or misspelled in the select statement, the table name cannot be identified. In this example, the select statement expects the presence of a FROM keyword in the query. As a result, an Oracle error “ORA-00923: FROM keyword not found where expected” will be thrown.
Solution 1
If the FROM keyword is not present in the select statement, it should be added before the table or view name. The select statement reads the table or view name and retrieves data from it. Check that the FROM keyword is present in the select query.
Problem
select id,name emp;
ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
Solution
select id,name FROM emp;
Solution 2
Oracle will give an error if the FROM keyword in the select statement is misspelled. The FROM keyword was not found in the query, thus the select statement failed. In this scenario, the table or view name could not be discovered. The FROM keyword must be properly written. The FROM keyword is case insensitive.
Problem
select id,name FRM emp;
ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
Solution
select id,name FROM emp;
Solution 3
If the FROM keyword is misplaced in the select statement, an error notice will be produced. The FROM keyword should come before the table or view name and after the list of column names. If the FROM keyword is used in combination with the name of a column, Oracle will consider the FROM keyword to be one of the columns and will expect the FROM keyword to identify the table or view name.
Problem
select id,name, FROM emp;
ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
Solution
select id,name FROM emp;
Solution 4
If there is a mistake in the list of column names in the select statement, an error message will be displayed. Oracle will treat the error in the column list and expects the FROM keyword in the select statement to specify the table or view name. The column name contains a space in between and no double quotes is used to the column name.
Problem
select id, name as senior manager from emp;
ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
Solution
select id, name as "senior manager" from emp;
Solution 5
The error will be thrown if the column name is identified with a single quotation. The column name should be included in double quotation marks. The issue may be fixed by changing the single quotation to a double quotation. In Oracle, a single quote will be used to identify the string value or date value. In the column names, a double quotation should be utilized.
Problem
select id, name as 'senior manager' from emp;
ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
Solution
select id, name as "senior manager" from emp;
Solution 6
The from keyword error happens in the Oracle database if any of the oracle keywords is used as the column names in the select statement. The keyword should not be used as the name of a column. The issue may be fixed by deleting the keyword from the column name.
Problem
select id as size from emp;
ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
Solution
select id as size_ from emp;
Hello everybody,
i try to get some information from my oracle database. I use the SQL code which is attached to get the informatio. Unfortunately, i always get this failure: Oracle database error 923: ORA-00923: FROM keyword not found where expected.
I have no idea what there is missing. Could anyone help me out in this issue? I really dont know where the failure is…. I printed all out but i didnt find it…
It would be awesome! Thank you in advance.
Best regards
Nicole
SELECT mkpf.budat, mkpf.FRBNR, mseg.CPUDT_MKPF, mkpf.mblnr, mkpf.SPE_BUDAT_UHR AS CPUTM_MKPF, mkpf.mjahr as kopfjahr, mkpf.cputm, mseg.matnr, mseg.mjahr as segjahr, mseg.zeile, mseg.mblnr,
mseg.bwart, mseg.werks, mseg.erfmg, mseg.dmbtr, mseg.lgort
ltap.wdatu ,ltap.qdatu, ltap.qzeit, ltap.VLPLA, ltap.NLPLA, ltap.VLTYP, ltap.NLTYP, ltap.VSOLA, ltap.NSOLA, ltap.werks, ltap.wenum, ltap.wepos, ltak.BDATU, ltak.BZEIT, ltap.TANUM, ltak.tanum, ltak.lgnum, ltak.mblnr
FROM (SELECT LOGSYS, MJAHR, MBLNR, FRBNR, BUDAT, CPUTM, SPE_BUDAT_UHR FROM S_TEC_LOGISTICS.V_MKPF
WHERE LOGSYS=’SAPP81011′ AND MJAHR=’2017′ AND FRBNR != ‘ ‘ AND BUDAT > 20170801) mkpf
INNER JOIN
(SELECT LOGSYS, WERKS, MATNR, MJAHR,
MBLNR, ZEILE ,BWART,
WERKS AS WERK, ERFMG, DMBTR, LGORT FROM S_TEC_LOGISTICS.V_MSEG
WHERE LOGSYS= ‘SAPP81011’ AND MJAHR = ‘2017’ AND WERKS = ‘9820’
AND LGORT = ‘9810’ AND CPUDT_MKPF >= 20170801 AND BWART = ‘101’) mseg
ON mkpf.MBLNR = mseg.MBLNR AND mkpf.MJAHR = mseg.MJAHR
INNER JOIN (SELECT LOGSYS, WERKS, QDATU, QZEIT, VLPLA, NLPLA, VLTYP, NLTYP, VSOLA, NSOLA, WENUM, WEPOS, LGNUM, TANUM FROM S_TEC_LOGISTICS.V_LTAP
WHERE LOGSYS = ‘SAPP81011’ AND WERKS = ‘9820’ AND QDATU >= 20170801 AND LGNUM = ’98G’ AND VLTYP in (‘902′,’423’) AND NLTYP in (‘423′,’424′,’421’)) ltap
ON mseg.MBLNR = ltap.WENUM AND mseg.ZEILE = ltap.WEPOS
INNER JOIN (SELECT LOGSYS, TANUM, LGNUM, MBLNR, BDATU, BZEIT FROM S_TEC_LOGISTICS.V_LTAK WHERE LOGSYS = ‘SAPP81011′ AND LGNUM = ’98G’ AND SUBSTR(QDATU,1,4) = ‘2017’) ltak
ON mkpf.LOGSYS = ltak.LOGSYS AND ltap.TANUM = ltak.TANUM AND ltap.LGNUM = ltak.LGNUM

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;
May 3, 2021
I got ” ORA-00923: FROM keyword not found where expected ” error in Oracle database.
ORA-00923: FROM keyword not found where expected
Details of error are as follows.
ORA-00923 FROM keyword not found where expected Cause: In a SELECT or REVOKE statement, the keyword FROM was either missing, misplaced, or misspelled. The keyword FROM must follow the last selected item in a SELECT statement or the privileges in a REVOKE statement. Action: Correct the syntax. Insert the keyword FROM where appropriate. The SELECT list itself also may be in error. If quotation marks were used in an alias, check that double quotation marks enclose the alias. Also, check to see if a reserved word was used as an alias.
FROM keyword not found where expected
This ORA-00923 errors are related with the SELECT or REVOKE statement, the keyword FROM was either missing, misplaced, or misspelled. The keyword FROM must follow the last selected item in a SELECT statement or the privileges in a REVOKE statement.
For example;
If you run the following query, you will get this error, because you don’t use FROM keyword.
SELECT * employees;
You need to use FROM keyword as follows.
SELECT * from employees;
To solve this error, Correct the syntax. Insert the keyword FROM where appropriate. The SELECT list itself also may be in error. If quotation marks were used in an alias, check that double quotation marks enclose the alias. Also, check to see if a reserved word was used as an alias.
Do you want to learn Oracle Database for Beginners, then read the following articles.
Oracle Tutorial | Oracle Database Tutorials for Beginners ( Junior Oracle DBA )
1,249 views last month, 1 views today
Таким образом, у меня есть эта таблица, каждая колонна ‘A, B, C’ представляющая сторона треугольника соответственно.
A | B | C
20 | 20 | 23
20 | 20 | 20
20 | 21 | 22
13 | 14 | 30
Я хочу проверить, соответствует ли значение A = B, и если да, отобразить на экране «Равнобедренный».
Я не могу за жизнь меня неимую снимать эту проблему. Вот мой простой запрос:
SELECT * AS 'Isosceles'
FROM TRIANGLES
WHERE TRIANGLES.A = TRIANGLES.B;
Похоже, синтаксис в порядке, а псевдоним заключен в одинарные кавычки. Может ли кто-нибудь взглянуть и сказать мне, что случилось?
3 ответа
Лучший ответ
Похоже, синтаксис в порядке, а псевдоним заключен в одинарные кавычки. Может ли кто-нибудь взглянуть и сказать мне, что случилось?
Одиночные кавычки — это как раз то, что не так. Когда вы задаете псевдоним для чего-либо, вам нужно использовать те же правила, которые вы используете при именовании объектов и столбцов, без кавычек, чтобы Oracle рассматривал это как верхний регистр по умолчанию, или использовать двойные кавычки, чтобы вы могли решить сами. Всегда нужно тщательно продумывать все, что чувствительно к регистру, это требует больших усилий, и о нем часто забывают. Вы же не хотите тратить часы на чесание в затылке, говоря: «Это должно быть здесь».
select object_id as 'a' from all_objects where 1=0;
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
select object_id as a from all_objects where 1=0;
no rows selected (success)
select object_id as "a" from all_objects where 1=0;
no rows selected (success)
Изменить — после пересмотра того, что вы действительно могли бы получить после: Кроме того, вы не можете просто присвоить каждому столбцу одно целое, это странно. Вы могли иметь в виду дополнительную строку вроде
select triangles.*, 'Isosceles' triangle_type
from triangles
WHERE TRIANGLES.A = TRIANGLES.B;
2
Andrew Sayer
2 Ноя 2020 в 21:07
Да не совсем; если я вас правильно понял, вы должны использовать CASE (строки 1–6 представляют собой образцы данных; они у вас уже есть, поэтому нужный вам запрос начинается со строки № 7):
SQL> with test (a, b, c) as
2 (select 20, 20, 23 from dual union all
3 select 20, 20, 20 from dual union all
4 select 20, 21, 22 from dual union all
5 select 13, 14, 30 from dual
6 )
7 select a, b, c,
8 case when a = b then 'Isosceles'
9 else 'not isosceles'
10 end result
11 from test;
A B C RESULT
---------- ---------- ---------- -------------
20 20 23 Isosceles
20 20 20 Isosceles
20 21 22 not isosceles
13 14 30 not isosceles
SQL>
2
Littlefoot
2 Ноя 2020 в 20:44
Также может помочь декодирование.
Выберите a, b, c, расшифровать (a, b, ‘равнобедренный’, ‘не равнобедренный’) IS_ISOSCELES из треугольников;
A B C IS_ISOSCELES
20 20 23 Isosceles
20 20 20 Isosceles
20 21 22 not isosceles
13 14 30 not isosceles
0
Ashish sinha
3 Ноя 2020 в 02:40