210128, 21:22
about blank
Skills
Network
SQL Cheat Sheet: Intermediate - LIKE, ORDER BY, GROUP BY
Command
LIKE
BETWEEN table_name WHERE colunn_nane
Syntax
SELECT column, colunn2, ...
FROM table_name WHERE
columnN LIKE pattern;
SELECT column_name(s) FROM
BETWEEN valuel AND value2;
SELECT colunnt, column2, ...
ORDER FROM table_name ORDER BY
BY colunnt, colunn2, ...
ASC |DESC;
SELECT column_name(s) FROM
GROUP SNe ce tours
colunn_nane(s)
SELECT column_name(s) FROM
table_nane GROUP BY
HAVING conunn_name(s) HAVING
condi
Author(s)
about blank
Description
LIKE operator is used in a
WHERE clause to search for a
specified pattern in a column,
Two wildcards often used in
conjunction with the LIKE
operator are percent sign(%)
and underscore sign (_),
depending upon the SQL
engine being used
The BETWEEN operator selects
values within a given range.
The values can be numbers,
text, or dates. The BETWEEN
operator is inclusive: begin and
end values are included.
ORDER BY keyword is used to
sort the result-set in ascending
or descending order. The
default is ascending. In case of
multiple columns in ORDER
BY, the sorting will be done in
the sequence of the appearance
of the arguments.
Group By clause is used in
Example
SELECT f_name , 1_name FROM
employees WHERE address LIKE
“xElgin, TL%"j
This command will output all
entries with Elgin, in the
Address.
SELECT * FROM enployees
WHERE salary BETWEEN e000
AND 80000;
This generates all records of
employees with salaries
between 40000 and 80000.
SELECT fname, 1_nane,
dep_id FROM enployees ‘ORDER
BY dep_id DESC, 1_nane
This displays the first name,
last name, and department [D
of employees, first sorted in
descending order of department
IDs and then sorted
alphabetically as per their last
names
SELECT dep_id, COUNT(*) FROM
employees GROUP BY dep_ids
collaboration with the SELECT This returns the department
statement to arrange data with
identical values into groups
HAVING clause is used in
conjunction with GRouP By
clause in collaboration with the
SELECT statement in order to
filter the data as per the given
IDs and the number of
employees in them, grouped by
the department IDs
SELECT dep_id, COUNT(*) FROM
employees GROUP BY dep_id;
This returns the department
IDs along with the number of
condition and then group as per employees in them, grouped by
identical values of a specified
parameter.
the department IDs.
12210128, 21:22
Lakshmi Holla
Abhishek Gagneja
Changelog
Date Version
2023-10-03 1.3
2023-10-01 1.2
2023-05-04 1.1
2021-07-28 1.0
about blank
about blank
Changed by Change Deseription
Steve Hord QA pass with edits
Abhishek Gagneja Updated the document
Benny Li Formatting changes
Lakshmi Holla Initial Version
22