-
ORA-00936 with Oracle script
When run the following script returns an ORA-00936 missing expression error.
Code:
select mem_number AS MemNumber,
sum(trans_turnover) AS Turnover
from members
join transact
on mem_number = trans_code
where Trans_date between '01-Jan-2004' and '09-Oct-2008'
and mem_barred = 0
group by mem_number,
order by turnover desc
)
where rownum <=200;
Please tell me what I have done wrong and how do I fix this.
-
Two thing pop up...
1- You are missing a...
select *
from
(
...at the beginning of your script.
2- You want to do "where rownum < 201;"
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
-
ORA-00936 with Oracle script
I do not understand how one would incorporate the select * from (
and I do not see too much difference between rownum < 201 and rownum <= 200
Please give me more detail.
-
Originally Posted by straygrey
I do not understand how one would incorporate the select * from (
and I do not see too much difference between rownum < 201 and rownum <= 200
Please give me more detail.
Don't worry, I got there are a lot of things you are not understanding, try this
Code:
select *
from
(
select mem_number AS MemNumber,
sum(trans_turnover) AS Turnover
from members
join transact
on (mem_number = trans_code)
where Trans_date between '01-Jan-2004' and '09-Oct-2008'
and mem_barred = 0
group by mem_number,
order by turnover desc
)
where rownum < 201;
Last edited by PAVB; 10-10-2008 at 10:05 AM.
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
-
ORA-00936 with Oracle script
I tried your suggestions and still get the same error message.
-
Okay...
Would you please post DESC of both tables as well as complete sql*plus session showing the error?
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
-
Code:
group by mem_number, <--- Remove this comma
-
Originally Posted by chrisrlong
Code:
group by mem_number, <--- Remove this comma
Chrisrlong, as usual, is correct.
-
ORA-00936 with Oracle script
I have now got the code to look like
Code:
select * from
(
mem_number AS MemNumber,
sum(trans_turnover) AS Turnover
from members
join transact
on mem_number = trans_code
where Trans_date between '01-Jan-2004' and '09-Oct-2008'
and mem_barred = 0
group by mem_number
order by turnover desc
)
where rownum <=200;
and now the error I get is ORA-00907: missing right parenthesis.
Help again please.
-
Changing my script to:-
Code:
select MemNumber,Turnover
from
(
select mem_number MemNumber,
sum(trans_turnover) Turnover
from members
join transact
on mem_number = trans_code
where Trans_date between '01-Jan-2004' and '09-Oct-2008'
and mem_barred = 0
group by mem_number
order by turnover desc
)
where rownum <=200;
caused it to work. Thank you for all your suggestions.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|