mysql的關聯查詢求和?
參考sql語句
select
sum(casewhena1=1then1else0end)asa1count,
sum(casewhena2=1then1else0end)asa2count,
sum(casewhena3=1then1else0end)asa3count,
sum(casewhena4=1then1else0end)asa4count
from表
參考sql語句
select
sum(casewhena1=1then1else0end)asa1count,
sum(casewhena2=1then1else0end)asa2count,
sum(casewhena3=1then1else0end)asa3count,
sum(casewhena4=1then1else0end)asa4count
from表