QUERIES PROJECTS AND APPLICATIONS RPA Customer Segmentation


#1

Question 2: my code is:

SELECT *
FROM users
WHERE birthday BETWEEN 1980 AND 1989;

This code works fine but now I see in the Hint that they used this code:

SELECT email, birthday
FROM users
WHERE birthday BETWEEN ‘1980-01-01’ AND ‘1989-12-31’;

This also works and it is stated that you should go for the second option because in the Table, birthday actually needs a TEXT insert. But what is the difference in the end? as my method works fine. Thanks in advance.


#2

It’s probably just a bad example to make this point on since you’re looking for a range of years and not a range of days in a specific month. I think the dashes in the full date format require it to be in quotes and why it’s considered text format ( I could be wrong) but you can test that but running this:

SELECT email, birthday
FROM users
WHERE birthday BETWEEN 1989-12-01 AND 1989-12-31;

If it doesn’t work without the quotes, those would be the limitations of doing it your way.