# Module 7: SQL Clauses and Filtering

MODULE OVERVIEW

This module focuses on retrieving, filtering, sorting and organising data in
MySQL using SQL queries and clauses. Learners will explore SELECT queries, WHERE
conditions, ORDER BY, DISTINCT, AND, OR, LIKE and LIMIT.



The module also covers advanced querying techniques, including GROUP BY, HAVING,
UNION and UNION ALL.



These concepts help participants retrieve relevant business information, analyse
records based on specific conditions and prepare structured datasets for
reporting and decision-making.






WHAT WILL BE COVERED


7.1 SELECT QUERY

 * Understanding the purpose of the SELECT statement in MySQL.

 * Retrieving data from database tables.

 * Selecting specific columns from a table.

 * Retrieving all columns using the asterisk (*) operator.

 * Writing SQL queries to access relevant business information.

 * Using SELECT statements as the foundation for database reporting and
   analysis.


7.2 WHERE CLAUSE

 * Understanding the purpose of the WHERE clause.

 * Filtering records based on specified conditions.

 * Using comparison operators in SQL queries.

 * Retrieving records that meet particular business requirements.

 * Applying conditions to extract relevant information from large datasets.


7.3 ORDER BY

 * Understanding how ORDER BY works in MySQL.

 * Sorting query results in ascending order.

 * Sorting records in descending order.

 * Sorting data using one or more columns.

 * Organising business information for easier review and comparison.


7.4 DISTINCT

 * Understanding the purpose of the DISTINCT keyword.

 * Retrieving unique values from database columns.

 * Identifying and excluding duplicate values from query results.

 * Applying DISTINCT to multiple columns.

 * Preparing cleaner datasets for reporting and analysis.


7.5 AND / OR

 * Understanding logical operators in MySQL.

 * Using AND to combine multiple filtering conditions.

 * Applying OR to retrieve records that match alternative conditions.

 * Combining conditions within WHERE clauses.

 * Building queries to meet specific business data requirements.


7.6 LIKE

 * Understanding pattern matching in MySQL.

 * Using LIKE to search for specific text patterns.

 * Applying wildcard characters such as percentage (%) and underscore (_).

 * Finding records based on partial text matches.

 * Searching business records using names, descriptions and other text fields.


7.7 LIMIT

 * Understanding the purpose of the LIMIT clause.

 * Restricting the number of records returned by a query.

 * Retrieving a specific number of rows.

 * Using LIMIT with ORDER BY to identify selected records.

 * Managing query results when working with large datasets.


7.8 GROUP BY

 * Understanding the purpose of GROUP BY.

 * Grouping records based on one or more columns.

 * Organising similar records into groups.

 * Combining GROUP BY with aggregate functions.

 * Summarising business information by categories such as department, product or
   region.


7.9 HAVING

 * Understanding the difference between WHERE and HAVING.

 * Filtering grouped records using the HAVING clause.

 * Applying conditions to aggregated results.

 * Combining HAVING with GROUP BY.

 * Identifying business categories that meet specific performance or reporting
   conditions.


7.10 UNION

 * Understanding the purpose of the UNION operator.

 * Combining results from multiple SELECT queries.

 * Understanding the requirements for combining query results.

 * Removing duplicate rows from combined results.

 * Consolidating information from different tables or datasets.


7.11 UNION ALL

 * Understanding the purpose of UNION ALL.

 * Combining results from multiple SELECT queries.

 * Retaining duplicate records in combined results.

 * Understanding the difference between UNION and UNION ALL.

 * Choosing the appropriate operator for different data consolidation
   requirements.


SKILLS YOU WILL GAIN

 * Writing SELECT queries to retrieve database records.

 * Filtering data using WHERE conditions.

 * Sorting records using ORDER BY.

 * Identifying unique values using DISTINCT.

 * Combining multiple conditions using AND and OR.

 * Searching records using LIKE and wildcard characters.

 * Limiting query results using LIMIT.

 * Grouping records using GROUP BY.

 * Filtering grouped results using HAVING.

 * Combining query results using UNION and UNION ALL.


LEARNING OUTCOMES

By the end of this module, learners will be able to:

 * Retrieve relevant business information from MySQL databases using structured
   SELECT queries.

 * Filter customer, employee, product and transaction records based on specific
   business conditions.

 * Sort and organise query results to support reporting and data review
   activities.

 * Identify unique records and reduce duplicate values when preparing business
   datasets.

 * Combine multiple filtering conditions to extract information that meets
   specific operational requirements.

 * Search database records using partial text matches to locate relevant
   business information.

 * Group and summarise records to analyse business performance across
   departments, products and other categories.

 * Apply HAVING conditions to identify groups that meet specific reporting
   criteria.

 * Consolidate information from multiple query results using UNION and UNION
   ALL.

 * Develop structured SQL queries to support business reporting, data extraction
   and analysis.


CERTIFICATION ALIGNMENT

This module develops SQL querying, filtering and data analysis skills that
support the Oracle MySQL Database Administrator certification pathway. The
concepts covered help learners retrieve, organise, filter and consolidate
database information for practical business and reporting requirements.


CONTINUE TO THE NEXT MODULE

Continue to Module 8: MySQL Joins
[https://teamacademy.help.center/article/1370-module-8-mysql-joins] to learn how
to retrieve related information from multiple tables using INNER JOIN, OUTER
JOIN, LEFT JOIN, RIGHT JOIN, CROSS JOIN, SELF JOIN and other join operations.