Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Column summary Expand / Collapse
Author
Message
Posted Friday, May 10, 2013 4:14 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, November 11, 2013 3:11 AM
Points: 14, Visits: 30
Hi

i have a table with 4 columns
Year Month Prod-Group Product Value
2010 April Fruit Oranges 2
2010 April Sweets Cad bury 3
2010 August Toys Doll 5.5
2011 August Fruit apple 1
2011 December Fruit pear 2
2012 February Toys car 10
2012 July Sweets choc 3.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

Post #1451506
Posted Friday, May 10, 2013 5:09 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:20 AM
Points: 5,233, Visits: 9,481
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
Post #1451524
Posted Friday, May 10, 2013 7:25 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, November 11, 2013 3:11 AM
Points: 14, Visits: 30
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
Post #1451580
Posted Friday, May 10, 2013 4:43 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 8:06 PM
Points: 36,786, Visits: 31,243
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1451778
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse