请教一条SQL语句的写法!

lienyao8866 2008-01-23 03:04:00
请教一条sql语句的写法
select * from user
有字段a,b,c,要求优先满足 a>b and c=false 的数据排在前面,剩余的排在后面
...全文
85 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lienyao8866 2008-01-23
  • 打赏
  • 举报
回复
真是能人多啊,菜鸟太感谢了!
free1879 2008-01-23
  • 打赏
  • 举报
回复

SELECT *
FROM user
ORDERY BY CASE WHEN a > b and c = 'false' THEN 0 ELSE 1 END
JL99000 2008-01-23
  • 打赏
  • 举报
回复
请教一条sql语句的写法
select * from user
有字段a,b,c,要求优先满足 a> b and c=false 的数据排在前面,剩余的排在后面

---
select * from [user] order by (case when a> b and c=false then 1 else 0 end)

接分了
wzy_love_sly 2008-01-23
  • 打赏
  • 举报
回复
select   *   from   [user]  
order by case when a> b and c='false' then 0 else 1 end
kk19840210 2008-01-23
  • 打赏
  • 举报
回复
select * from [user] order by case when a>b and c=false then 1 else 0 end desc
kk19840210 2008-01-23
  • 打赏
  • 举报
回复
select * from [user] order by case when a>b and c=false then 1 else 0 end
子陌红尘 2008-01-23
  • 打赏
  • 举报
回复

select
*
from
[user]
order by
(case when (a>b and c=false) then 1 else 2 end) ASC

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧