Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Problem with simple SQL query part 2
Hi Terry,
this could be slow, but it should do the work.
insert into t_sedol (sedol, market_cap)
select sedol, market_cap
from t_master_download a
where country = 'United Kingdom'
and downloaddate = '01-DEC-92'
and 246 >= (select count(*)
from t_master_download b where b.country = a.country and b.downloaddate = a.downloaddate and b.market_cap >= a.market_cap);
Be careful comparing dates. If your downloaddate has a time other then midnight (00:00:00) the comparasion fails. In this case use the TRUNC command to cut off the time from the date.
HTH
Angelo.
Received on Thu Oct 01 1998 - 00:00:00 CDT