首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用复杂case-when语句的SQL查询

使用复杂case-when语句的SQL查询
EN

Stack Overflow用户
提问于 2017-06-14 15:13:25
回答 0查看 1.6K关注 0票数 0

我有一个具有以下模式的表

代码语言:javascript
复制
id  data  rank  usage
 1  hi     19    H
 2  he     14    M
 3  me      9    L
 4  ke     23    H
 5  jo     11    M
 6  km      2    L
 7  lo      4    L
 8  no     12    M
 9  my     20    H

我想做一些像这样的事情

If max(rank) where usage='L'>=25 Then Select all records where usage='H' Else If max(rank) where usage='M'>=25 Select all records where usage='L' and records where usage='M' ELSE Select all records

SQL不支持以下语句:

SELECT CASE WHEN (select max(rank) from my_table where usage='L') >= 100

那么,我应该如何编写这个查询呢?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44537909

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档