Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Exercise 1.
- 1. select Title, PubName from Book;
- 2. select * from Book where PagesNum = (select max(PagesNum) from Book);
- 3. select Author from Book group by Author having count(*) > 5;
- 4. select * from Book where PagesNum > (select avg(PagesNum) * 2 from Book);
- 5. select c1.CategoryName from Category c1 where exists(select * from Category c2 where c2.ParentCat = c1.CategoryName);
- 6. select Author, count(*) as CountOfBooks from Book group by Author order by CountOfBooks desc limit 1;
- 7. -
- 8. select b.* from Book b inner join Copy c group by b.ISBN having count(*) > 1;
- 9. select b.* from Book b where (select count(*) from Book b2 where b2.PubYear <= b.PubYear) < 10 order by b.PubYear;
- 10. -
- Exercise 2.
- 1. insert into Borrowing (ReaderNr, ISBN, CopyNumber, ReturnDate) select ID, 123456, 4, null from Reader where (LastName = 'Johnson' AND FirstName = 'John');
- 2. delete from Book where PubYear > 2000;
- 3. update Borrowing b, BookCat bc set ReturnDate = ReturnDate + interval 30 day where b.ReturnDate >= '20160101' and b.ISBN = bc.ISBN and bc.CategoryName = 'Databases';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement