In select query values with space appended takes higher precedence than normal characters

  • In select query values with space appended takes higher precedence than normal characters . How to overcome this . I.e the result is like this as shown below but i want 1001 to come on the top. Since i am using union all cannot use order by.

    Cost Evaluation Sheet

    Decision Gate 1 Complete

    Involvement Complete

    Statement of Work

    1001

  • Why can't you use ORDER BY?

    try this

    declare @items1 table (item varchar(100))

    declare @items2 table (item varchar(100))

    insert into @items1

    select 'Cost Evaluation Sheet'

    union select 'Decision Gate 1 Complete'

    union select 'Involvement Complete'

    union select 'Statement of Work'

    insert into @items2

    select 1001

    select item from @items1

    union all

    select item from @items2

    order by item

    returns

    1001

    Cost Evaluation Sheet

    Decision Gate 1 Complete

    Involvement Complete

    Statement of Work

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

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