Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    76

    Unhappy Unanswered: selecting rows with duplicate values/columns

    Hi ,
    I have a cursor c_cursor which selects ORDER, SKU and QTY and outputs the following values. Now I want to pick out records which have more than 1 instance of the same SKU. I.e. 'xxx'. I want to do this because I want to check for the QTY of 2 and 3 against a storedqty of 4. if 2+3 > 4 than I only want the aa record to be processed.
    I cant say select * where sku ='xxx' because I wont know what the cursor pulls out. I am looking for some way of saying
    select * where the same sku occurs more than once. How can I do this?Help,

    ORDER SKU QTY
    aa xxx 2
    ab xxx 3
    ac sss 1
    ad yyy 1
    ae axa 3

  2. #2
    Join Date
    Apr 2002
    Posts
    56
    select sku,count(1)
    from <table_name>
    group by sku
    having count(1) > 1

    it wil, give you all sku's that occur more than once.

  3. #3
    Join Date
    Nov 2003
    Posts
    76

    thank you

    Originally posted by edwin
    select sku,count(1)
    from <table_name>
    group by sku
    having count(1) > 1

    it wil, give you all sku's that occur more than once.

Posting Permissions

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