SQL Quiz Sample - A
SQL Quiz Sample - A
Database Fundamentals
Write SQL statements
Q1. Display all the baskets, ingredients and their cost prices. Display
with the highest cost price first.
Select basket, ingredient, costprice
From Baskets, Ingredients
Order by 3 desc
Q3. Which basket has the highest sale price, and what is this price ?
Select basket, saleprice
From baskets
Where saleprice >= (select max(saleprice) from baskets);
Q5. Change the data in the baskets table so that the sale price is
increased by $1 for all baskets which are below the average
saleprice.
Update baskets
Set saleprice = saleprice + 1
300418 1|Page
SQL Quiz A – Sample
Database Fundamentals
Where saleprice < (sekect avg(saleprice) from baskets);
300418 2|Page
SQL Quiz A – Sample
Database Fundamentals
Q6. Find the number of girls who live in each suburb. Display with the
largest number first..
Select count(girl), suburb
From girls
Group by suburb
Order by 1 desc
Q7. Display the girls who like both tennis and reading Time magazine.
Select ls.girl
From likessport ls, likesreading lr
Where sport = “tennis”
And magazine = “Time”;
Q8. Find the girl, and the number of sports liked, by the girl who likes
the largest number of sports.
Select girl, count(sport) as numberofsports
From likessport
Group by girl
Having count(sport) >= all (select count(sport)
From likessport
Group by girl)
Order by 1;
Q9. Girls aged less than 19 are not allowed to like tennis. Change the
tables.
300418 3|Page
SQL Quiz A – Sample
Database Fundamentals
Delete from llikessport
Where sport = “tennis”
And girl in (select girl from girls where age < 19);
300418 4|Page