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
 General SQL Server Forums
 New to SQL Server Programming
 Oracle PL / SQL - Elaborating ranking

Author  Topic 

Javier00
Starting Member

3 Posts

Posted - 2009-06-04 : 15:18:01
Good day people.
I am glad to see some forums of SQL Online.

I have an issue with Oracle.

You see, from a select that returns unsorted lines i would want to:
be able to view the top 5 itmes on a determined 'column'.

To clarify my request:
lets _supose_ there is a table called 'Product' wich has 10 values.
'Product' has three columns 'cost' 'in' 'out'.

SELECT in FROM Producto;

will show me all rows... now how can i get a ordered 'ranking of 5 items' of this table from top to less if result is all unsorted?.

heard that SELECT TOP 5 WITH TIES... could be some hint, but i am not really sure as i am still learning.

Could you please give a hand on this?


webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-04 : 15:28:49
Do you mean this?
http://harriyott.com/2007/06/with-ties-sql-server-tip.aspx


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Javier00
Starting Member

3 Posts

Posted - 2009-06-04 : 15:38:02
Thank you for the reply webfred, i'll check it.
:) anything helps when is about learning.
Go to Top of Page

Javier00
Starting Member

3 Posts

Posted - 2009-06-05 : 23:21:15
Hey i found some solution to this:

SELECT * FROM
(SELECT name, description
FROM TABLEA
ORDER BY NAME)
WHERE rownum <=10


^^
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-06 : 06:01:50
quote:
Originally posted by Javier00

Hey i found some solution to this:

SELECT * FROM
(SELECT name, description
FROM TABLEA
ORDER BY NAME)
WHERE rownum <=10


^^


Aha and where is the column rownum?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -