find how many customers order per item

Discussion in 'MySQL' started by aayybb, Dec 3, 2009.

  1. #1
    Hi,

    I have a table ORDER_PRODUCT with fields ORDER_ID, PRODUCT_ID, PRODUCT_QUANTITY, PRODUCT_PRICE... and a table ORDER with fields ORDER_ID, CUSTOMER_ID...

    How do I write the mysql to show how many customers order each product and how many each item were sold? (Same customer can order the same item as many times as they want just like we can go to store to buy the same bread every week. So same customer will count 1.)

    Thanks for any help in advance.
     
    aayybb, Dec 3, 2009 IP
  2. iama_gamer

    iama_gamer Active Member

    Messages:
    404
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    you can use distinct() to choose only distinct customers. And count() will give the number of rows. If you send me the actual structure with dump data ill give u the actual queries
     
    iama_gamer, Dec 3, 2009 IP
  3. aayybb

    aayybb Peon

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Got it. Thanks.
     
    aayybb, Dec 3, 2009 IP