我写了一个查询来按状态对db中的所有项目进行计数和分组。
现在,我需要计算每个给定结果的百分比。
func removeAllAnnotations() {
guard let document = pdfView.document else { return }
for index in 0..<document.pageCount {
if let page = document.page(at: index) {
let annotations = page.annotations
for annotation in annotations {
page.removeAnnotation(annotation)
}
}
}
}
func searchBar(_ searchBar: UISearchBar,textDidChange searchText: String) {
removeAllAnnotations()
return highlight(searchTerms: [searchText])
}
这给了我
我尝试了以下方法:
SELECT
COUNT(CASE WHEN status='Pending' THEN 1 ELSE NULL END) as 'Pennding Requests',COUNT(CASE WHEN status='accepted' THEN 1 ELSE NULL END) as 'accepted Requests',COUNT(CASE WHEN status='Denied' THEN 1 ELSE NULL END) as 'Denied Requests'
FROM meeting_request;
有人可以建议如何计算这三种状态的百分比。