Filtering Rows+aggregate Functions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Important: in PostgreSQL

(the version of SQL we're


using), you must use sin-
gle quotes with WHERE
Get the names of people
whose names have 'r' as the
second letter.

select name from people


where name like '_r%'
Get the percentage of people who are no longer alive. Alias the result as percentage_dead.
Remember to use 100.0 and not 100!

SELECT COUNT(deathdate) * 100.0 / COUNT(*) AS percentage_dead FROM people

You might also like