Column summary

  • Hi

    i have a table with 4 columns

    YearMonthProd-Group ProductValue

    2010April Fruit Oranges2

    2010April SweetsCad bury3

    2010AugustToys Doll 5.5

    2011AugustFruit apple1

    2011DecemberFruit pear 2

    2012FebruaryToys car 10

    2012July Sweets choc3.5

    Is it possible for me to get a summary of this for example i want to know from the Prod-Group column which one appears the most

    E.G. i would like my results to be like: Fruit

  • Is this homework? What have you tried so far?

    Here's a hint: use GROUP BY and COUNT(*) in a CTE or subquery to find out how many of each product there are, and then use MAX to find out which one has the most.

    John

  • i am an intern just started sql never touched it in my life now i have to create a report fro the client ... i have done the report i am left with this

  • I don't know... being an intern means that you're supposed to be learning some things from the people you're working for. You should have a mentor that's been assigned to you. I'd ask the mentor to show you. Nothing better than face-to-face training/learning.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 3 (of 3 total)

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