Select WhsCode,ItemCode,LotNumber,ExpDate,Qty
from rq_Test2
order by case when qty < 0 then Qty else ExpDate end
case Qty(numeric value) Expdate(datetime)
case result_expression result_expression.
Datetime , numeric or int or Bigint etc.. , .
SQL Server precedence :
user-defined data types (highest)
sql_varian t
xml
datetimeoffset
datetime2
datetime
smalldatetime
date
time
float
real
decimal
money
smallmoney
bigint
int
smallint
tinyint
bit
ntext
text
image
timestamp
uniqueidentifier
nvarchar (including nvarchar(max) )
nchar
varchar (including varchar(max) )
char
varbinary (including varbinary(max) )
binary (lowest)