Skip to content

Instantly share code, notes, and snippets.

@monapasan
Created July 19, 2015 12:07
Show Gist options
  • Save monapasan/6322f5c23b467c558028 to your computer and use it in GitHub Desktop.
Save monapasan/6322f5c23b467c558028 to your computer and use it in GitHub Desktop.
select name from (select t.band_id from
(
(select h.tour_id from held_in h, cities c where h.city_id=h.city_id and c.name='Yakutsk') as help
natural join tour t)
) as help2
natural join band
select name from band natural join song where title='Kiss me'
select name from tour natural join cities c where c.name='Berlin'
select co.name from country co, cities c where c.name in ('Yakutsk', 'Berlin') and c.country_id=co.country_id
select * from band b where exists (select * from song s where b.band_id=s.band_id)
select co.name, count(c.country_id) as "Anzahl der Städte"
from country co join cities c
on c.country_id=co.country_id
group by co.name
select b.name, count(s.song_id) as "Anzahl der Songs"
from band b join song s
on s.band_id=b.band_id
group by b.name
select t.name, count(h.city_id) as "Anzahl der Städte im Tour"
from tour t, held_in h where h.tour_id=t.tour_id group by t.name having count(h.city_id) >= 2
select a.name from album a, band b, song s where s.album_id=a.album_id and s.band_id = b.band_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment