Multiple Orders

  • I need to find out customers having more than one order for the same product

     

    Xyz table

     ---------

    Customer_Id

    Order_ID

    Prodcut_ID

    Abc

    Mnr

     

    I can get information like

     

    Select customer_Id,Product_Id, Count(Customer_ID) Cnt from Xyz

    Group By customer_Id,Product_Id having Count(Customer_ID) >= 2

    Order By Customer_Id

     

    But I want to include rest of the columns and I don’t want to use any temp tables either.

    Shas3

  • Got it

    Select * from Xyz where Customer_Id in (Select Customer_Id

    from Xyz

    Group by Customer_ID,Product_ID

    having  Count(Customer_ID) >= 2 )

     

    Shas3

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply