From the course: SQL for Data Analysis
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
Filtering data by dates - SQL Tutorial
From the course: SQL for Data Analysis
Filtering data by dates
- In a larger database, we wouldn't want to return all of the orders. For one, it could get pretty inefficient; and 2, we most likely aren't interested in every record. Instead, we're going to identify a subset of the data by using dates. I need to show the sales team a list of all the orders from May 2016. Let's incorporate both logical and comparison operators and the date functions from our previous section. Let's open the ComparisonOperators.sql file. We have the following query, SELECT OrderID and CreationDate FROM Orders, where the month is equal to 5 and the year is equal to 2016. A couple of things to note here. Month and year are returned as integers, and the values can be noted in single quotes or not. That doesn't matter, since they are integers. Also, we use the AND operator so that both conditions must be true in order for the records to be returned. If either condition is false, we will not get the records…