我正在尝试将SQL查询转换为Java代码中的转换, 我做了很多尝试,没有人返回wright结果,请求有点复杂,很多连接,这是我的查询;
SELECT *
FROM hom.SOC_PAR_PAR p
LEFT JOIN hom.HISTO inc
ON p.PAR_ID = inc.PAR_ID AND inc.PAR_ETAT='INCLUS'
LEFT JOIN hom.HISTO pre_inc
ON p.PAR_ID =pre_inc.PAR_ID AND pre_inc.PAR_ETAT='PRE_INCLUS'
LEFT JOIN hom.HISTO sort
ON p.PAR_ID = sort.PAR_ID AND sort.PAR_ETAT='SORTI'
LEFT JOIN hom.HISTO cloture
ON p.PAR_ID = cloture.PAR_ID AND cloture.PAR_ETAT='ARCHIVE'
LEFT JOIN hom.INTERV interv
ON (p.PAR_PAT_ID=interv.INT_PATIENT_ID OR p.PAR_ID=interv.INT_PARCOURS_ID)
WHERE (interv.INT_ROLE=(SELECT ROL_ROLE_ID FROM BASECOM.PEC_ROLE_ROL r
WHERE r.ROL_TYPE='MTR')
AND (interv.INT_DATE_FIN is NULL OR interv.INT_DATE_FIN > now()))
AND(p.DATE_HISTO > (SELECT IFNULL(max(date_job),'0000-00-00 00:00:00')
FROM plug.job_state WHERE dest='lg'
AND tdest='PAR')
OR p.DATE_CREATION > (SELECT IFNULL(max(date_job),'0000-00-00 00:00:00')
FROM plug.job_state WHERE dest_name='lg'
AND tdest='PAR'))
GROUP BY p.PAR_ID, p.PAR_PAT_ID
这些是我的数据集:
Dataset<Row> ds_SOC_PAR_PAR;
Dataset<Row> ds_HISTO_inc;
Dataset<Row> ds_HISTO_pre_inc;
Dataset<Row> ds_HISTO_sort;
Dataset<Row> ds_HISTO_cloture;
Dataset<Row> ds_INTERV;
Dataset<Row> ds_PEC_ROLE_ROL;
感谢您的帮助