Solved

Oracle RANK() function to Sybase ASE

Posted on 2009-07-09
5
3,387 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
ID: 24813060
SELECT TOP 10 * FROM T

try this


0
 
LVL 6

Accepted Solution

by:
IncisiveOne earned 500 total points
ID: 24814816
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
ID: 24821479
Does anyone know how to configure ASE to support CIS rpc procedures?
0
 
LVL 6

Expert Comment

by:IncisiveOne
ID: 24822058
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can't Access My Database 57 86
ORA-04071: missing BEFORE, AFTER or INSTEAD OF keyword 2 98
Sybase and replication server 13 58
sum of columns in a row in oracle 3 44
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example, show how to take different types of Oracle backups using RMAN.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

733 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