Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    7

    Unanswered: Generalising Rownum for all the databases

    Hi

    I have as issue with this rownum.This is supported in different forms in different databases like top in mssql ,limit in mysql and all..i want to genaralise this independent of the type of database because i want to run the query as i wont be knowing the type of the DB used by my user.

    can anyone suggest a solution for this ? is there anyway of generating a series of numbers with the query by calling the function in that query repetitively ???


    Regards
    Sreenath

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    A UDF won't help you, because not all databases support User Defined Functions.

    I think you will need to use something like this, which requires a primary key or unique sort order on your result set:

    select a.Pkey, count(*) as RowNum
    from YourTable a
    inner join YourTable b on a.Pkey >= b.Pkey
    group by a.PKey
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •