Results 1 to 6 of 6

Thread: advanced SQL queries - not for the faint-of-heart

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    88
    earlier, i was trying to write a sql statement that would not copy duplicate values into a recordset. i found that you could do this using the DISTINCT keyword (fellow vb-world member, jlopez deserves some credit here). now i want to be able to identify those records that are duplicates and use them as part of an error log. but how do i capture them? are there any sql gurus out there? SQL for Dummies doesn't seem to be cutting it.

    [Edited by dwhawley on 08-02-2000 at 04:36 PM]

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    What's the table name and the fields that make a unique key?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    88
    the table is tblEquipment
    the fields are as follows:
    ControlNo (this is assigned by the user)
    Mfg (manufacturer)
    ModelNo (model number)
    SerialNo (serial number)

    jhausmann, if you can get this one for me, the cyber-beers are on me.



  4. #4
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    If you are using Access, you can do something like this:

    SELECT DISTINCTROW FIRST(ControlNo) AS FirstControlNo, COUNT(ControlNo) AS NumberOfDups
    FROM tblEquipment
    GROUP BY ControlNo HAVING COUNT(ControlNo) > 1;
    "It's cold gin time again ..."

    Check out my website here.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    88
    bruceg! you win the prize! a cyber-beer on me! thanks a lot for you help. as you can tell from babblings, i have been working on this one for a while and i really needed a resolution. you wouldn't happen to have a good sql reference would you? nothing in my "SQL for Dummies" book would give me anything close to this.

  6. #6
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    That's what I get for taking a day off...no beer (virtual or otherwise)

    [Edited by JHausmann on 08-04-2000 at 01:49 PM]

Posting Permissions

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



Click Here to Expand Forum to Full Width