我有一个像这样的mysql数据库:
PropertyBase<A>
我知道如何获得1月,2月的总和......
ID | date | value
1 | 2017-02-20 | 200
2 | 2017-02-17 | 400
3 | 2017-02-15 | 630
4 | 2017-01-28 | 110
5 | 2017-01-29 | 220
但现在我需要一个代码来获得1月和2月的平均值。
我试过
SELECT SUM(value) AS wert
FROM table
WHERE YEAR(date) = YEAR(CURRENT_DATE - INTERVAL 2 MONTH)
AND MONTH(date) = MONTH(CURRENT_DATE - INTERVAL 2 MONTH)
但这不起作用。
感谢您的帮助!
答案 0 :(得分:0)
override func viewDidLoad() {
super.viewDidLoad()
FirstName.delegate = self
LastName.delegate = self
FirstName.addTarget(self, action:"edited", for:UIControlEvents.allEditingEvents)
LastName.addTarget(self, action:"edited", for:UIControlEvents.allEditingEvents)
// Do any additional setup after loading the view.
if FirstName.text?.isEmpty == true || LastName.text == "" {
ProgressButton.setImage(UIImage(named: "Skip"), for: .normal)
ProgressButton.contentEdgeInsets = UIEdgeInsetsMake(0,0,0,0)
ProgressButton.addTarget(self, action: #selector(Skip(_sender:)), for: UIControlEvents.touchUpInside)
} else {
ProgressButton.setImage(UIImage(named: "Right2"), for: .normal)
ProgressButton.contentEdgeInsets = UIEdgeInsetsMake(20,31,24,0)
ProgressButton.addTarget(self, action: #selector(Continue(_sender:)), for: UIControlEvents.touchUpInside)
}
}
func edited() {
if FirstName.text?.isEmpty == true || LastName.text == "" {
ProgressButton.setImage(UIImage(named: "Skip"), for: .normal)
ProgressButton.contentEdgeInsets = UIEdgeInsetsMake(0,0,0,0)
ProgressButton.addTarget(self, action: #selector(Skip(_sender:)), for: UIControlEvents.touchUpInside)
} else {
ProgressButton.setImage(UIImage(named: "Right2"), for: .normal)
ProgressButton.contentEdgeInsets = UIEdgeInsetsMake(20,31,24,0)
ProgressButton.addTarget(self, action: #selector(Continue(_sender:)), for: UIControlEvents.touchUpInside)
}
}
func Continue(_sender: ABProgressButton!) {
FirstName.resignFirstResponder()
LastName.resignFirstResponder()
// Delay the dismissal by 5 seconds
let delay = 0.85 * Double(NSEC_PER_SEC)
var time = DispatchTime.now() + Double(Int64(delay)) / Double(NSEC_PER_SEC)
DispatchQueue.main.asyncAfter(deadline: time, execute: {
self.performSegue(withIdentifier: "ToViewController#2", sender: nil)
})
}
func Skip(_sender: ABProgressButton!) {
FirstName.resignFirstResponder()
LastName.resignFirstResponder()
self.performSegue(withIdentifier: "ToViewController#2", sender: nil)
}