Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 Select top x * from error

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-10-31 : 07:56:57
Gary writes "I try using the following query from within my compiled code and also from sqlplus query window connected to a lan database. I can connect fine and the query works without the TOP 3 keyword.

Select top 3 * from HX_USER_PASSWORDS where USER_ID = 2 ORDER BY UPPER(PASSWORD_CHANGE_DATE) DESC;

The error I get is:
"ORA-00923: FROM keyword not found where expected"

I have tried replacing the '*' with exact col names but get the same result.

Any ideas on why I am doing wrong? or suggest an alternative that works for both Ora 8i+ and SqlServer 2000."

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-10-31 : 11:45:23
From SQLPlus? Does Oracle even support TOP command?

Tara
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2003-10-31 : 16:20:01
Oracle has a magic word rownum. Try

SELECT *
from HX_USER_PASSWORDS
where USER_ID = 2 and rownum <= 3
ORDER BY UPPER(PASSWORD_CHANGE_DATE) DESC;

--------------------------------------------------------
Visit the SQLTeam Weblogs at [url]http://weblogs.sqlteam.com[/url]
Go to Top of Page
   

- Advertisement -