根据不同的条件进行升序或降序排列(order by )
当@status为2时
我需要对 createDate 字段进行升序排序
当@status为3时
我需要对 createDate 字段进行降序排序
select *from 表名 aorder by (case when @status=2 then createdate when @status=3 then GETDATE()-createdate end)
发布时间: 2012-07-26 12:01:08 作者: rapoo
根据不同的条件进行升序或降序排列(order by )
当@status为2时
我需要对 createDate 字段进行升序排序
当@status为3时
我需要对 createDate 字段进行降序排序
select *from 表名 aorder by (case when @status=2 then createdate when @status=3 then GETDATE()-createdate end)