Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!indetech!rec From: rec@indetech.com (Rick Cobb) Newsgroups: comp.databases Subject: Re: How do you do this query? Keywords: SQL, query Message-ID: <1989Nov20.190046.12833@indetech.com> Date: 20 Nov 89 19:00:46 GMT References: <940@cirrus.stsci.edu> Reply-To: rec@indetech.UUCP (Rick Cobb) Organization: Independence Technologies, Inc. Fremont, CA Lines: 51 You use the ``group by'' construct. Like so, using ORACLE version 6.0: SQL> describe abc ; /* describe is an ORACLE feature which tells you about a table or view */ Name Null? Type ------------------------------- -------- ---- A CHAR(1) B CHAR(1) C NUMBER SQL> select * from abc ; A B C - - ---------- z y 2 z y 3 w y 1 w y 2 x p 1 x z 1 x z 2 x z 3 8 records selected. SQL> select a, b, max(c) from abc group by a, b ; A B MAX(C) - - ---------- w y 2 x p 1 x z 3 z y 3 SQL> select a, b, max(c) from abc where b = 'y' group by a, b ; A B MAX(C) - - ---------- w y 2 z y 3 SQL> -- ____*_ Rick Cobb rcobb@indetech.uucp, sun!indetech!rcobb \ / / Independence Technologies An opinion is as a drop of rain. \/ / 42705 Lawrence Place That this drop fell does not mean \/ Fremont, CA 94538 my employers are all wet.