AdaptEd
Pod · look-only preview

SQL Result Control: Sorting, Deduplication, and Pagination

Grade 12 Computer Science TEKS SQL.2D 5 slides · 11 questions
Shared by Ram
Sign in to make a copy
Teachers: your copy includes the answer key.
Use with my class
No account needed. You get a link for students and a private page with their scores.
The answer key isn't shown here. Nothing you do on this page is saved or graded.
Opening

Millions of Matches, One Page

A findable screenshot of a Google search results page showing a search query, a results-count line, several results on the first screen, and page-navigation controls near the bottom. Keep the screen focused on the contrast between many reported matches and a limited visible set; do not add explanatory annotations.
Slide 1

Distinct Values and Sort Direction

Slide picture
DISTINCT
— Removes repeated selected values from query results.
ASC
— Orders values from lower to higher or A to Z.
DESC
— Orders values from higher to lower or Z to A.
Check for understanding

Check Your Understanding

Hot Spot

Which displayed result contains each city once in ascending alphabetical order? Click that result table.

Tap on the correct area of the image.

A single database results display contains four unlabeled city tables. The tables show different combinations of Austin, Dallas, and Seattle, including one ascending sequence, one descending sequence, one with a repeated value, and one out of alphabetical order.
Slide 2

Control the Page with LIMIT and OFFSET

Slide picture
LIMIT
— Caps the number of rows returned.
OFFSET
— Skips a specified number of rows before returning results.
Pagination
— Divides a larger result set into navigable pages.
Check for understanding

Check Your Understanding

SQL

Write a query for the requested album page.

The albums table has an album_title column. Return album_title in ascending alphabetical order, skip the first 4 ordered rows, and return no more than the next 4 rows. Write the complete query using the same ordering-and-page pattern shown in the lesson.
SCHEMATable: albums(album_title TEXT).
One column named album_title, containing at most four rows from the alphabetically ordered album titles after the first four are skipped.
0/2000 characters Waiting for input
Slide 3

Worked Case: Unique Products in Reverse Alphabetical Order

Slide picture
Selected columns
— The columns named after SELECT in a query.
Duplicate value
— A selected value that appears more than once.
Check for understanding

Check Your Understanding

Pick 1 Correct Answer

Which query returns each product once in the order Notebook, Mug, Binder?

Choose the one correct answer.

Slide 4

Worked Case: Navigate a Ticket List

Slide picture
LIMIT
— Sets the maximum number of returned rows.
OFFSET
— Sets the number of ordered rows to skip.
ORDER BY
— Sets the sequence of rows in query results.
Check for understanding

Check Your Understanding

Categorize

Classify each SQL clause by the result behavior it controls.

Drag each item into the bucket it belongs in, or click an item and then a bucket. Click an item in a bucket to send it back.

Sets row order
Removes repeated selected values
Sets the page window
0 / 5 placed
Check for understanding

Solo Run: Control Query Results

Categorize

For a score report, assign each clause to the operation it performs on the returned rows.

Drag each item into the bucket it belongs in, or click an item and then a bucket. Click an item in a bucket to send it back.

Sets row order
Removes repeated selected values
Sets the page window
0 / 5 placed
Pick 1 Correct Answer

A shipment table contains Cedar, Maple, Cedar, and Birch in its tree_type column. Which query returns the unique tree types in reverse alphabetical order?

Choose the one correct answer.

Exit check

Show What You Know: SQL Result Control

Pick 1 Correct Answer

A sensor log has values 4, 9, 4, and 2. Which query returns each reading once, from lowest to highest?

Choose the one correct answer.

Categorize

For a library report, assign each clause to the effect it has on the returned rows.

Drag each item into the bucket it belongs in, or click an item and then a bucket. Click an item in a bucket to send it back.

Ascending order
Descending order
Removes repeated selected values
Does not itself remove repeated values
0 / 6 placed
Hot Spot

A report needs each neighborhood once, in alphabetical order. Click the result that meets both requirements.

Tap on the correct area of the image.

One database results display contains four unlabeled neighborhood tables. The tables show different arrangements of Alder, Brook, and Cedar, including one alphabetical sequence with no repeated neighborhood, one reverse sequence, one with a repeated value, and one with a different out-of-order sequence.
SQL

Write a query for the requested inspection-record page.

The inspections table contains inspection_id and inspected_on. Return inspection_id values with the newest dates first, skip the first 7 ordered rows, and return at most 5 rows.
SCHEMATable: inspections(inspection_id INT, inspected_on DATE).
One inspection_id column with no more than five rows from the newest-to-oldest date sequence after seven rows are skipped.
0/2000 characters Waiting for input
Pick 1 Correct Answer

A query must display pages of 6 records from a stable sequence. Which design correctly returns the third page when page one begins at the start of the sequence?

Choose the one correct answer.