无法加入桌子

时间:2018-11-22 05:36:48

标签: sql oracle oracle11g

我正在尝试联接两个表,但是有问题。 没有错误弹出,但联接后表的列未显示。 这是我进行的查询,目的是查找日期差,然后将表与另一个表连接起来。

SELECT * FROM 
(Select job_empl_job.*,(job_empl_job.emplj_lastdate -trunc(sysdate)) 
AS 
difference from job_empl_job 
INNER JOIN 
job_city 
ON
job_city.city_id=job_empl_job.emplj_city)
WHERE difference < 16 AND difference > 0

2 个答案:

答案 0 :(得分:3)

您可以在下面尝试

Select job_empl_job.*,trunc(sysdate)-TO_date(job_empl_job.emplj_lastdate, 'dd/mm/yyyy') AS difference 
from job_empl_job INNER JOIN job_city 
ON
job_city.city_id=job_empl_job.emplj_city
WHERE trunc(sysdate)-TO_date(job_empl_job.emplj_lastdate, 'dd/mm/yyyy')> 0  and trunc(sysdate)-TO_date(job_empl_job.emplj_lastdate, 'dd/mm/yyyy') < 16 

答案 1 :(得分:1)

尝试这个:

SELECT * FROM 
(
SELECT   a.* , b.* , 
(SELECT trunc(EMPLJ_LASTDATE - sysdate ) from dual )as days 
FROM 
job_empl_job a  
INNER JOIN 
JOB_CITY b 
ON 
a.EMPLJ_CITY=b.CITY_ID 
)
WHERE
days < 16 and days > 0