courseId(varchar)
userid(varchar)
type(varchar) --can be update,preview or live
update(date)
preview(date)
live(date)
the courseId is repeated many times and every entry will have only one of the coloumns which has dates and the other two date coloumns will be empty.
Now I want to retrieve the userid,type and the date coloumn based on the type (for ex if the type is update I want to get the greatest of update coloumn) where type= update and update = greatest(update).
I want the latest two live dates and its complete rows and one latest preview dates and its complete row.
So totally i wnat to retrieve 3 rows based on the courseid and type.
it would be very great ful if somebody help me out to come up giving a rope.
thanx
satish
03-05-2002, 10:17 AM
Shestakov
Try this:
select * from TBL
where type='UPDATE' and
ubdate = (select max(update) from tbl)
union
select * from TBL
where type='PREVIEW' and
preview = (select max(preview) from tbl)
union
select * from TBL
where type='LIVE' and
live = (select max(live) from tbl)
;
03-06-2002, 12:07 AM
satishkk
thanx a lot Shestakov
A slight addition to the requirement.
I not only want the latest date but also the second latest date.
can u please help on that.
for getting the latest date we can use max(publishdate) but what should I do for getting the second latest date.
thanx
satish kumar K.
03-06-2002, 02:16 AM
Kumar_RP
query
HI,
Can u please check the result is the your desired result?
1 select * from ( select * from pal_test where t_id = 'Preview' order by p_date desc)
2 where rownum < 3
3 union
4 select * from ( select * from pal_test where t_id = 'Live' order by l_date desc)
5* where rownum < 2
12:44:57 6 /