Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2007
    Posts
    17

    Unanswered: Retriving the Top row

    I need to retrieve topmost value of a column in sybase. My query goes something like this: Select col1, col2, (select top 1 col3 from table1) as expr1from table2 where ......... group by....... having......

    It gives me an error near top.

    Could u help me out with this?

    Regards,
    Sajitha

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Unlike Microsoft SQL Server, Adaptive Server Enterprise version 12.5.3 does not supports the top n clause in the select list of a subquery.

  3. #3
    Join Date
    Aug 2007
    Posts
    2
    Perhaps using min(col3) or max(col3) could help you out?

    Grtz,

    Jeroen

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by sajita
    My query goes something like this: Select col1, col2, (select top 1 col3 from table1) as expr1from table2 where ......... group by....... having......
    the solution goes something like this --

    select col1, col2, ( select col3 from table1 where ... ) as expr1 from table2 where ......... group by....... having......
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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