开发者

Conditional GROUP BY result

I need the query to group by name and, if开发者_高级运维 one of the is_new is 1, the resulting value should be 1.


Current rows:

+--------+--------+
| name   | is_new |
+--------+--------+
| a      |      0 |
| a      |      0 |
+--------+--------+
| b      |      0 |
| b      |      1 |
+--------+--------+
| c      |      1 |
| c      |      1 |
+--------+--------+

Expected query result:

+--------+--------+
| name   | is_new |
+--------+--------+
| a      |      0 |
| b      |      1 |
| c      |      1 |
+--------+--------+


SELECT name,MAX(is_new) AS is_new FROM <TABLE> GROUP BY name
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜