Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Returning The Closest Single Value
"Niall Litchfield" <n-litchfield_at_audit-commission.gov.uk> wrote in message
news:3dae73fb$0$8507$ed9e5944_at_reading.news.pipex.net...
> "Barry Warner" <bwarner_at_blueyonder.co.uk> wrote in message
> news:K3ur9.29254$jR.14136_at_news-binary.blueyonder.co.uk...
> > Hi
> >
> > I need to compare the system date with the first available date in
> > workshop_start_date column. How do I only return the closest date?
>
> select min(abs(sysdate-workshop_start_date)) from .... where....;
>
> HTH
but of course that doesn't help much as it only gives the interval not the
closest date.
select workshop_start_date from ....
where abs(sysdate-workshop_start_date) =
min(abs(sysdate-workshop_start_date))
might work rather better,NB all those functions might slow down performance somewhat on a very large table.
-- Niall Litchfield Oracle DBA Audit Commission UK ***************************************** Please include version and platform and SQL where applicable It makes life easier and increases the likelihood of a good answer ******************************************Received on Thu Oct 17 2002 - 03:29:59 CDT