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.
Author |
Topic |
madhan
Yak Posting Veteran
59 Posts |
Posted - 2014-11-26 : 13:27:36
|
I am trying to understand group by concept using below query problem. write a query that displays the count of orders placed by year for each customer using the Sales.SalesOrderHeader tableselect count(*) as CountOfOrders,year(OrderDate) as OrderYear,CustomerID from Sales.SalesOrderHeadergroup by CustomerID,year(OrderDate)Is my query correct for the question,please |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-11-26 : 13:30:33
|
Yes looks correct. I normally list the GROUP BY columns first in the SELECT and then the aggregate functions last. But that doesn't impact the results, just is my programming style.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|