Skip to content

Instantly share code, notes, and snippets.

@tim-br
Created July 13, 2015 19:50
Show Gist options
  • Save tim-br/35fac97ce4518b3c10c7 to your computer and use it in GitHub Desktop.
Save tim-br/35fac97ce4518b3c10c7 to your computer and use it in GitHub Desktop.
EXERCISE 1/2 are earlier versions of ex 3
EXERCISE 3.
select books.title, stock.retail, stock.stock, books.id AS BOOK_ID, editions.isbn, editions.publisher_id from books left join editions on books.id = editions.book_id left join stock on stock.isbn = editions.isbn where editions.publisher_id = 59;
EXERCISE 4.
select books.title, stock.retail, stock.stock, books.id AS BOOK_ID, editions.isbn, editions.publisher_id from books left join editions on books.id = editions.book_id left join stock on stock.isbn = editions.isbn where editions.publisher_id = 59 and stock.stock > 0;
EXERCISE 5.
select book_id, case when type='h' then 'hardcover' else 'paperback' end as type from editions;
EXERCISE 6
select books.title, editions.publication from books left join editions on editions.book_id=books.id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment