• raghuldrag (12/27/2013)


    Dear Friends,

    my table looks like

    Actual Table looks

    Custmoer NOproduct name billed date

    50 Biscuit 1/4/2013

    50 Milk 10/4/2013

    50 Milk 11/4/2013

    50 Curd 15/4/2013

    50 Biscuit 14/4/2013

    50 Milk 16/4/2013

    50 Curd 21/4/2013

    50 Biscuit 19/4/2013

    50 Curd 26/4/2013

    50 Milk 28/4/2013

    50 Biscuit 30/4/2013

    40 Biscuit 1/4/2013

    40 Milk 10/4/2013

    40 Milk 11/4/2013

    40 Curd 15/4/2013

    40 Biscuit 14/4/2013

    40 Milk 6/4/2013

    40 Curd 21/4/2013

    Expecting Output

    Custmoer NOproduct name billed date

    50 Biscuit 5

    50 Milk 4

    50 curd 3

    40 Biscuit 2

    40 Milk 3

    40 curd 2

    the actual table is refers the product billed for month of customer .....

    now my expecting output is

    How many products i billed for each customer wise ?

    I'm not sure if I'm understanding your requirements clearly. If you want the customer number and the number of times they were billed, this should do it:

    select customer, count(*)

    from table_name

    group by customer;

    If you instead want the customer number and product and the number of times they were billed, try this:

    select customer, product, count(*)

    from table_name

    group by customer;

    If you want something different, please post DDL to create the table, code to populate some sample data and your expected output. See the second link in my signature for advice on how to ask questions for the best results.