Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: cursor definition query

Re: cursor definition query

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 2000/07/21
Message-ID: <8lail8$3n7$1@nnrp1.deja.com>#1/1

In article <39789f5f.19486749_at_news.harvard.edu>,   hoke_at_gse.harvard.edu (Ken Ho) wrote:
> If I have a table whose columns are:
>
> customer_ID varchar2(4)
> visit_date date
>
> and each customer has 1 or more visits, how would I select a single
> row for each customer_ID, with the stipulation that I must have the
> row with the most recent visit_date value?
>

SELECT customer_id, max(visit_date)
  from T
group by customer_id
/

--
Thomas Kyte (tkyte_at_us.oracle.com) Oracle Service Industries
Howtos and such: http://osi.oracle.com/~tkyte/index.html
Oracle Magazine: http://www.oracle.com/oramag
Opinions are mine and do not necessarily reflect those of Oracle Corp


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Fri Jul 21 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US