From the course: PostgreSQL: Advanced Queries
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Define WHERE criteria with a series - PostgreSQL Tutorial
From the course: PostgreSQL: Advanced Queries
Define WHERE criteria with a series
- [Instructor] PostgreSQL can create a list of sequential numbers with the generate_series function. You can customize the starting and ending number as well as the interval that numbers will be created. For example, we'll select generate_series and inside we have a couple of options. The first number is the number the series will start with. Let's start with 100. The second value is the ending number, and I'll make a series that goes up to 120. The results of this query will list out all the numbers between 100 at the top and 120 at the very bottom. You can also add in an optional third parameter to control an interval. After 120, I'll type in comma 5. This will create a series that will range from 100 to 120 but only includes every fifth number. Now right now, I'm treating the generate_series function as a column with no table. But you can also treat it as a table with a single column. You might see the same function…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Output row numbers with query results2m 29s
-
(Locked)
Cast values to a different data type2m 15s
-
(Locked)
Move rows within a result with LEAD and LAG5m 47s
-
(Locked)
Use an IN function with a subquery4m 7s
-
(Locked)
Define WHERE criteria with a series4m 30s
-
(Locked)
Solution: Calculations across rows4m 19s
-
(Locked)
Pattern matching with regular expressions6m 57s
-
(Locked)
-