Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I'm a C# asp.net guy. (not as smart as you SQL people)Can someone help me with a query that would allow me to generate this?Total Sales Orders - 6 * Nike - 4 * Adidas - 3 * Fruit of the Loom - 5If I can get the data, even in aliases, I can grab it and mark it up.Thanks for reading all those SQL books for me :>Robert
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-10-26 : 01:03:41
assuming the field containing Nike.Adidas,... is called Brand, it will be like below
SELECT Brand,TotalCountFROM(SELECT 'Total' AS Brand,COUNT(*) AS TotalCount,0 AS OrderValFROM YourTableUNION ALLSELECT Brand,COUNT(*) AS TotalCount,1FROM YourTableGROUP BY Brand)tOrder BY OrderVal
rvignato
Starting Member
2 Posts
Posted - 2008-10-27 : 16:42:55
Thanks!
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2008-10-27 : 17:55:06
What happened to WITH ROLLUP?E 12°55'05.63"N 56°04'39.26"