Now that my confusion is cleared up

  • I created a table called tabText with two columns and nametext as primary key:

    Nametext varchar(10)

    numbercol int

    with this data

    nametextnumbercol

    eight 8

    five 5

    four 4

    nine 9

    one 1

    seven 7

    six 6

    ten 10

    three 3

    two 2

    I then ran four similar queries from the question

    SELECT TOP 5 nametext

    FROM tabText ORDER BY numbercol DESC

    GO

    SELECT TOP 5 PERCENT nametext

    FROM tabText ORDER BY numbercol DESC

    GO

    SELECT BOTTOM 5 PERCENT nametext

    FROM tabText ORDER BY numbercol

    GO

    SELECT BOTTOM 5 nametext

    FROM tabText ORDER BY numbercol

    GO

    The last two failed

    Server: Msg 170, Level 15, State 1, Line 2

    Line 2: Incorrect syntax near '5'.

    Server: Msg 170, Level 15, State 1, Line 2

    Line 2: Incorrect syntax near '5'.

    The second one produced the following results

    ten

    The first one produced the results that seem to answer the problem

    ten

    nine

    eight

    seven

    six

    Comments?

  • But the question was to pick 5 PERCENT. Your query returned 50 percent.

    -SQLBill

  • Thanks for straighting me out, perhaps too much holiday cheer.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply