示例数据:
event_id, session_id, did_tap_on_screen
1 1 true
2 1 false
3 2 false
4 2 false
期望的结果:
session_id, did_tap_on_screen
1 true
2 false
基本上,我希望按session_id进行分组,如果any为true则返回true,如果全部为假则返回false
这是我写的伪查询:
SELECT
session_id,
did_tap_on_screen -- what should I do here
FROM events
GROUP BY session_id
答案 0 :(得分:1)
如果did_tap_on_screen
是一个字符串,您可以这样做:
select session_id, max(did_tap_on_screen)
from events
group by session_id;
如果它是布尔值(某种类型),则适当的公式取决于数据库。例如,Postgres支持bool_or()
select session_id, bool_or(did_tap_on_screen)
from events
group by session_id;
答案 1 :(得分:0)
以下是确定每import UIKit
class CustomTableViewCell: UITableViewCell, UITextFieldDelegate {
@IBOutlet weak var inputLabel: UILabel!
@IBOutlet weak var inputText: UITextField!
@IBOutlet weak var labelLabel: UILabel!
@IBOutlet weak var labelDetail: UILabel!
@IBOutlet weak var picker: UIPickerView!
@IBOutlet weak var largeInputText: UITextField!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
inputText.delegate = self
}
func textFieldShouldReturn(textField: UITextField) -> Bool {
print("return button in CustomTableViewCell")
inputText.resignFirstResponder()
return true
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
个did_tap_on_screen
是否为真的方法:
session_id