Page 173 - SQL
P. 173
DB2
SELECT * FROM TableName WITH UR;
where UR stands for "uncommitted read".
If used on table that has record modifications going on might have unpredictable results.
Select distinct (unique values only)
SELECT DISTINCT ContinentCode
FROM Countries;
This query will return all DISTINCT (unique, different) values from ContinentCode column from
Countries table
ContinentCode
OC
EU
AS
NA
AF
SQLFiddle Demo
Select with condition of multiple values from column
SELECT * FROM Cars WHERE status IN ( 'Waiting', 'Working' )
This is semantically equivalent to
SELECT * FROM Cars WHERE ( status = 'Waiting' OR status = 'Working' )
i.e. value IN ( <value list> ) is a shorthand for disjunction (logical OR).
Get aggregated result for row groups
Counting rows based on a specific column value:
SELECT category, COUNT(*) AS item_count
FROM item
GROUP BY category;
https://riptutorial.com/ 155

