Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!asuvax!noao!stsci!davids From: davids@stsci.EDU (David Silberberg) Newsgroups: comp.databases Subject: How do you do this query? Keywords: SQL, query Message-ID: <940@cirrus.stsci.edu> Date: 19 Nov 89 23:23:44 GMT Organization: Space Telescope Science Institute, Baltimore, MD 21218 Lines: 39 How do you do the following query in SQL? Imagine a table of the following: A B C --------------------- z y 1 z y 2 z y 3 w y 1 w y 2 x p 1 x z 1 x z 2 x z 3 etc. If I did a 'select A, B, C from table where B="y" ', I would get the following: A B C --------------------- z y 1 z y 2 z y 3 w y 1 w y 2 What I really want is a select that would get only the line with the maximum value of C for each unique combination of A, B. It would produce the following: A B C --------------------- z y 3 w y 2 Remember, only SQL standard queries allowed. Thanks in advance. David Silberberg