Big SQL Energy Beginner Course: Lesson 10 Between & Not Between
Got BDE?⚡️
Hi BDEs! Welcome to Lesson 10 of the free Big SQL Energy Beginner Course⚡️ Today we’re learning about Between & Not Between to filter data in SQL!
Return to Big SQL Energy Beginner homepage here to access the other lessons:
If you’re new here:
💁🏽♀️ Who Am I?
I’m Jess Ramos, the founder of Big Data Energy and the creator of the BEST SQL course and community: Big SQL Energy⚡️. Check me out on socials: 🔗LinkedIn, 🔗Instagram, 🔗YouTube, and 🔗TikTok. And of course subscribe to my 🔗newsletter here for all my upcoming lessons and updates— all for free!
⚡️ What is Big SQL Energy?
🔗Big SQL Energy Intermediate is an intermediate SQL course designed to solve real-world business problems hands-on using realistic data and a modern tech stack. You’ll walk away with 2 SQL portfolio projects, portfolio building guidance, access to the Big Data Energy Discord community, and lots of confidence for you upcoming coding interviews! You also get access to all monthly events including masterclasses, office hours, and guest speakers. This course is all of the most important things I’ve learned on the job as a Senior Data Analyst in tech who grew from a $72K salary to over a $150K salary. And now I’m sharing it with YOU! It’s more than just another course— it’s a challenging program designed to upskill your SQL to the intermediate level, get ready to ace your live coding interviews, and build connections in the data community through the Discord and events.
Lesson 10: Between & Not Between
So we’ve already learned how to filter datasets for a certain date range in the WHERE clause like this:
select
*
from
orders
where
order_date >= '2024-08-01'
and order_date <= '2024-08-05'
This method filters for a date range (inclusive of the lower and upper endpoints because of the equals signs) by combining 2 date conditions with a Boolean operator (AND). We can actually simplify this code by using BETWEEN to filter for dates between 2 specified endpoints (the lower and upper endpoint). Note that between is inclusive of the upper and lower endpoints of the range, which means that the dates you specify will also be included in the output! Here’s an example:
select
*
from
orders
where
order_date between '2024-08-01' and '2024-08-05'
And of course, we can negate the between using NOT to filter for only dates outside of the specified range:
select
*
from
orders
where
order_date not between '2024-08-01' and '2024-08-05'
And we can filter for certain numeric values as well (not just dates!):
SELECT
*
FROM
orders
where
coupon between 10 and 50
Between and not between are a great way to filter for a range of values whether they’re a numeric value or date. If you’ve enjoyed the free BEGINNER Big SQL Energy course, grab my intermediate course. There are no deadlines or timelines for this course— you start and take as long as you want. It will take your beginner skills to the next level and get you ready to ace your interviews. DM me or email me at courses@bdeanalytics.com if you have questions on the intermediate course!
Return to Big SQL Energy Beginner homepage here to access the other lessons: