Avatar of kenuk110
kenuk110
 asked on

Retrieving Results based on distinct and grouped

Hi,

I have a table with data that is broken down as follows:

countryCode, cityCode, storeCode, storeType, gridCodeX

I need to get a result, distinct, from this table so it totals up how many distinct gridCodeX's there are in a store within a city within a country

I have tried the following in around 100 itterations but to no avail!

Any help would be much appreciated.

Regards,

Ken




select distinct countrycode,citycode,storecode,count(gridcodex) from block 
group by countrycode,citycode,storecode, gridCodeX

Open in new window

Microsoft SQL Server 2008

Avatar of undefined
Last Comment
kenuk110

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Eyal

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
kenuk110

ASKER
Perfect, looks so simple when you see the answer yet seems impossible when you don't.

Really appreciate you help.

Your help has saved me hundreds of hours of internet surfing.
fblack61