附加的查询不会为每个年份的日期返回零值,如何返回零值,预期结果:
而不是
答案 0 :(得分:0)
您好Mostafa,您可以使用以下查询,
SELECT Yearweek(`date`) AS yweek_m,
Week( `date` ) AS weekperiod_m,
Count(id_xx) AS cnt_m
FROM measurementview MV
LEFT OUTER JOIN woundview WV
ON MV.wound_id_wound = WV.id_wound
LEFT OUTER JOIN activepatientview AV
ON WV.patient_id_patient = AV.id_patient
WHERE
MV.Yearweek( `date` ) >= MV.Yearweek(NOW()) - 3
AND WV.user_id_user = 4
AND AV.clinic_id_clinic = 3
GROUP BY yweek_m, weekperiod_m
ORDER BY yweek_m DESC