6 kyu
Generation Categorization
161bornForThis
Description:
Assume you have a PostgreSQL database with a table named "users". The "users" table has the following columns:
id
(integer): a unique identifier for each user.name
(text): the name of the user.birthdate
(date): the user's birth date.
The generational categories are generally defined as follows:
Generation Z
: Born from 1997 to 2012 (inclusive)Millennials
: Born from 1981 to 1996Generation X
: Born from 1965 to 1980Baby Boomers
: Born from 1946 to 1964Silent Generation
: Born from 1928 to 1945Greatest Generation
: Born in 1927 or earlier
Your SQL query should return all users sorted by id
in asc order from the users table with an additional generation field that indicates the generation to which each user belongs based on the above definitions.
Sounds simple? You are not allowed to use the CASE WHEN
operator for this task :-)
GLHF!
Desired Output
The desired output should look like this:
id | name | birthdate | generation |
---|---|---|---|
1 | Mr. Nerissa Cremin | 1994-03-15 | Millennials |
2 | Mattie Lind | 1961-04-05 | Baby Boomers |
3 | Cody Murray | 1966-12-05 | Generation X |
SQL
Databases
Restricted
Similar Kata:
Stats:
Created | Jul 8, 2023 |
Published | Jul 8, 2023 |
Warriors Trained | 308 |
Total Skips | 27 |
Total Code Submissions | 547 |
Total Times Completed | 161 |
SQL Completions | 161 |
Total Stars | 7 |
% of votes with a positive feedback rating | 92% of 31 |
Total "Very Satisfied" Votes | 27 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |