Loading
Current section: SQL 6 exercises
Problem

Sorting Users by Recent Entry with Raw SQL

Transcript

00:00 Well, now our product manager is doing the product manager thing and wants to make sure that these users are sorted by their recent activity. And we determine recent activity based on how recently they updated any of their notes, right? So we need to have some sort of way

00:18 to sort these users by the notes that they are taking and when they've last updated their note, which adds a fair bit of complexity to our query. But it's actually the entire reason why we're using raw SQL for this in the first place, because so far what we have here,

00:37 there's nothing here that we couldn't just do with Prisma. This is the feature that requires us to use our query raw from Prisma, because Prisma, as of today, is not capable of doing this type of a query. So your job is to add a nested order by query

00:55 here so that we can select all of the user's notes and order those by the most recently updated. And then we can use that to order the users by the user that has the most recently updated note. And so that way we can sort these by the most active users.

01:13 So that is your objective here. You will have some good instructions showing you how to accomplish this in the instructions. So take a whack at it and have a good time.