select a.click_date createTime,
ifnull(b.bloodOxygenDetectionResult,0) as bloodOxygenDetectionResult,
ifnull(b.alcoholDetectionResult,0) as alcoholDetectionResult,
ifnull(b.bloodPressureDetectionResult,0) as bloodPressureDetectionResult
from (
SELECT curdate() as click_date
union all
SELECT date_sub(curdate(), interval 1 day) as click_date
union all
SELECT date_sub(curdate(), interval 2 day) as click_date
union all
SELECT date_sub(curdate(), interval 3 day) as click_date
union all
SELECT date_sub(curdate(), interval 4 day) as click_date
union all
SELECT date_sub(curdate(), interval 5 day) as click_date
union all
SELECT date_sub(curdate(), interval 6 day) as click_date
) a left join (
SELECT
u.nick_name nickName, u.job_number jobNumber, u.cardkey,u.health,u.sex,u.user_id userId,DATE_FORMAT(u.create_time,"%Y-%m-%d") as createtimes,
u.alcohol_detection_result alcoholDetectionResult,u.phonenumber,
u.blood_pressure_detection_result bloodPressureDetectionResult,
u.blood_oxygen_detection_result bloodOxygenDetectionResult,
u.temperature,d.dept_name deptName, r.role_name roleName,
p.download_path downloadPath
from sys_user_index u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
LEFT JOIN sys_user_photo p ON u.job_number=p.job_number
where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(u.create_time) and u.user_id ='2611' and u.del_flag = '0'
) b on a.click_date = b.createtimes
ORDER BY a.click_date desc;
近七日数据,没有数据的默认展示0
最新推荐文章于 2024-10-15 13:49:16 发布