Oracle SQL : FROM keyword not found where expected
my query as follows.
WITH CTE AS
(
SELECT EmpID, EmpName, EmpSalary,
RN = ROW_NUMBER() OVER (ORDER BY EmpSalary DESC)
FROM dbo.Salary
)
SELECT EmpID, EmpName, EmpSalary
FROM CTE
WHERE RN = @8thRow
I am getting error as
Error report -
SQL Error: ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected".
Can someone explain what is wrong with the code?
sql oracle
add a comment |
my query as follows.
WITH CTE AS
(
SELECT EmpID, EmpName, EmpSalary,
RN = ROW_NUMBER() OVER (ORDER BY EmpSalary DESC)
FROM dbo.Salary
)
SELECT EmpID, EmpName, EmpSalary
FROM CTE
WHERE RN = @8thRow
I am getting error as
Error report -
SQL Error: ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected".
Can someone explain what is wrong with the code?
sql oracle
I think you are missing some of the code would you please include the initial part of the code as it is difficult to get as to what your query is
– Himanshu Ahuja
Nov 11 '18 at 20:25
You can't assign a variableRN = ...
like that in Oracle
– a_horse_with_no_name
Nov 12 '18 at 9:28
add a comment |
my query as follows.
WITH CTE AS
(
SELECT EmpID, EmpName, EmpSalary,
RN = ROW_NUMBER() OVER (ORDER BY EmpSalary DESC)
FROM dbo.Salary
)
SELECT EmpID, EmpName, EmpSalary
FROM CTE
WHERE RN = @8thRow
I am getting error as
Error report -
SQL Error: ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected".
Can someone explain what is wrong with the code?
sql oracle
my query as follows.
WITH CTE AS
(
SELECT EmpID, EmpName, EmpSalary,
RN = ROW_NUMBER() OVER (ORDER BY EmpSalary DESC)
FROM dbo.Salary
)
SELECT EmpID, EmpName, EmpSalary
FROM CTE
WHERE RN = @8thRow
I am getting error as
Error report -
SQL Error: ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected".
Can someone explain what is wrong with the code?
sql oracle
sql oracle
edited Nov 12 '18 at 9:27
a_horse_with_no_name
291k46445539
291k46445539
asked Nov 11 '18 at 20:14
DHARMIT JHUNJHUNWALA
1
1
I think you are missing some of the code would you please include the initial part of the code as it is difficult to get as to what your query is
– Himanshu Ahuja
Nov 11 '18 at 20:25
You can't assign a variableRN = ...
like that in Oracle
– a_horse_with_no_name
Nov 12 '18 at 9:28
add a comment |
I think you are missing some of the code would you please include the initial part of the code as it is difficult to get as to what your query is
– Himanshu Ahuja
Nov 11 '18 at 20:25
You can't assign a variableRN = ...
like that in Oracle
– a_horse_with_no_name
Nov 12 '18 at 9:28
I think you are missing some of the code would you please include the initial part of the code as it is difficult to get as to what your query is
– Himanshu Ahuja
Nov 11 '18 at 20:25
I think you are missing some of the code would you please include the initial part of the code as it is difficult to get as to what your query is
– Himanshu Ahuja
Nov 11 '18 at 20:25
You can't assign a variable
RN = ...
like that in Oracle– a_horse_with_no_name
Nov 12 '18 at 9:28
You can't assign a variable
RN = ...
like that in Oracle– a_horse_with_no_name
Nov 12 '18 at 9:28
add a comment |
1 Answer
1
active
oldest
votes
Wrong syntax; an example based on Scott's schema:
SQL> select ename, sal from emp order by sal;
ENAME SAL
---------- ----------
SMITH 920
JAMES 950
ADAMS 1100
WARD 1250
MARTIN 1250
MILLER 1300
TURNER 1500 -- 8th --> you need this one
ALLEN 1600
CLARK 2450
BLAKE 2850
JONES 2975 -- ...
SCOTT 3000 -- 3rd
FORD 3000 -- 2nd
KING 10000 -- 1st, when sort is DESCending
14 rows selected.
SQL> with cte as
2 (select empno, ename, sal,
3 row_number() over (order by sal desc) rn
4 from emp
5 )
6 select empno, ename, sal
7 from cte
8 where rn = 8;
EMPNO ENAME SAL
---------- ---------- ----------
7844 TURNER 1500
SQL>
Exactly you cant setRn=
you need to replace like the above because=
in sql means to check for a condition not to assign a value there is:=
operator for assigning values to variable can try if it works.
– Himanshu Ahuja
Nov 12 '18 at 10:30
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53252782%2foracle-sql-from-keyword-not-found-where-expected%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Wrong syntax; an example based on Scott's schema:
SQL> select ename, sal from emp order by sal;
ENAME SAL
---------- ----------
SMITH 920
JAMES 950
ADAMS 1100
WARD 1250
MARTIN 1250
MILLER 1300
TURNER 1500 -- 8th --> you need this one
ALLEN 1600
CLARK 2450
BLAKE 2850
JONES 2975 -- ...
SCOTT 3000 -- 3rd
FORD 3000 -- 2nd
KING 10000 -- 1st, when sort is DESCending
14 rows selected.
SQL> with cte as
2 (select empno, ename, sal,
3 row_number() over (order by sal desc) rn
4 from emp
5 )
6 select empno, ename, sal
7 from cte
8 where rn = 8;
EMPNO ENAME SAL
---------- ---------- ----------
7844 TURNER 1500
SQL>
Exactly you cant setRn=
you need to replace like the above because=
in sql means to check for a condition not to assign a value there is:=
operator for assigning values to variable can try if it works.
– Himanshu Ahuja
Nov 12 '18 at 10:30
add a comment |
Wrong syntax; an example based on Scott's schema:
SQL> select ename, sal from emp order by sal;
ENAME SAL
---------- ----------
SMITH 920
JAMES 950
ADAMS 1100
WARD 1250
MARTIN 1250
MILLER 1300
TURNER 1500 -- 8th --> you need this one
ALLEN 1600
CLARK 2450
BLAKE 2850
JONES 2975 -- ...
SCOTT 3000 -- 3rd
FORD 3000 -- 2nd
KING 10000 -- 1st, when sort is DESCending
14 rows selected.
SQL> with cte as
2 (select empno, ename, sal,
3 row_number() over (order by sal desc) rn
4 from emp
5 )
6 select empno, ename, sal
7 from cte
8 where rn = 8;
EMPNO ENAME SAL
---------- ---------- ----------
7844 TURNER 1500
SQL>
Exactly you cant setRn=
you need to replace like the above because=
in sql means to check for a condition not to assign a value there is:=
operator for assigning values to variable can try if it works.
– Himanshu Ahuja
Nov 12 '18 at 10:30
add a comment |
Wrong syntax; an example based on Scott's schema:
SQL> select ename, sal from emp order by sal;
ENAME SAL
---------- ----------
SMITH 920
JAMES 950
ADAMS 1100
WARD 1250
MARTIN 1250
MILLER 1300
TURNER 1500 -- 8th --> you need this one
ALLEN 1600
CLARK 2450
BLAKE 2850
JONES 2975 -- ...
SCOTT 3000 -- 3rd
FORD 3000 -- 2nd
KING 10000 -- 1st, when sort is DESCending
14 rows selected.
SQL> with cte as
2 (select empno, ename, sal,
3 row_number() over (order by sal desc) rn
4 from emp
5 )
6 select empno, ename, sal
7 from cte
8 where rn = 8;
EMPNO ENAME SAL
---------- ---------- ----------
7844 TURNER 1500
SQL>
Wrong syntax; an example based on Scott's schema:
SQL> select ename, sal from emp order by sal;
ENAME SAL
---------- ----------
SMITH 920
JAMES 950
ADAMS 1100
WARD 1250
MARTIN 1250
MILLER 1300
TURNER 1500 -- 8th --> you need this one
ALLEN 1600
CLARK 2450
BLAKE 2850
JONES 2975 -- ...
SCOTT 3000 -- 3rd
FORD 3000 -- 2nd
KING 10000 -- 1st, when sort is DESCending
14 rows selected.
SQL> with cte as
2 (select empno, ename, sal,
3 row_number() over (order by sal desc) rn
4 from emp
5 )
6 select empno, ename, sal
7 from cte
8 where rn = 8;
EMPNO ENAME SAL
---------- ---------- ----------
7844 TURNER 1500
SQL>
answered Nov 12 '18 at 7:09
Littlefoot
20.5k71433
20.5k71433
Exactly you cant setRn=
you need to replace like the above because=
in sql means to check for a condition not to assign a value there is:=
operator for assigning values to variable can try if it works.
– Himanshu Ahuja
Nov 12 '18 at 10:30
add a comment |
Exactly you cant setRn=
you need to replace like the above because=
in sql means to check for a condition not to assign a value there is:=
operator for assigning values to variable can try if it works.
– Himanshu Ahuja
Nov 12 '18 at 10:30
Exactly you cant set
Rn=
you need to replace like the above because =
in sql means to check for a condition not to assign a value there is :=
operator for assigning values to variable can try if it works.– Himanshu Ahuja
Nov 12 '18 at 10:30
Exactly you cant set
Rn=
you need to replace like the above because =
in sql means to check for a condition not to assign a value there is :=
operator for assigning values to variable can try if it works.– Himanshu Ahuja
Nov 12 '18 at 10:30
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53252782%2foracle-sql-from-keyword-not-found-where-expected%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I think you are missing some of the code would you please include the initial part of the code as it is difficult to get as to what your query is
– Himanshu Ahuja
Nov 11 '18 at 20:25
You can't assign a variable
RN = ...
like that in Oracle– a_horse_with_no_name
Nov 12 '18 at 9:28