エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
記事へのコメント1件
- 注目コメント
- 新着コメント
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
【SQL】複数の条件のcountを1回のクエリでおこなう - Qiita
select count(status = 0 or null), --statusが0の件数 count(status in(1,2) or null) --statusが1か2... select count(status = 0 or null), --statusが0の件数 count(status in(1,2) or null) --statusが1か2の件数 from hoge これでできてしまう。すごい! 解説 count()は全件、count(以外)はnull以外をcountする。 ゆえに条件に合致するものをtrue,合致しないものをnullで返す。 true or null ->true -> countされる。 false or null ->null -> countされない。 ゆえに、count(条件 or null)で条件でcountできる。 Register as a new user and use Qiita more conveniently You get articles that match your needsYou can ef
2018/07/01 リンク