home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases
- Path: sparky!uunet!sangam!cmie!rs
- From: rs@cmie.cmie.ernet.in (Rajappa Iyer)
- Subject: Re: SQL Question
- In-Reply-To: s9100786@cumulus.csd.unsw.oz.au's message of Wed, 27 Jan 1993 21:46:45 GMT
- Message-ID: <RS.93Jan28135822@cmie.cmie.ernet.in>
- Sender: rs@cmie.ernet.in (Rajappa Iyer)
- Organization: Centre for Monitoring Indian Economy
- References: <1993Jan27.214645.12939@usage.csd.unsw.OZ.AU>
- Date: Thu, 28 Jan 1993 08:58:22 GMT
- Lines: 22
-
- In article <1993Jan27.214645.12939@usage.csd.unsw.OZ.AU> s9100786@cumulus.csd.unsw.oz.au (Matthew Jackson) writes:
-
- > I have a table which contains some data which looks like this
- > identifier year code value
- >
- > I want to pick out the row with the latest year for each identifier for
- > a given code
-
- I will use "identifier" as the key. If this is incorrect you will have
- to change the condition in the nested query.
-
- SELECT identifier, year, code, value
- FROM tablename t1
- WHERE t1.code = "xyz" AND t1.year =
- (SELECT max(year) FROM tablename t2 WHERE t1.identifier = t2.identifier)
-
- --
- Rajappa Iyer rs@cmie.ernet.in (Preferred)
- riyer@shakti.ncst.ernet.in
- --
- Rajappa Iyer rs@cmie.ernet.in (Preferred)
- riyer@shakti.ncst.ernet.in
-