Home » RDBMS Server » Server Administration » Order By query
Order By query [message #375038] Fri, 20 July 2001 05:56 Go to next message
Rdamle
Messages: 4
Registered: July 2001
Junior Member
I am running query like this

select * from
(
select prod_id,usoc from product
order by prod_id
)
where region_Cd like 'MB'
I get error 'missing right parenthesis at' and cursor is on word order. What is wrong here?
Re: Order By query [message #375040 is a reply to message #375038] Fri, 20 July 2001 06:50 Go to previous messageGo to next message
Matthew
Messages: 20
Registered: July 2001
Junior Member
Unfortunately,
you cannot have an order by clause in a subquery.
You would have to do something like:

select * from
(
select prod_id,usoc from product
)
order by prod_id
where region_Cd like 'MB'

I don't know where you are getting your region_Cd field from, but they will have to be added in, also, for the where clause to work.
Re: Order By query [message #375046 is a reply to message #375040] Fri, 20 July 2001 07:49 Go to previous messageGo to next message
Rdamle
Messages: 4
Registered: July 2001
Junior Member
Thanks Matthew.
Re: Order By query [message #375075 is a reply to message #375040] Tue, 24 July 2001 04:03 Go to previous message
Matthew
Messages: 20
Registered: July 2001
Junior Member
Actually, I was unsure what dbms Rdamle was using.
If he is using Oracle 8, you cannot have order by in a subquery. Oracle 8i added the ability for this option.

Here is a reference:
http://www.akadia.com/services/ora815nf.html#Top-n%20/%20Bottom-n%20Queries
Previous Topic: Table Transpose
Next Topic: Null Value
Goto Forum:
  


Current Time: Fri Jul 05 11:28:40 CDT 2024