Oracle数据库横向查询数据

横向查询数据,并进行显示
-------专家排版查询
select dv.st_dv_dexpertsVisits dexpertsVisits,
MAX(CASE dv.st_dv_dweek WHEN '星期一' THEN dc.ST_DO_Dname ELSE '' END) oneName,
MAX(CASE dv.st_dv_dweek WHEN '星期二' THEN dc.ST_DO_Dname ELSE '' END) twoName,
MAX(CASE dv.st_dv_dweek WHEN '星期三' THEN dc.ST_DO_Dname ELSE '' END) threeName,
MAX(CASE dv.st_dv_dweek WHEN '星期四' THEN dc.ST_DO_Dname ELSE '' END) fourName,
MAX(CASE dv.st_dv_dweek WHEN '星期五' THEN dc.ST_DO_Dname ELSE '' END) fiveName,
MAX(CASE dv.st_dv_dweek WHEN '星期六' THEN dc.ST_DO_Dname ELSE '' END) sixName,
MAX(CASE dv.st_dv_dweek WHEN '星期日' THEN dc.ST_DO_Dname ELSE '' END) sevenName,
MAX(CASE dv.st_dv_dweek WHEN '星期一' THEN dc.st_do_dprofessional ELSE '' END) oneExpertsTitles,
MAX(CASE dv.st_dv_dweek WHEN '星期二' THEN dc.st_do_dprofessional ELSE '' END) twoExpertsTitles,
MAX(CASE dv.st_dv_dweek WHEN '星期三' THEN dc.st_do_dprofessional ELSE '' END) threeExpertsTitles,
MAX(CASE dv.st_dv_dweek WHEN '星期四' THEN dc.st_do_dprofessional ELSE '' END) fourExpertsTitles,
MAX(CASE dv.st_dv_dweek WHEN '星期五' THEN dc.st_do_dprofessional ELSE '' END) fiveExpertsTitles,
MAX(CASE dv.st_dv_dweek WHEN '星期六' THEN dc.st_do_dprofessional ELSE '' END) sixExpertsTitles,
MAX(CASE dv.st_dv_dweek WHEN '星期日' THEN dc.st_do_dprofessional ELSE '' END) sevenExpertsTitles,
MAX(CASE dv.st_dv_dweek WHEN '星期一' THEN r.st_at_name ELSE '' END) oneRoomName,
MAX(CASE dv.st_dv_dweek WHEN '星期二' THEN r.st_at_name ELSE '' END) twoRoomName,
MAX(CASE dv.st_dv_dweek WHEN '星期三' THEN r.st_at_name ELSE '' END) threeRoomName,
MAX(CASE dv.st_dv_dweek WHEN '星期四' THEN r.st_at_name ELSE '' END) fourRoomName,
MAX(CASE dv.st_dv_dweek WHEN '星期五' THEN r.st_at_name ELSE '' END) fiveRoomName,
MAX(CASE dv.st_dv_dweek WHEN '星期六' THEN r.st_at_name ELSE '' END) sixRoomName,
MAX(CASE dv.st_dv_dweek WHEN '星期日' THEN r.st_at_name ELSE '' END) sevenRoomName,
MAX(CASE dv.st_dv_dweek WHEN '星期一' THEN dv.st_dv_id ELSE 0 END) oneSchedulingId,
MAX(CASE dv.st_dv_dweek WHEN '星期二' THEN dv.st_dv_id ELSE 0 END) twoSchedulingId,
MAX(CASE dv.st_dv_dweek WHEN '星期三' THEN dv.st_dv_id ELSE 0 END) threeSchedulingId,
MAX(CASE dv.st_dv_dweek WHEN '星期四' THEN dv.st_dv_id ELSE 0 END) fourSchedulingId,
MAX(CASE dv.st_dv_dweek WHEN '星期五' THEN dv.st_dv_id ELSE 0 END) fiveSchedulingId,
MAX(CASE dv.st_dv_dweek WHEN '星期六' THEN dv.st_dv_id ELSE 0 END) sixSchedulingId,
MAX(CASE dv.st_dv_dweek WHEN '星期日' THEN dv.st_dv_id ELSE 0 END) sevenSchedulingId,
MAX(CASE dv.st_dv_dweek WHEN '星期一' THEN dv.st_dv_ddid ELSE 0 END) oneId,
MAX(CASE dv.st_dv_dweek WHEN '星期二' THEN dv.st_dv_ddid ELSE 0 END) twoId,
MAX(CASE dv.st_dv_dweek WHEN '星期三' THEN dv.st_dv_ddid ELSE 0 END) threeId,
MAX(CASE dv.st_dv_dweek WHEN '星期四' THEN dv.st_dv_ddid ELSE 0 END) fourId,
MAX(CASE dv.st_dv_dweek WHEN '星期五' THEN dv.st_dv_ddid ELSE 0 END) fiveId,
MAX(CASE dv.st_dv_dweek WHEN '星期六' THEN dv.st_dv_ddid ELSE 0 END) sixId,
MAX(CASE dv.st_dv_dweek WHEN '星期日' THEN dv.st_dv_ddid ELSE 0 END) sevenId
FROM ST_DV_DOCTORVISITS dv,ST_DO_DOCTOR dc,ST_AT_ROOM r
WHERE dv.st_dv_ddid=dc.st_do_did AND dv.st_dv_drid=r.st_at_id 
AND dv.st_dv_dvisitDate in ( to_date('2018-02-26','YYYY-MM-SS HH24:MI'), to_date('2018-03-04','YYYY-MM-SS HH24:MI'))
 GROUP BY dv.st_dv_dmark, dv.st_dv_dexpertsVisits
 ORDER BY dv.st_dv_dmark

你可能感兴趣的:(java)