Error (ORA-00923: FROM keyword not found where expected)
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
Using CTE in Oracle SQL (ORA-00923: FROM keyword not found where expected)
I have replace *
in your sub query with dates, items
and changed group by clause from group by 1,2
to group by dates, items
. It's working.
But I would suggest to use query#2 which is more readable in my opinion and easy to change in future.
create table items(dates varchar2(200), item VARCHAR2(200));
insert into items values ('01-01-20', 'apple');
insert into items values ('01-01-20', 'apple');
insert into items values ('01-01-20', 'pear');
insert into items values ('01-01-20', 'pear');
insert into items values ('01-02-20', 'pear');
insert into items values ('01-02-20', 'pear');
insert into items values ('01-02-20', 'pear');
insert into items values ('01-02-20', 'orange');
Query#1:
select dates, item
from
(
SELECT dates,item, rank() OVER (PARTITION by dates ORDER BY item_count DESC) AS date_rank
FROM
(
SELECT dates, item, count(*) AS item_count
FROM items
GROUP BY dates, item
ORDER BY dates) )
where date_rank=1;
Output:
DATES | ITEM |
---|---|
01-01-20 | apple |
01-01-20 | pear |
01-02-20 | pear |
Leetcode Oracle - ORA-00923: FROM keyword not found where expected
If you need to select only all the columns then *
without the alias is fine. But if You need to give alias of the table wherever you want to select all the columns of the table using *
and also another expression in SELECT
clause.
with TEMP AS
( SELECT
COL1,
COL2
FROM table )
, TEMP1 AS
(SELECT
T.*, -- alias here
"hello" AS COL3
FROM TEMP T
)
select * FROM TEMP1;
with temp as
(
select d.Name as Department,
e.Name as Employee,
e.Salary as Salary
from employee e
join department d
on e.DepartmentId = d.Id
)
select T.* -- alias here
, rank() over (partition by department order by salary desc) as rr
from temp T;
Oracle SQL Developer - Error: FROM keyword not found where expected
You have a trailing comma in the last table (proddta.f4301 c
) of FROM
clause and should become
...
FROM PRODDTA.F5543170 a,
proddta.f4209 b,
proddta.f4301 c
...
which should be removed.
You also have a trailing comma in your select statement that should also be removed.
...
rank() over (partition by pckcoo, pcdoco, pcdcto, pclnid order by FX_PARA_GREGORIANA(HORDJ, 'DD/MM/YYYY')||' '||rpad(HORDT,6,'0') desc) as rank
...
Finally, for table alias you need to use double instead of single quotes:
select
PCKCOO AS "COMPANHIA_DO_PEDIDO_NUMERO_DO_PEDIDO",
PCDOCO AS "DOCUMENTO_NUMERO_DA_OS_FATURA",
PCDCTO AS "TIPO_DE_ORDEM",
PCSFXO AS "SUFIXO_DO_PEDIDO",
rpad(HORDT,'0',6) AS "HORARIO_DE_LIBERACAO",
...
Related Topics
SQL Query Where Date = Today Minus 7 Days
MySQL Is Array in Multiple Columns
Postgresql Reusing Computation Result in Select Query
Hibernate Create Criteria to Join the Same Table Twice - Tried 2 Approach with 2 Difference Error
"An Item with the Same Key Has Already Been Added" Error on Ssrs When Trying to Set Dataset
Sqlite Multiple Autoincrement Columns
Concatenate Multiple Rows in One Field in Access
Why Doesn't Oracle Raise "Ora-00918: Column Ambiguously Defined" for This Query
How to Update with Inner Join in Oracle
Concat Group by in Vertica SQL
How to Parse a Varchar Passed to a Stored Procedure in SQL Server