Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 3 of 3

Thread: Any SQL Gurus?

  1. #1
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default Any SQL Gurus?

    I have a problem im trying to solve but its just not hitting me. I have a table, lets says its defined like this.

    Code:
    SOMETABLE
        - OrderNumber
        - CustomerID
        - CreatedDate DATETIME
    I am trying to write a query that will find me all duplicate records for a certain customerid.

    So example data
    Code:
    10100, 58640, 2010-10-26 11:22:27.697
    10200, 58640, 2010-10-26 14:82:27.697
    10300, 58640, 2010-10-26 08:42:27.697
    10400, 58640, 2010-10-28 14:32:27.697
    10500, 58640, 2010-10-26 12:22:27.697
    So the query would return 10100, 10200, 10300, 10500

    The date compare has to be independent of time.

    I just have hit a road block and I know it cant be this hard.

    Anyone have any tips?

  2. #2
    jknauff is offline Member
    Join Date
    Apr 2008
    Posts
    41

    Default re: sql query

    OK here it is


    select a.ordernumber from orders a
    where a.customerid in
    (select b.customerid from
    orders b
    where b.orderdate > '12-dec-2010' and b.orderdate< '10-jan-2011'
    group by b.customerid
    having count ( b.customerid) > 1)

    Let me know if you have any problems
    Jaishree

  3. #3
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default

    Wow, your rock. No clue what I couldnt get that to work! Yours, with a tweak, worked great!

    Thanks soo much!