Results 1 to 3 of 3

Thread: [RESOLVED] Order By clause (TOP clause)

  1. #1

    Thread Starter
    Addicted Member Golfreak's Avatar
    Join Date
    Oct 2005
    Location
    stuck in a cube
    Posts
    147

    Resolved [RESOLVED] Order By clause (TOP clause)

    Hi all,

    Its me again with yet another question.

    I am using SQLServer 2000 and in a view that I am building I have two SELECT statements joined by a UNION. All the info from both statements appears in one column (as it should), but I want the info from the first SELECT to appear on top (its just one line).

    I have an ORDER BY clause in my view but when I try to apply it, SQL tells me that I must specify the TOP clause.

    I have no idea how to accomplish this task.

    Can anyone help???
    Last edited by Golfreak; Feb 17th, 2006 at 10:13 AM.
    jg

  2. #2
    Fanatic Member kaffenils's Avatar
    Join Date
    Apr 2004
    Location
    Norway
    Posts
    946

    Re: Order By clause (TOP clause)

    UNION automatically sorts and distincts the rows in the tables you UNION.
    If you want the data to appear in the order of the tables in the UNION you should use UNION ALL.

  3. #3

    Thread Starter
    Addicted Member Golfreak's Avatar
    Join Date
    Oct 2005
    Location
    stuck in a cube
    Posts
    147

    Re: Order By clause (TOP clause)

    Thanks kaffenils,

    That did the trick!
    jg

Posting Permissions

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



Click Here to Expand Forum to Full Width