Documente Academic
Documente Profesional
Documente Cultură
Database Fundamentals
Q3. Which basket has the highest sale price, and what is this price ?
Select basket, saleprice
From baskets
Where saleprice >= all (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.
300418 1|Page
SQL Quiz B – Sample
Database Fundamentals
Update baskets
Set saleprice = saleprice + 1
Where saleprice < (select avg(saleprice) from baskets);
300418 2|Page
SQL Quiz B – Sample
Database Fundamentals
Q6. Find the number of people who like each magazine. Display with
the largest number first.
Select count(person), magazine
From likesreading
Group by magazine
Order by 1 desc, 2;
Q7. Display the people who like both football and reading Time
magazine.
Select ls.person
From likesport ls, likesreading lr
Where ls.person = lr.person
And sport = “football”
And magazine = “time”;
Q8. Find the person, and the number of sports liked, by the person
who likes the largest number of sports.
Select person, count(sport)
From likessport
Group by person
Having count(sport) >= all (select count(sport) from likessport group by
person);
Q9. People who read Time magazine are not allowed to like football.
Change the tables.
Delete from likessport
Where sport = “football”
300418 3|Page
SQL Quiz B – Sample
Database Fundamentals
And person in (select person from likesreading
Where magazine = “time”);
300418 4|Page