Stithaprajyna

I use this blog to jot down what ever comes into my mind or get to see anything I feel is important.

Thursday, December 22, 2005

SQL Server QOD

This is the Question that appeared in SQL Central -

SELECT COUNT(*) AS OrderCount,
MONTH(OrderDate) AS OrderMonth,
YEAR(OrderDate) AS OrderYear
FROM Orders
GROUP BY OrderDate
ORDER BY OrderDate

Assume that the column and table names are correct and that OrderDate is a dateTime column. What is wrong with this query?

Answer:
The query will run without error, but will give the count of orders by order date, not summarized by month and year

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home