Mysql如何在必须找出我的变量是否位于其他两个值之间的情况下创建if语句
我正在尝试创建一个存储过程,如下所示
...Having (IF(input_val between 1 and 10, 1,0) AS 排名
示例
|input_val | rank |
--------------------|
| 1 | 1 |
| 11 | 0 |
| 3 | 1 |
| 22 | 0 |
| 4 | 1 |
| 5 | 1 |
I'm trying to create a stored procedure like followed
...Having (IF(input_val between 1 and 10, 1,0) AS rank
example
|input_val | rank |
--------------------|
| 1 | 1 |
| 11 | 0 |
| 3 | 1 |
| 22 | 0 |
| 4 | 1 |
| 5 | 1 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HAVING 子句通常位于 GROUP BY 子句之后,用于测试聚合函数的结果。我认为这不适合你在这里想要的。怎么样:
A HAVING clause normally follows a GROUP BY clause and is used to test the results of an aggregate function. I don't think that's appropriate for what you want here. How about: