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 have an OrderDate column and I need to filter it so it only brings up a certain month. and my other problem is I have a column of customers and another column of countries. There are many customers in a certain country. I need to know the total number of customers in each country.thanks for the help
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2010-01-29 : 22:37:04
first problem
where datepart(month, OrderDate) = <required month>
other problem
select country, count(*)from sometablegroup by country
KH[spoiler]Time is always against us[/spoiler]
lakers34kb
Starting Member
15 Posts
Posted - 2010-01-29 : 22:51:01
how do I make the 2nd one sort from the new counting column
lakers34kb
Starting Member
15 Posts
Posted - 2010-01-29 : 23:17:06
I figured it out... thanks for your helpSolution:SELECT Country, count(*)as CountryCount FROM CustomersGROUP BY Country ORDER BY CountryCount Desc