Sign up and we'll send you the best freelance opportunities straight to
your inbox.
We're building the largest self-service freelancing marketplace for people like you.
Problem: List all orders placed in September 2013.
SELECT FirstName, LastName, OrderNumber,
OrderDate, TotalAmount
FROM [Order] O
JOIN Customer C ON C.Id = O.CustomerId
WHERE MONTH(OrderDate) = 9 AND
YEAR(OrderDate) = 2013
Result: 37 records
FirstName
LastName
OrderNumber
OrderDate
TotalAmount
Rita
Müller
542781
2013-09-01 00:00:00.000
530.40
André
Fonseca
542782
2013-09-01 00:00:00.000
331.78
Peter
Franken
542783
2013-09-02 00:00:00.000
1203.50
Christina
Berglund
542784
2013-09-02 00:00:00.000
668.70
Maurizio
Moroni
542785
2013-09-03 00:00:00.000
193.00
MONTH in GROUP BY, ORDER BY
ORDER
Id
OrderDate
OrderNumber
CustomerId
TotalAmount
CUSTOMER
Id
FirstName
LastName
City
Country
Phone
Problem: List the number of orders by month for the year 2013.
SELECT MONTH(OrderDate) AS Month,
COUNT(Id) AS Count
FROM [Order]
WHERE YEAR(OrderDate) = 2013
GROUP BY MONTH(OrderDate)
ORDER BY MONTH(OrderDate)
Sign up and we'll send you the best freelance opportunities straight to
your inbox.
We're building the largest self-service freelancing marketplace for people like you.