Lesson 1, Topic 1
In Progress

Lesson 2.4 – Create Simple Queries Using SELECT, FROM, DISTINCT, and WHERE Clauses

Lesson 2.4 – Create Simple Queries Using SELECT, FROM, DISTINCT, and WHERE Clauses
Unit 2 · Lesson 2.4

Create Simple Queries Using SELECT, FROM, DISTINCT, and WHERE Clauses

Lesson 2.4 of the SQL Coding Specialist course.

SQL Coding Specialist — 60-Hour Course ~90 Minutes Beginner

Learning Objectives

By the end of this lesson, you will be able to:

  • Construct basic SQL queries to retrieve data from a single table using the SELECT and FROM clauses.
  • Use the WHERE clause to filter query results based on conditions (e.g., matching a specific value or range).
  • Apply the DISTINCT keyword to eliminate duplicate values in query results.
  • Understand the general syntax order of a query and how clauses like SELECT, FROM, WHERE, and DISTINCT interact.
  • Practice writing several example queries against a sample schema (e.g., the SchoolHub Students table) to retrieve targeted information.

📚 Key Vocabulary

TermDefinition
SELECTSQL keyword used to begin a query, indicating which columns to retrieve. Example: SELECT FirstName, LastName will pick those two columns from the result set (when combined with FROM and other clauses).
FROMSQL keyword that specifies the table (or tables) from which to retrieve data. Example: FROM Students means the query is looking at data in the Students table. You can only select columns that exist in the tables listed in FROM.
WHERESQL clause that filters rows based on a given condition. Only rows satisfying the condition (expression evaluates to TRUE) are returned. Example: WHERE GradeLevel = 10 filters the result to only include rows where the GradeLevel is 10. If a row has GradeLevel 9, it is excluded.
DISTINCTKeyword that, when placed after SELECT, causes the query to eliminate duplicate rows from the result. Example: SELECT DISTINCT Department FROM Teachers will list each department only once, even if multiple teachers share the same department.
ClauseA component of an SQL query that serves a particular purpose (SELECT clause, FROM clause, WHERE clause, etc.). Clauses often start with keywords and together form the full statement. Understanding each clause in isolation helps in constructing queries step by step.
ConditionAn expression in the WHERE clause that each row is tested against. It uses operators (like =, >, <, AND, OR, LIKE) to form a logical test. Example: GradeLevel = 12 AND IsEnrolled = 1 is a condition that checks two things about each row. Conditions can be simple (Age > 18) or complex combinations of multiple checks.
Logical OperatorsKeywords that combine or modify boolean conditions in SQL. Example: AND, OR, NOT are logical operators. AND means both conditions must be true, OR means at least one is true, NOT negates a condition. In a query: WHERE GPA >= 3.0 AND GPA < 4.0 uses AND to require both comparisons to hold.
LIKEAn operator used in a WHERE clause for pattern matching with text. Example: LastName LIKE 'A%' finds any LastName that begins with "A". % is a wildcard representing any sequence of characters, _ (underscore) represents any single character. So 'SMITH' LIKE 'S____' would be true for "Smith" (S + four letters).
INA condition operator that checks if a value is in a set of values. Example: GradeLevel IN (9, 10, 11) is true if GradeLevel is either 9, 10, or 11. It's a shorthand for multiple OR conditions.
BETWEENA condition operator that checks if a value lies between two values (inclusive). Example: WHERE DateOfBirth BETWEEN '2005-01-01' AND '2005-12-31' would find anyone born in the year 2005 (assuming the dates given cover that year). It's equivalent to DateOfBirth >= '2005-01-01' AND DateOfBirth <= '2005-12-31'.
ORDER BYClause (often at the end of a query) that sorts the results by one or more columns. Example: ORDER BY LastName ASC will sort the output by last name in ascending (A-Z) order. DESC would be descending. You can sort by multiple criteria (e.g., ORDER BY GradeLevel, LastName sorts by grade, then within the same grade, by name). (Though not in the lesson title, we've introduced it as it naturally fits with reporting queries).

💡 Real-World Analogy

Imagine your school has a huge filing cabinet with folders for every student. If you want to find information, you could pull out all the folders and search manually, but that’s inefficient. Instead, you might tell an assistant specific criteria: "Bring me the folders of all 10th grade students, and from each folder, note down the first and last names." In this analogy, FROM specifies the cabinet (e.g., the Students cabinet), WHERE specifies the criteria (grade = 10th), and SELECT specifies what information to take from each folder (first and last name). If the assistant comes back and says, "There were 100 folders, but many students have the same last name, here’s a list of unique last names among them," that corresponds to using DISTINCT to list unique values.

Another analogy: Using a search engine. The web is like a huge database. When you type a query like "schools in Florida", the search engine is effectively doing something analogous to SELECT * FROM WebPages WHERE content CONTAINS 'schools' AND content CONTAINS 'Florida'; behind the scenes (very simplified!). If you refine your search by adding quotes or excluding words, it's like adding more conditions to your WHERE clause. And if you say "I just want one result per site, not multiple pages from the same site," that's akin to DISTINCT (one result per site domain).

The bottom line: In everyday life, whenever you ask for specific information from a large pool of data (whether it's files, web pages, or a catalog), you're performing the conceptual equivalent of SELECT ... FROM ... WHERE ... and sometimes DISTINCT to avoid repeats.

🧱 Concept Explanation

A basic SQL query has a simple structure. The fundamental form is:

SELECT [DISTINCT] column1, column2, ... FROM table_name WHERE condition;

Let's break down each of these components:

  • SELECT: This clause specifies which columns of the data you want to retrieve. Think of this as choosing which attributes or fields you care about. If you want everything (all columns), you can use * as a wildcard (meaning "all columns"). For example, SELECT * FROM Students would get every column for every student. But often you don't need every column. If you only need names, you might do SELECT FirstName, LastName FROM Students. This not only can reduce the amount of data processed, but it also makes it clearer what the query results represent.
  • FROM: This clause tells SQL which table (or tables, in advanced queries) to pull data from. In a simple query, it's just one table. For instance, FROM Students means we're looking at the Students table for data. The table must exist in the database (and typically you must have permission to read it). You can only select columns that exist in the table(s) you list in FROM.
  • WHERE: This is an optional clause that filters the result set to include only those rows that meet certain conditions. If you omit WHERE, the query will return all rows from the table (subject to any other clauses like DISTINCT). With a WHERE, you can be very specific. The condition in a WHERE clause is like a question or test for each row: only rows for which the condition is TRUE will be included in the output. For example, WHERE GradeLevel = 10 will include only rows where the GradeLevel column equals 10. You can combine conditions with logical operators:
  • =, <> (or !=), >, <, >=, <= are comparison operators for equality, inequality, greater/less than, etc. E.g., WHERE GPA >= 3.5 would filter students with GPA 3.5 or above.
  • AND, OR allow combining multiple conditions. E.g., WHERE GradeLevel = 10 AND IsEnrolled = 1 means the student must be in 10th grade and currently enrolled.
  • LIKE is used for pattern matching with text. For example, WHERE LastName LIKE 'S%' finds all last names starting with S. (% is a wildcard in LIKE patterns representing any sequence of characters.) We haven't formally introduced LIKE in objectives, but it's a common addition to know for filtering text.
  • IN allows specifying a set of values. E.g., WHERE GradeLevel IN (9, 10, 11) means grade is either 9 or 10 or 11. (This is equivalent to GradeLevel = 9 OR GradeLevel = 10 OR GradeLevel = 11 but shorter.)
  • BETWEEN is for ranges. E.g., WHERE DateOfBirth BETWEEN '2006-01-01' AND '2006-12-31' would find students born in the year 2006.

These are just a few examples; the key point is that WHERE dramatically narrows down results to only those rows you actually want according to some criteria.

  • DISTINCT: This is an optional keyword that can be placed right after SELECT (before the column list) to remove duplicate rows from the result set. When might you use DISTINCT? Suppose you want to list all grade levels present in the Students table. If you do SELECT GradeLevel FROM Students, and there are 100 students, you'll get 100 results, many of which are repeats of 9, 10, 11, 12. If you only want each grade level once, you use SELECT DISTINCT GradeLevel FROM Students. This will give you just "9, 10, 11, 12" (assuming those are the only distinct values). DISTINCT applies to the combination of columns you select. If you select multiple columns, DISTINCT will ensure each combination of those column values is unique.

Important: DISTINCT is not a function, it applies to the whole row of selected columns. For example, SELECT DISTINCT GradeLevel, IsEnrolled FROM Students will give unique pairs of GradeLevel and IsEnrolled. If you only wanted distinct GradeLevel irrespective of enrollment status, just select GradeLevel alone with DISTINCT.

  • Semicolon (;): This marks the end of the statement. In many interactive SQL shells or the lab environment, a single query can be run without a semicolon, but it's good practice to include it, especially when writing SQL scripts or multiple statements.

Order of Execution (under the hood): While you write the query as SELECT ... FROM ... WHERE ..., it's helpful to understand that logically the database first identifies the data from the FROM clause (taking the table), then applies the WHERE filter to that data, then finally the SELECT picks the columns (and DISTINCT removes duplicates if specified). So you can think of it as: 1. Take all rows from the table(s). 2. Apply the WHERE filter to discard rows that don't match. 3. From the remaining rows, collect the columns requested in SELECT. 4. If DISTINCT is used, remove duplicate rows from that set. 5. Return the result.

This is why, for instance, you can't put an alias or a computed column from the SELECT clause into the WHERE directly (because the WHERE is applied before SELECT expressions are processed). That's an advanced detail, but just in case you ever try something like SELECT FirstName, LENGTH(LastName) AS NameLen FROM Students WHERE NameLen > 5; – that won't work because the database doesn't know NameLen at the time it's filtering. The correct way would be WHERE LENGTH(LastName) > 5 using the expression again or a subquery.

Examples:

Let's illustrate with the SchoolHub Students table we have: - Example 1: Basic retrieval – Get all data on all students:

SELECT * FROM Students;

This will return every column for every row in Students. Use this sparingly on big tables because it can be a lot of data, but it's fine on our small sample for testing or if we truly need all fields.

  • Example 2: Specific columns – Suppose we want a contact list of students with just their names and maybe we had a phone number column. We could do:
  • SELECT FirstName, LastName
FROM Students;
  • This yields a two-column result with first and last names of each student. If we had 100 students, we'd get 100 rows (names of all students).
  • Example 3: Filtering – Get all currently enrolled 10th graders' names:
  • SELECT FirstName, LastName
FROM Students WHERE GradeLevel = 10 AND IsEnrolled = 1;
  • Here, only rows where GradeLevel is exactly 10 and IsEnrolled is 1 (true) will be included. So if there are, say, 25 tenth graders but only 20 are currently enrolled (others might have left), you get 20 results. The AND ensures both conditions must hold. If you used OR instead, it would be a different query: GradeLevel = 10 OR IsEnrolled = 1 would give you all tenth graders plus anyone (of any grade) who is enrolled, which is not what we want here. So use AND/OR carefully.
  • Example 4: Using DISTINCT – List all distinct grade levels that have enrolled students:
  • SELECT DISTINCT GradeLevel
FROM Students WHERE IsEnrolled = 1;
  • This might return something like: 9, 10, 11, 12 (each only once, even if multiple students in each grade). If no enrolled student in a certain grade, that grade won't appear. If we omitted DISTINCT, and we had counts like 30 grade9, 28 grade10, etc., we'd see multiple repeated values in the output.
  • Example 5: More advanced filtering with patterns – Find all students whose last name starts with "S":
  • SELECT FirstName, LastName
FROM Students WHERE LastName LIKE 'S%';
  • Here % is a wildcard meaning "any sequence of characters". So LastName LIKE 'S%' means last name begins with "S". If we used '%S' it would mean ends with S, and '%S%' means contains S anywhere. This is a typical use of LIKE for basic pattern matching.
  • Example 6: Combining conditions – Suppose we want students who are either in 9th or 10th grade, and only those enrolled. We could do:
  • SELECT FirstName, LastName, GradeLevel
FROM Students WHERE IsEnrolled = 1 AND GradeLevel IN (9, 10);
  • This will fetch only enrolled students, and among them only those whose grade level is 9 or 10. The IN clause is just a compact way of saying (GradeLevel = 9 OR GradeLevel = 10).
  • Example 7: Query with DISTINCT on multiple columns (just to illustrate):

If we run:

  • SELECT DISTINCT GradeLevel, IsEnrolled
FROM Students;
  • We might get results like:

GradeLevel | IsEnrolled 9 | 1 10 | 1 11 | 1 9 | 0 12 | 1 10 | 0 ... Each row is a unique combination of grade and enrollment status that appears in the table. For example, if one student in 9th grade is not enrolled (IsEnrolled=0), the pair (9,0) appears. If all 12th graders are enrolled and none left, maybe (12,0) doesn't appear at all. The point is DISTINCT considers the whole row. If you only wanted distinct GradeLevel values (regardless of enrollment), list only GradeLevel after DISTINCT.

Understanding Query Results: The output of a SELECT query is a result set, which you can think of as a temporary table that holds the data you asked for. It has columns (as you specified or derived) and rows that meet your criteria. This result can be used directly (seen on screen, used in application) or even fed into other queries (as we'll eventually see with subqueries or joining multiple tables in later lessons).

✍️ Best Practices

🎯 Specify Columns Instead of

SELECT *: While SELECT * is quick and easy, especially in exploratory queries, it's best practice to explicitly specify the columns you need in production queries or reports. This makes your query's intent clear (readers know exactly which data is being pulled) and can reduce overhead. For example, if a table has 20 columns and you only need 3, selecting just those 3 avoids reading the other 17 unnecessarily. It also prevents issues if the table structure changes (adding columns won't accidentally start pulling more data into your result).

🚫 Use Meaningful Aliases (if needed)

In more complex queries or when presenting results, you can rename columns using aliases for clarity. For example, SELECT FirstName + ' ' + LastName AS FullName FROM Students; (syntax may differ by database) could combine first and last name into one column labeled "FullName". Or you might alias a column name to a more user-friendly or shorter label in the output. Aliases are created by using the AS keyword (which is optional – you can just do LastName Last in some SQL dialects). Use aliases to make query results easier to read or to avoid confusion when joining tables that have columns with the same name.

📐 Comment Your Query (for complex logic)

If you have a particularly complex WHERE clause, consider adding a brief comment above the query explaining what it's meant to do. For example: -- Find students who are seniors (12th grade) and under 18 on a given date (minors) SELECT FirstName, LastName FROM Students WHERE GradeLevel = 12 AND DateOfBirth > '2007-09-01'; This helps others (and future you) understand the intent behind the conditions (here, presumably checking if seniors have birthdays after a certain cutoff making them under 18).

🧷 Check Your Conditions on a Small Scale

Before running a query that filters on multiple conditions, you can test parts of it separately to ensure each condition does what you think. For example, first run SELECT * FROM Students WHERE GradeLevel = 12; then SELECT * FROM Students WHERE DateOfBirth > '2007-09-01'; to see the sets, then combine. This way you verify each piece. This is similar to what we mentioned in earlier lessons about verifying which rows will be affected. With SELECT (which is read-only), it's safe to test different conditions without altering data.

🏷️ Be Careful with NULL in WHERE

If any of your data can be NULL, remember that comparisons with NULL are tricky – NULL is not "equal" to anything, not even another NULL. If you have a condition like WHERE Email = 'student@example.com', a student with NULL Email will neither match nor not match – they are just excluded (because any comparison with NULL yields UNKNOWN which is treated as FALSE for filtering). If you need to include or exclude NULLs explicitly, use IS NULL or IS NOT NULL conditions. For example, WHERE Email IS NULL finds records with no email. Or WHERE Email IS NOT NULL finds those that do have an email. This is a common pitfall: forgetting that WHERE SomeField != 'value' will not include rows where SomeField is NULL (not just not equal, but null altogether).

💭 DISTINCT vs GROUP BY

This might be advanced for now, but note that DISTINCT is essentially a shortcut for grouping by all selected columns and taking one from each group. When you start needing to do aggregate calculations, you'll use GROUP BY. For simply eliminating duplicates, DISTINCT is fine. But don't overuse DISTINCT to compensate for poorly structured queries that produce duplicates unintentionally – it's better to write the query in a way that naturally yields unique rows (especially when joining tables, which we will see later). In summary: use DISTINCT when it truly makes sense to collapse duplicate values; avoid just slapping DISTINCT on every query as a catch-all, because it can mask underlying issues and potentially degrade performance.

🔑 Formatting

We touched on formatting before, but specifically for SELECT queries: put each major clause on a new line (SELECT, FROM, WHERE, etc.), and indent continuation lines (like if you list many columns or have a long WHERE, you might format them neatly). This makes it much easier to read and debug. Example: SELECT FirstName, LastName, GradeLevel FROM Students WHERE IsEnrolled = 1 AND GradeLevel >= 10 AND LastName LIKE 'S%'; This format is easy on the eyes. It’s clear what we are selecting and from where, and the conditions are stacked for readability. Consistent formatting is a subtle but important best practice for any coding, SQL included.

🧪 Hands-On Practice

Warm-Up

Try It Yourself

Using the SchoolHub database (or a similar dataset), write and execute queries to accomplish the following tasks. After each query, check the output to ensure it’s correct and make adjustments if needed:

  • All Students List: Write a query to select all columns from the Students table for all students. Run it to see the full data (this is essentially a sanity check that our data is in the table as expected). Example: SELECT * FROM Students;
  • After running, note how many rows you got and verify it matches the number of students you inserted.
  • Selective Columns: Write a query to get a list of students' full names (you can either concatenate or just select first and last name separately) and their grade level. Only those columns. Example: SELECT FirstName, LastName, GradeLevel FROM Students;
  • This should show something like (Alice, Johnson, 10), (Bob, Smith, 10), etc. Check that you didn't accidentally include more columns.
  • Use of WHERE – single condition: Query all students who are in 11th grade. Example: SELECT FirstName, LastName FROM Students WHERE GradeLevel = 11;
  • Does it show the students you expect (from the ones you inserted, who were grade 11)? If you had two, it should show two names. If none, maybe you didn't insert an 11th grader – adjust one of your inserts or the query accordingly.
  • WHERE with text condition: Query all teachers in the Science department (from the Teachers table). Example: SELECT FirstName, LastName FROM Teachers WHERE Department = 'Science';
  • Check that it lists those science teachers correctly. If you only had one Jane Doe in Science, you should see just Jane Doe. Try changing the condition to a department that doesn't exist (e.g., 'Art') and verify you get no results, which is expected.
  • WHERE with AND: Get the names of students who are in 10th grade and currently enrolled (IsEnrolled = 1). Example: SELECT FirstName, LastName FROM Students WHERE GradeLevel = 10 AND IsEnrolled = 1;
  • If you marked someone as not enrolled (like we updated Evan to IsEnrolled = 0 in lesson 2.3), ensure that if Evan was grade 9 he wouldn't appear since he fails the enrolled condition. If all your 10th graders are enrolled, this yields the same as just grade 10. Consider temporarily setting one 10th grader to IsEnrolled = 0 and re-run to see the difference (then you can set them back).
  • WHERE with OR: Query students who are in 9th or 12th grade (perhaps the "entry and exit" grades of high school). Example: SELECT FirstName, LastName, GradeLevel FROM Students WHERE GradeLevel = 9 OR GradeLevel = 12;
  • Check that you get all 9th and 12th graders. If none in one category, that's fine. Make sure no 10th or 11th graders show up. This helps you see the OR logic.
  • WHERE with IN: Achieve the same result as above (9th or 12th graders) using an IN clause. Example: SELECT FirstName, LastName, GradeLevel FROM Students WHERE GradeLevel IN (9, 12);
  • The result should match the OR query exactly. It's good to see both approaches yield the same outcome.
  • WHERE with pattern (LIKE): Find any students whose first name starts with "A". Example: SELECT FirstName, LastName FROM Students WHERE FirstName LIKE 'A%';
  • See if it returns those names correctly (Alice should appear, others depending on your data). Try another pattern, like last names containing "o" (WHERE LastName LIKE '%o%') and see the variety of results. This isn't in objectives explicitly but is a quick, useful tool.
  • DISTINCT usage: List all distinct departments from the Teachers table. Example: SELECT DISTINCT Department FROM Teachers;
  • Even if you have only a few teachers, imagine many teachers share departments. The result should list each department name only once. You could cross-check by counting how many teachers you inserted per department and see that duplicates are removed.
  • Also, try SELECT DISTINCT GradeLevel FROM Students; to see the distinct grade levels in your data. It should list each grade 9-12 at most once, possibly skipping any you have no data for (e.g., if you had no 12th graders, 12 won't appear).
  • Combining it all: A slightly more complex query – list the full names of students (you can concatenate first and last name using your SQL dialect, or just select both) who are enrolled and whose last name starts with "S". This combines AND and a function:

Example (SQL Server syntax for concatenation):

  • SELECT FirstName + ' ' + LastName AS FullName
FROM Students WHERE IsEnrolled = 1 AND LastName LIKE 'S%';
  • This should return results like "Bob Smith" if Bob is enrolled and last name Smith, etc. If no one qualifies, adjust one of your data entries or try a different letter that matches someone. This query is good practice in combining conditions and selecting a derived output (FullName). In MySQL, you'd use CONCAT(FirstName, ' ', LastName) instead of +. Adjust to your environment.

After each query, verify the results and consider: does each output make sense given the underlying data? If something looks off (too many/few results), tweak your WHERE clause accordingly. This kind of iterative testing is how SQL queries are developed to ensure accuracy.

💻 Coding Lab

Coding Challenge

Apply What You've Learned

SchoolHub Report Queries: Assume that the school administrators have asked you for specific reports from the SchoolHub database. Use the knowledge of SELECT, FROM, WHERE, and DISTINCT to write the SQL queries for each request and test them in the Knowledge Pillars Coding Lab (or your SQL environment). Document the query and a brief explanation or result for each:

  • Enrolled Students by Grade: The principal wants a roster of currently enrolled students, organized by grade. Write a query to select the FirstName, LastName, and GradeLevel of all students who are enrolled (IsEnrolled = 1). Use an ORDER BY GradeLevel clause to sort the results by grade (and perhaps a secondary sort by last name within each grade for readability).

Hint: SELECT FirstName, LastName, GradeLevel FROM Students WHERE IsEnrolled = 1 ORDER BY GradeLevel, LastName;

  • Run this query. Check that the output groups students by grade level in ascending order. This gives the principal an easy-to-read list grouped by grade. (We introduced ORDER BY here even though it wasn't explicitly in the lesson title, because sorting is a common requirement for reports. It's straightforward: it orders the result by the specified column(s).)
  • Grade Levels Offered: The school board asks, "What grade levels does our school serve?" Instead of reading a document, you can derive this from the database. Use a query to get the distinct GradeLevel values from the Students table (this assumes each grade from 9-12 has at least one student; if not, consider adding data or note that an empty grade won't show).

Query: SELECT DISTINCT GradeLevel FROM Students ORDER BY GradeLevel;

  • This should output e.g., 9, 10, 11, 12 (one per row). The ORDER BY GradeLevel will list them in numeric order. Provide this list as the answer to the board.
  • Department Directory: Create a list of all distinct departments in the Teachers table. This helps administrators see which departments exist.

Query: SELECT DISTINCT Department FROM Teachers ORDER BY Department;

  • If you added an Order By, it sorts them alphabetically. For example, "History, Mathematics, Science". This output can be given as a quick department directory. If you wanted to fancy it up, you could join it with teacher counts later, but we'll keep it simple for now.
  • Find Specific Students (lookup): A guidance counselor wants to find any student with a particular last name (say "Smith"). Write a query that filters students by last name.

Query: SELECT FirstName, LastName, GradeLevel FROM Students WHERE LastName = 'Smith';

  • This will return all students who have the last name Smith and show their first name and grade. Test it with a last name you know exists in your data. If you have case sensitivity considerations (in some databases 'smith' might not match 'Smith'), ensure you use the correct case or a case-insensitive collation (but that's beyond scope; assume exact match for now).
  • If the counselor is not sure of spelling, you could use LIKE 'Smi%' to catch "Smith" or "Smithe", etc. But let's assume exact match for this query.
  • Conditional Listing: The sports coach needs to know which 12th graders (seniors) are eligible for a certain competition (say eligibility requires them to be enrolled). Formulate a query to list all 12th grade students who are currently enrolled, showing their name and maybe age or birthdate if needed. For now, just name.

Query: SELECT FirstName, LastName FROM Students WHERE GradeLevel = 12 AND IsEnrolled = 1;

  • This yields the list of enrolled seniors. If you didn't have any 12th graders in your sample, you might not get results; consider inserting one to test or adjust the grade in the query to one you do have.
  • The logic (12 and enrolled) demonstrates multiple criteria filtering.
  • Bonus - Cleanup Check: The school secretary thinks there might be an empty table for "Alumni" that isn't used yet. You can verify by selecting from it. If you created an Alumni table (perhaps not yet), run a query: SELECT * FROM Alumni;. It likely has no rows. This isn't a query you would necessarily report on, but it's a way to demonstrate that a SELECT with no matching rows simply returns an empty set. You can then decide to drop the table or leave it for future use. (This is more of a DDL management task, but uses SELECT to investigate.)

For each query above, write it in the lab, execute it, and observe the results. In a real scenario, you'd then format these results or export them as needed. In our learning context, focus on getting the correct data.

Make sure to save your queries (perhaps in a .sql file or notes) – they are the building blocks for more complex tasks ahead. Each query here is relatively simple, but together they fulfill real information needs. As the database grows in complexity (more tables, relationships), you'll build on these skills to pull info from multiple tables, do calculations, etc.

By practicing these queries, you are now capable of asking a wide range of questions to a single-table database: you can get all records, filter down to specific criteria, avoid duplicates, and sort results. Great job – this is the essence of data retrieval with SQL!