我怎么能为了通过根据一些布尔逻辑? [英] How can I ORDER BY according to some boolean logic?

查看:140
本文介绍了我怎么能为了通过根据一些布尔逻辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有列'a'和'B'。 A记录被视为准备,如果!一个|| b 。我如何可以通过该就绪状态排序?我与SQL真的生锈,我不记得什么会是这样做的最佳方式。我的猜测是,我将能够通过该列的布尔结果添加一列,然后排序,但我试图寻找和似乎无法找到我要找的。

解决方案

 按情况下订单时!一个||然后B 0,否则,1月底

Say I have columns 'a' and 'b'. A record is deemed 'ready' if !a || b. How can I sort by this ready condition? I'm really rusty with SQL and I can't recall what would have been the best way to do this. My guess is that I would be able to add a column with the boolean result and then sort by that column, but I've tried searching and can't seem to find what I'm looking for.

解决方案

order by case when !a || b then 0 else 1 end

这篇关于我怎么能为了通过根据一些布尔逻辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆