アクティブな参加者の最新のメモを教えてくれるクエリを実行しています。
select notes.applicant_id,
reg.program_code,
reg.last_name,
reg.first_name,
reg.status_cd,
MAX(notes.service_date) as "Last Note"
from reg inner join notes on reg.applicant_id=notes.applicant_id
where reg.status_cd='AC'
group by notes.applicant_id, reg.program_code,
reg.last_name, reg.first_name, reg.reg_date,
reg.region_code, reg.status_cd
order by MAX(notes.service_date)
note.service_date
しかし、このクエリで最大値の直前の結果も取得したいと思いますservice_date
。
結果は次のようになります
notes.applicant_id reg.last_name reg.first_name reg.status_cd Last Note Prior Note
12345 Johnson Lori AC 01-NOV-2011 01-OCT-2011
私はオラクルで働いています。