SQL EXERCICE 2

Find the number of girls who were named Lillian for the full span of time of the database.

SELECT year, number
FROM babies
WHERE name = 'Lillian' AND gender = 'F'; 

Find 20 distinct names that start with ‘S’.

SELECT DISTINCT name
FROM babies
WHERE name LIKE 'S%'
LIMIT 20;

What are the top 10 names in 1880?

SELECT name, gender, number
FROM babies
WHERE year = 1880
ORDER BY number DESC
LIMIT 10 ;

Return all the restaurants that are Japanese and $$

SELECT *
 FROM nomnom
 WHERE cuisine = 'Japanese'
 AND price = "$$";

Your roommate Bevers can’t remember the exact name of a restaurant he went to but he knows it contains the word ‘noodle’ in it.

Can you find it for him using a query?

 SELECT *
 FROM nomnom
 WHERE name LIKE '%noodle%';

Find the restaurants that have empty health values.

SELECT *
FROM nomnom
WHERE health IS NULL;

Order the table by title (from A-Z).

 SELECT title, publisher
 FROM news
 ORDER BY title ASC;

Which article names have the word 'bitcoin' in it?

 SELECT *
 FROM news
 WHERE title LIKE '%bitcoin%';

What are the 20 business articles published most recently?

 SELECT *
 FROM news
 WHERE category = "b" 
 ORDER BY timestamp DESC
 LIMIT 20;