• dwain.c (10/31/2012)


    28.kanikasoni (10/31/2012)


    Hi,

    Thanks 4 ur solution but I am getting error in order clause

    Incorrect syntax near the keyword 'order'.

    Incorrect syntax near the keyword 'ELSE'.

    Incorrect syntax near the keyword 'ELSE'.

    Try removing the parentheses around the CASE statement in the ORDER BY clause.

    Actually, I think the problem might be that I used the reserved word 'Order' as column alias. Try this:

    select distinct VacancyInternalID

    ,VacancyTitle

    ,null ParentInternalID

    ,null GeoLocation

    ,

    OrderBy = (

    case @SortFieldIndexConfig

    when 2

    then VacancyTitle

    else VacancyInternalID

    end

    )

    from Vacancy.TB_Vacancy va

    inner join Config.TB_Contract co on va.VacancyContractID = co.ContractInternalID

    where co.ContractExternalID = '492A94D0-7D71-46E5-A8F6-E3A973394647'

    and co.ContractStatusID = 1

    and VacancyStatusID = 1

    and VacancyTitle like '%%'

    order by (

    case @SortFieldIndexConfig

    when 2

    then VacancyTitle

    else VacancyInternalID

    end

    ) desc

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.