AI Computer Science Academy · Faisalabad

SQL & Databases

Keep the newest rows

Task 51 of 56 SQL Capstone: reports a client would pay for
All tasks
Read first Task 51

Keep the newest rows

`ORDER BY ... DESC` sorts newest first and `LIMIT` keeps only the top rows, which is how every dashboard shows recent activity.

What you are building

The task in front of you: Task: Keep the newest rows. Which rows come back?.

The editor already holds a working starting point. Do not delete it and start again — read it, change one thing, run it, and watch which check moves. That loop is the whole method.

Why this matters

You are inside the section “Capstone: reports a client would pay for” of the SQL & Databases track. Everything in this section builds towards the section project, and this task is one of the pieces that project leans on.

In real work nobody marks your code — it either runs or it does not, and someone is waiting for the result. The checks here are deliberately strict about output, because a program that prints the right thing in the wrong shape fails in the real world too.

The key idea

SQL describes the result you want, not the steps to get it. SELECT picks columns, FROM picks the table, and WHERE filters rows before they are returned.

Quotes matter: text needs single quotes, numbers do not. A column name in the wrong place is the most common reason a correct-looking query returns nothing.

Two mistakes to avoid

  • Filtering with WHERE after a JOIN when you meant to filter before it — the rows you excluded still influenced the join.
  • Writing SELECT * and then comparing text output. Ask for exactly the columns the task names, in the order it names them.

What the automatic checks look for

The right-hand column runs 1 check every time you press Run code. Nothing is hidden:

  • The output has to contain “rows:[["Hamza"…”.

Task

Task: Keep the newest rows. Which rows come back?

The editor already contains a starting point. Change it until every check passes — the Next task button unlocks when it does.

What you start with
SELECT name, joined
FROM students
ORDER BY joined DESC
LIMIT 3;
SQL 1 automatic check Capstone: reports a client would pay for
Code editor Ctrl + Enter runs
Run your code to see the output and the checks.
Your result

Submit your code to see results

Write your code in the middle column and press Run code.

Checks on this task:

  • Check 1

Stuck? The Hint button at the bottom nudges you one step without handing over the answer — that is on purpose: an exercise you copied teaches nothing.

Track progress

0 of 56 tasks complete

Next task unlocks when every check passes.

Sign in to keep your code and certificates.

Next task (pass every check first)