Solved

Oracle RANK() function to Sybase ASE

Posted on 2009-07-09
5
3,175 Views
1 Endorsement
Last Modified: 2013-12-19
Hi experts,

Is there a way of converting (or re-writing) an ORACLE RANK() function into Sybase ASE T-SQL?

I know this is possible in Sybase IQ but I have not seen this function in ASE and was wondering how I could get a query containing RANK to work in Sybase ASE.

Thanks,
1
Comment
Question by:SybaseUk
  • 2
5 Comments
 
LVL 14

Expert Comment

by:shru_0409
Comment Utility
SELECT TOP 10 * FROM T

try this


0
 
LVL 6

Accepted Solution

by:
IncisiveOne earned 500 total points
Comment Utility
Nope.

TOP x will return the first x rows based on your ORDER BY (or the implicit ordering resulting from the index scan).

RANK() returns the position of the row in the result set, OVER (based on) some other identified criteria, such as another column value.

RANK() is easy to implement in Orable because it is ROW_ID based.  Difficult in Sybase because it is purely set oriented.  You will have to use a cursor, ugly as that is.  

I can give you a code struct that does exactly what a cursor does, minus the cursor class of locks and minus the internal overhead; ie. it performs better and allows more concurrency.   An enhanced version is great for pagination as well (return 'pages' of 50 rows at a time from a 7,000 row result set), but it requires a handshake from the front end/web server.

Cheers

0
 

Author Comment

by:SybaseUk
Comment Utility
Does anyone know how to configure ASE to support CIS rpc procedures?
0
 
LVL 6

Expert Comment

by:IncisiveOne
Comment Utility
SybaseUk

The way it works is, you need to close the question, award points, and ask a new question.  You will get a much better response, the only people watching this thread are those who have chosen to watch an "Oracle Rank()" question.

Cheers

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now