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

Home -> Community -> Usenet -> c.d.o.server -> Newbie question on SQL Syntax: using data returned from an aggregate function

Newbie question on SQL Syntax: using data returned from an aggregate function

From: <arch>
Date: Tue, 26 Oct 2004 19:45:59 +0800
Message-ID: <417e3657@funnel.arach.net.au>


I'm using Oracle 7 and i'm trying to use data returned from an aggregate function. I've created a query that returns a list of duplicate records
(duplicates based on a few fields, not just one). For each of those
duplicate records, I want to link to another table to get further information about those duplicate records. I've been able to do a query when the aggregate function returns only one field without too much trouble. But what do I do if it returns multiple fields?

Ideally, I want something like this:

SELECT * FROM table2

WHERE (table2.field1, table2.field2, table2.field3) in

(SELECT table1.field1, table1.field2, table1.field3, COUNT(*)

FROM table1

GROUP BY table1.field1, table1.field2, table1.field3

ORDER BY table1.field1, table1.field2, table1.field3

            HAVING COUNT(*) > 1) Unfortunately, this doesn't seem to work. How do I fix this? Received on Tue Oct 26 2004 - 06:45:59 CDT

Original text of this message

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