Last active
January 18, 2016 13:59
-
-
Save cthoyt/bc262c07df6da9e6e345 to your computer and use it in GitHub Desktop.
Biological Databases Practical 2016 Day 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* How many countries exist */ | |
select count(*) as num_countries | |
from country; | |
/* Select the first 10 countries and order them by name */ | |
select * | |
from country | |
order by country.Name | |
limit 10; | |
/* How many countries exists per Contitent */ | |
select country.Continent, count(country.Code) | |
from country | |
group by country.Continent; | |
/* What is the min,max,average and standard deviation surface area of all country. */ | |
select min(country.SurfaceArea), max(country.SurfaceArea), avg(country.SurfaceArea), std(country.SurfaceArea) | |
from country; | |
/* How many languages exists per country */ | |
select country.Name, count(countryLanguage.Language) | |
from country | |
join countryLanguage on (country.Code = countryLanguage.CountryCode) | |
group by country.Name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
alternatively the second query could be construed as select 10, then order. Depending on the use case, this statement could be written as