You are on page 1of 1

6/21/23, 3:49 PM about:blank

SQL Cheat Sheet: Intermediate - LIKE, ORDER


BY, GROUP BY

Command Syntax Description Example


LIKE operator is used in a
WHERE clause to search for a
specified pattern in a column.
SELECT column1, column2, ... SELECT f_name , l_name FROM
LIKE There are two wildcards often
FROM table_name WHERE employees WHERE address LIKE
used in conjunction with the
columnN LIKE pattern; '%Elgin,IL%';
LIKE operator which are
percent sign(%) and
underscore sign (_).
The BETWEEN operator selects
values within a given range.
SELECT column_name(s) FROM The values can be numbers, SELECT * FROM employees
BETWEEN table_name WHERE column_name WHERE salary BETWEEN 40000
BETWEEN value1 AND value2; text, or dates. The BETWEEN AND 80000;
operator is inclusive: begin and
end values are included.
SELECT column1, column2, ... ORDER BY keyword is used to
ORDER sort the result-set in ascending SELECT f_name, l_name,
FROM table_name ORDER BY
dep_id FROM employees ORDER
BY column1, column2, ... or descending order. The BY dep_id DESC, l_name;
ASC|DESC; default is ascending.
SELECT column_name(s) FROM GROUP BY clause is used in
GROUP table_name WHERE condition collaboration with the SELECT dep_id, COUNT(*) FROM
BY GROUP BY column_name(s) SELECT statement to arrange employees GROUP BY dep_id;
ORDER BY column_name(s); identical data into groups.

Author(s)
Lakshmi Holla

Changelog
Date Version Changed by Change Description
2023-05-04 1.1 Benny Li Formatting changes
2021-07-28 1.0 Lakshmi Holla Initial Version

about:blank 1/1

You might also like