Interactive Platform

SQL Practice Lab

Master SQL from Beginner concepts to Expert level QA validation queries. Read the tutorials, write queries, and see the results instantly using our real-time mock database engine.

🟢 Beginner Level: SQL Fundamentals

Welcome to the world of databases! SQL (Structured Query Language) is the standard language used to communicate with databases. As a QA Tester, SQL is your superpower to verify if front-end actions are correctly reflected in the back-end database.

💡 Analogy for Easy Understanding

Think of a Database as a physical Filing Cabinet. Inside it, each drawer contains Excel Sheets. In SQL, these sheets are called Tables. Each vertical column in the sheet is a Column (attribute), and each row of data is a Row (record).

Our Practice Database Tables

We have prepared a realistic QA database with 5 tables for you to practice:

  • employees - Staff info (name, role, salary, department)
  • departments - Department names & office locations
  • projects - Team projects and financial budgets
  • testers - QA Testers who validate the software
  • bugs - Logged software defects, severity, and status

Lesson 1 The SELECT Statement

The SELECT statement is used to fetch (read) data from a table. The asterisk * means "Select all columns".

SELECT * FROM employees;
💡 QA Tip: Use this to confirm that new employees added via the UI registration form actually got saved in the database!

Lesson 2 Selecting Specific Columns

To avoid messy layouts and keep data clean, list the exact columns you want to view, separated by commas.

SELECT name, role FROM employees;
💡 QA Tip: When testing, you only care about specific fields (e.g. usernames). Filter out junk system columns to focus better.

🧠 Quick Knowledge Check

What does the asterisk (*) stand for in the query: SELECT * FROM bugs;?

🔵 Intermediate Level: Filtering & Sorting

Now that we can fetch data, let's learn how to filter out unnecessary rows and sort our output. This is vital when validating search and sorting features in software.

💡 Analogy for Easy Understanding

Think of the WHERE clause as the **filter funnel icon** in Excel. Instead of scrolling through 10,000 rows to find one customer, you "filter" by a condition (like `country = 'India'`).

Lesson 1 The WHERE Clause (Filtering)

Use the WHERE clause to extract only records that match a strict criteria (like numbers, strings, or booleans).

SELECT * FROM employees WHERE salary > 50000;
Operator Meaning Example Use Case
= Equal to Find user with ID 5: WHERE id = 5
> / < Greater / Less than Find high-salary workers: WHERE salary > 60000
LIKE Pattern matching Names starting with 'A': WHERE name LIKE 'A%'

Lesson 2 ORDER BY (Sorting)

Use ORDER BY to sort your output alphabetically or numerically. Use DESC for descending (highest to lowest) or ASC for ascending.

SELECT * FROM employees ORDER BY salary DESC;
💡 QA Tip: Essential when testing eCommerce shopping carts to confirm the "Sort by Price" buttons are working correctly!

Lesson 3 The LIKE Operator (Wildcard search)

What if you only know part of a name? Use LIKE with the % wildcard (which stands for zero, one, or multiple characters).

SELECT * FROM employees WHERE name LIKE 'A%';
💡 QA Tip: Used to simulate global search bars when looking up a user record by partial email address (e.g. LIKE '%gmail.com').

🧠 Quick Knowledge Check

Which operator would you use to filter employees who make more than 50,000?

🟣 Advanced Level: Joins & Aggregations

Great progress! In real companies, data is split into multiple tables to keep it neat. Here we will learn how to do basic math calculations and link multiple tables together.

💡 Analogy for Easy Understanding

Think of a JOIN as linking two puzzle pieces. If the employees sheet has a column called `dept_id`, and the departments sheet has a column called `dept_id`, a JOIN matches these IDs to combine the information!

Lesson 1 Aggregate Functions (Calculations)

Sometimes you don't want to read thousands of rows; you just want a single calculated number. SQL provides built-in calculators: COUNT(), SUM(), AVG(), MAX(), and MIN().

SELECT COUNT(*) FROM bugs;
💡 QA Tip: If your web app dashboard says "5 open bugs", run this query to verify if the number matches the database!

Lesson 2 GROUP BY (Summarizing Data)

Use GROUP BY to group rows that have identical values together. It is always used alongside aggregate calculations to get clean counts.

SELECT severity, COUNT(*) FROM bugs GROUP BY severity;

Lesson 3 INNER JOIN (Linking Tables)

An INNER JOIN selects records that have matching keys in both tables.

SELECT employees.name, departments.dept_name FROM employees JOIN departments ON employees.dept_id = departments.dept_id;
💡 QA Tip: Very useful to confirm that a dropdown listing "Departments" is correctly mapped to employees in the backend!

🧠 Quick Knowledge Check

Which SQL aggregate function counts the total number of rows returned?

🔴 Expert Level: Real QA Use Cases

Welcome to the top tier! Here are realistic scenarios software testing teams execute daily to validate data integrity and find system defects.

QA Scenario 1 Bug Logger & Verification

Goal: Find which tester logged critical bugs so the developer can contact them for testing logs. We JOIN the `bugs` table with the `testers` table.

SELECT bugs.title, testers.name FROM bugs JOIN testers ON bugs.tester_id = testers.tester_id WHERE bugs.severity = 'Critical';

QA Scenario 2 Budget Threshold Check

Goal: Verify if employees assigned to high-budget projects match their expected payroll brackets. We join the employees and projects.

SELECT employees.name, projects.project_name, projects.budget FROM employees JOIN projects ON employees.project_id = projects.project_id WHERE projects.budget > 500000;

🧠 Final Knowledge Check

Why is SQL an essential skill for manual and automation QA engineers?

Available Mock Tables Click table to quick-preview data!

employees (id, name, role, salary, dept_id, project_id)
departments (dept_id, dept_name, location)
projects (project_id, project_name, budget)
testers (tester_id, name, experience_years)
bugs (bug_id, title, status, severity, tester_id)

Hands-On Practice Challenges

Completed: 0/5

Test your skills! Select a challenge below, write the correct SQL query in the terminal, and click Run Query to unlock achievements!

SQL Query Terminal

Result Set

Execute a query to fetch data from the mock database.

SQL Cheat Sheet

  • SELECT - Fetch data
  • WHERE - Filter records
  • ORDER BY - Sort results
  • GROUP BY - Aggregate data
  • LIMIT - Restrict row count
  • LIKE - Pattern matching

Interview QA Tips

WHERE vs HAVING

WHERE filters rows before aggregation, while HAVING filters groups after aggregation.

Primary vs Foreign Key

PK uniquely identifies a record. FK links to a PK in another table to establish table relationships.

INNER vs LEFT JOIN

INNER JOIN returns records that have matching values in both tables. LEFT JOIN returns all records from the left table, even with no matches.

QA Testing Use Cases

  • ✔ Validate Missing Data (NULLs)
  • ✔ Find Duplicate Records (GROUP BY)
  • ✔ Compare Expected vs Actual Output
  • ✔ Verify Database Constraints