11 May 2022
→ %
represents 0, 1 or more characters
→ _
single character
SELECT * FROM table1
WHERE column1 LIKE 'A%'
Group rows that have identical data
name | salary |
---|---|
James | 20 |
James | 10 |
Paul | 5 |
SELECT name, sum(salary)
FROM company1
GROUP BY name
Result:
name | sum(salary) |
---|---|
James | 30 |
Paul | 5 |
WITH some_name AS (SELECT id, name)
SELECT * FROM table1
some_name
can be an existing table name (will override the table)
Places conditions on groups created by the GROUP BY clause.
name | salary |
---|---|
Paulina | 50 |
Janet | 10 |
Paulina | 30 |
SELECT name FROM table1
GROUP BY name
HAVING count(name) > 1
Result:
name |
---|
Paulina |
SELECT * FROM table1
LIMIT 20 OFFSET 3