Databases Reference
In-Depth Information
Placeholder wildcard:
SELECT ... FROM ...
WHERE Column1 LIKE '_BC_EF'
Criteria using parentheses to designate order:
SELECT ... FROM ...
WHERE
(Column1 LIKE 'ABC%' AND Column2 LIKE '%XYZ')
OR
Column3 = '123'
GROUP BY
All nonaggregated columns in the SELECT list must be included in the GROUP BY list:
SELECT COUNT(Column1), Column2, Column3
FROM ... WHERE ...
GROUP BY Column2, Column3
Designating order:
SELECT COUNT(Column1), Column2, Column3
FROM ... WHERE ...
GROUP BY Column2, Column3
ORDER BY Column2 DESC, Column3 ASC
HAVING
Filter results based on values available after the aggregations and groupings are performed:
SELECT COUNT(Column1), Column2, Column3
FROM ... WHERE ...
GROUP BY Column2, Column3
HAVING COUNT(Column1) > 5
UNION
Combine multiple results with the same column count:
SELECT Column1, Column2 FROM table1_name
UNION
SELECT Column1, Column2 FROM table2_name
Combine literal values and query results:
SELECT -1 AS Column1, 'A literal value' AS Column2
UNION
SELECT Column1, Column2 FROM table1_name
Search WWH ::




Custom Search