我有這樣的查詢:查詢:SELECT *回報數據,但是選擇列沒有返回結果
select pln.*
from plan pln
where pln.id = '0003'
and pln.seq = (select max(pln_es.seq)
from plan pln_es
where pln_es.id = pln.emplid
and pln_es.career =pln.career
and pln_es.nbr = pln.nbr
and pln_es.dt = pln.dt)
但是,如果我(選擇列...),使用相同的條件下,它不會返回數據!對我沒有意義。
這裏的查詢不返回結果:
select pln.MYDATE
from plan pln
where pln.id = '0003'
and pln.seq = (select max(pln_es.seq)
from plan pln_es
where pln_es.id = pln.emplid
and pln_es.career =pln.career
and pln_es.nbr = pln.nbr
and pln_es.dt = pln.dt)
有誰知道爲什麼會這樣happenning?列本身是一個日期,而DB是Oracle 10g中
請發送替代查詢。 – markus 2009-10-19 19:11:06
你的意思是沒有數據返回零行嗎?而選擇*返回> 0行? – ongle 2009-10-19 19:24:23
目標是使用同一個表中的最大日期值? – 2009-10-19 19:35:55