按键和表达式组合行

时间:2015-02-20 09:22:29

标签: sql postgresql

我有一张桌子

email::string
location::string
day_1::boolean
day_2::boolean
...

现在我需要每天email OR天获得。对于以下输入

user1@gmail.com | location1 | true  | false
user1@gmail.com | location2 | false | true

我想要

user1@gmail.com | true  | true

1 个答案:

答案 0 :(得分:1)

SELECT email, bool_or(day_1) AS day_1, bool_or(day_2) AS day_2 FROM your_table GROUP BY email