Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2006
    Posts
    46

    Unanswered: HELP WITH FINDING DUPLICATES AND USING A Group By Clause

    Why does the GROUP BY CLAUSE below make my query not to work.
    Will the following code below work with the GROUP BY CLAUSE?


    SELECT D1.ID, D1.BEGPSN AS NEWBEGPSN, D1.DOCTYPE, D1.docsum, COUNT(D1.BEGPSN)
    FROM DUPLICATES AS D1
    GROUP BY D1.BEGPSN
    WHERE EXISTS (Select * From Duplicates D2
    where D1.BEGPSN = D2.BEGPSN and d1.ID <> d2.ID)
    ORDER BY D1.BEGPSN;

  2. #2
    Join Date
    Jan 2004
    Posts
    492
    Because the group by clause always needs to go after the where.
    Oracle OCPI (Certified Practicing Idiot)

  3. #3
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Quote Originally Posted by ss659
    Because the group by clause always needs to go after the where.
    and before the order or having clause.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  4. #4
    Join Date
    Dec 2003
    Posts
    1,074
    and note that the WHERE clause will be implemented BEFORE the GROUP BY clause bundles up your data. And, you must list every non-aggregate field from your SELECT clause in your GROUP BY clause.

    -Chuck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •