FAQ: Code Challenge: Queries - Code Challenge 9

This community-built FAQ covers the “Code Challenge 9” exercise from the lesson “Code Challenge: Queries”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development
Data Science

FAQs on the exercise Code Challenge 9

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I have a kind of general question. The timestamp values make no sense to me, so I didn’t understand why we need to put them in DESC order. Can someone explain what this number means so that I can understand why we ordered it this way?


In this exercise we are asked to find 20 recent articles from Business category.

I want to go further and find 20 recent articles in both Business and Technology categories . Unfortunately, my query didn’t work:

select * from news
where category = ‘t’ or category = ‘b’
group by category
limit 20;

I also tried another variation of where like category = ‘t’ or ‘b’ - also didn’t work.

Also tried this

select * from news
group by category
having category = ‘b’ or category = ‘t’
limit 20;

How can I combine search for two categories and why my queries didn’t work?

If you want the 20 most recent articles, shouldn’t use order by?

where category = ‘t’ or category = ‘b’ should work, or you could use: WHERE category IN ('b', 't').

Anyway, if we do:

select * from news
where category = ‘t’ or category = ‘b’
order by timestamp des;

(which codecademy doesn’t like), we can see of all the most recent articles, they are all in tech, not Business.

1 Like

Is the IS operator the same as “=”? I thought = was only used from numbers, but then I saw it used instead of IS in the exercise. My query with IS worked, but I wasn’t sure what the rule/best practice is.

have you tried to google if is and = are the same thing? Understanding the difference is highly recommended.

Yes, I did Google it, but all of the answers I found are in relation to the NULL value. I thought that this forum was for questions on the exercises in Codecademy. Would appreciate some help on the concept.

So that answers the question? = checks for equality, is checks if value is a null value

we can’t use = for checking if value equals NULL, because null means no value.

1 Like

OK, now I get it. IS only applies to NULL. Otherwise, = is the correct operator. Thank you.


Why does swapping ORDER and LIMIT yield no results?

WHERE category = ‘b’
ORDER by timestamp DESC;

(I understand that this could change the list you obtain; I am just curious why this finds nothing)


WHERE category = ‘b’ AND title LIKE’SEC%’

ORDER BY timestamp DESC

LIMIT 20;Practicing with other CLAUSES you have learned is important and interesting

i dont want to soud bad, but it would be kind if students would ofter get a reply from moderators on interesting questions, as this is a paid course. could anyone help?

I don’t know if this was answered, and more than 4 years later, you’re probably no longer interested.
I ran into this, had the same question, did some googling, and I believe that I figured it out.

The numbers in the TIMESTAMP column for this exercise apparently represent the number of milliseconds between January 1, 1970 and the date/time at which the article was published. On a related note, there’s something called unixepoch time, which gives the number of seconds between January 1, 1970 and the date/time in question.

Also, the strftime() function has ‘unixepoch’ as one of its modifiers. So what I did was convert the timestamp from milliseconds since January 1, 1970 to seconds, by dividing the number by 1000. Doing that enabled me to use that ‘unixepoch’ modifier, and then I formatted it with the usual %m, %d, %Y, etc.

If I’m correct about this, the most recent 20 business articles (category = ‘b’) were published between 10:25 PM and 10:59 PM on March 10, 2014.

On a related note, I wish that the Codecademy people would make the timestamp values resemble dates readable by humans.

strftime(‘%m-%d-%Y %H-%M-%S’, timestamp/1000.0, ‘unixepoch’) as blah,

Capture 03