Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL question (sequence of dates into sequnce od date_from-date_to)
Hi LokalST,
I'm hoping you're not a student ...
I'm not saying it's necessarily the best way but the following should be close to getting the output you're after:
SELECT b.object_id, b.type_id, b.date_field date_from, a.date_field date_to
FROM history_change a, history_change b
WHERE a.id(+) = b.id + 1;
Cheers
Richard
"LokalST" <stbest001_at_hotmail.com> wrote in message
news:anerna$l8n$1_at_sunce.iskon.hr...
> I'm on 8i WinXP
> I have a table with some data of history change
(id,object_id,type_id,date)
> and i want to write a query which should produce following columns:
> object_id,type_id,date_from,date_to
>
> Sample data:
> ID OBJECT_ID TYPE_ID DATE
> -----------------------------------------------
> 1 1 2 19.07.2001
> 2 1 5 11.09.2001
> 3 1 8 18.09.2001
> 4 1 51 08.12.2001
>
>
> I want to get folowing output:
>
> OBJECT_ID TYPE_ID DATE_FROM DATE_TO
> -----------------------------------------------------------------
> 1 2 19.07.2001
> 11.09.2001
> 1 5 11.09.2001
> 18.09.2001
> 1 8 18.09.2001
> 08.12.2001
> 1 51 08.12.2001
NULL
>
> I have basic query
> SELECT t.object_id, t.type_id, t.date date_from
> FROM table_name t
> ORDER BY t.date
>
> but don't know how to get date_to.
>
> Any idea?
> Tnx ina advance
>
>
Received on Wed Oct 02 2002 - 09:12:55 CDT
![]() |
![]() |