home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases
- Path: sparky!uunet!ukma!darwin.sura.net!sgiblab!munnari.oz.au!metro!usage!s9100786
- From: s9100786@cumulus.csd.unsw.oz.au (Matthew Jackson)
- Subject: SQL Question
- Message-ID: <1993Jan27.214645.12939@usage.csd.unsw.OZ.AU>
- Sender: news@usage.csd.unsw.OZ.AU
- Nntp-Posting-Host: aix00.csd.unsw.oz.au
- Reply-To: M.Jackson@unsw.edu.au
- Organization: School of Banking and Finance, University of New South Wales
- X-Newsreader: TIN [version 1.1 PL8]
- Date: Wed, 27 Jan 1993 21:46:45 GMT
- Lines: 35
-
- Is it possible to do the following in SQL ? I can't seem to get the
- correct code.
-
- 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
-
- ie say I am looking for a code of "xyz", I want to see all those
- identifiers which have that code but only the greatest year.
-
- The problem is that each identifier may end at a different year
-
- I tried
-
- select identifier, max(year), code, value
- from tablename
- where code = "xyz"
- group by identifier;
-
- but this gives the maximum year of all identifiers not the individual
- maxima.
-
- Any advice would be appreciated.
-
- Thanks,
-
- --
- Matthew Jackson | Computing Officer
- M.Jackson@unsw.edu.au | School of Banking and Finance
- 61-2-697-3553 | University of New South Wales
- | Sydney, Australia
-
- Olympics for Sydney in 2000
-