I want to sort product by discount on certain condition
ORDER BY
CASE WHEN @OrderBy = 0
THEN table.id END ASC,
CASE WHEN @Orderby = 2
THEN tabl
It seems to me you need something similar to this
select * from TableName where someCondition >100
order by
case when @OrderBy = 'AirlineService'
then AirlineService END desc,
case when @OrderBy = 'SomeMore'
then MyOtherColumn end
GO
If you not have a coulmn then you can not sort with that. Please read this Microsoft Link Please keep in mind - specifies the sort order used on columns returned in a SELECT statement. Hope it helps.