jmoran18251
asked on
Group By and Order By
I am fairly new to SQL and seem to be stuck... I would greatly appreciate any help. I am trying to write an SQL statement that will tell me what text appears most often in my data. For example, if I have
Ice Cream
Cookie
Cake
Ice Cream
Muffin
I would like to get 'Ice Cream'
Here's what I have come up with...
"SELECT CC as Complaint, COUNT(CC) AS Total from Data WHERE XYZ GROUP BY CC", which returns
Cake 1
Cookie 1
Ice Cream 2
Muffin 1
I was thinking if I could at least order the 'Total' column I could just always grab the top result, but I cannot seem to get the 'Order By' function to work with the field. Any idea how to make this work or another way to get the result I am looking for? Thanks!
Ice Cream
Cookie
Cake
Ice Cream
Muffin
I would like to get 'Ice Cream'
Here's what I have come up with...
"SELECT CC as Complaint, COUNT(CC) AS Total from Data WHERE XYZ GROUP BY CC", which returns
Cake 1
Cookie 1
Ice Cream 2
Muffin 1
I was thinking if I could at least order the 'Total' column I could just always grab the top result, but I cannot seem to get the 'Order By' function to work with the field. Any idea how to make this work or another way to get the result I am looking for? Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I figured I had to be in the ballpark, but I just couldn't quite get there. Thank you! That was killing me!
Open in new window