Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    29

    Unanswered: Simple select question

    Using TSQL in Sybase:

    1) Is there a way to select the first 5 rows in a table with 20 rows:
    SELECT FIRST 5 score
    FROM data_table
    ORDER BY score
    This is not working for me

    2) Is there a way to make the row count part of the record selection
    SELECT rowcnt, score
    FROM data_table
    ORDER BY score

  2. #2
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    524

    Cool

    1)
    Code:
    set rowcount 5
    select * from myTable
    set rowcount 0
    2) No. A workaround:
    Code:
    select * into #T from MyTable
    alter #t add num numeric(10,0) identity
    select * from #t

  3. #3
    Join Date
    Nov 2002
    Posts
    207
    2) Here is an example for a very simple table. client table with clientid and clientname where clustered index is on clientid.

    select cnt=(select count(*) from client a where a.client_id <= b.client_id), * from client b

Posting Permissions

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