Rainbow Deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Providing detailed information and counting objects
4. Time-constrained reports
Calculating metrics for multiple business objects
Understanding the difference between various count metrics
Summary

Instruction

Good job! Another common report type is a tally of certain objects, often based on a time filter. Take a look:

SELECT
  COUNT(*)
FROM Orders
WHERE OrderDate >= '2016-07-01' AND  OrderDate < '2016-08-01';

In this query, we count the number of orders placed in July 2016. Note how we used the WHERE clause to get the time limit we're interested in.

Also note that dates in MS SQL Server are always placed inside single quotes and are formatted as YYYY-MM-DD (i.e., year-month-day). This may be a bit counterintuitive in countries that use other date formats, so watch out.

Exercise

Count the number of employees hired in 2013. Name the result NumberOfEmployees.

Stuck? Here's a hint!

Use the HireDate column from the Employees table.