{"id":20582984,"url":"https://github.com/vedanthv/sql","last_synced_at":"2026-03-19T16:32:02.425Z","repository":{"id":109181825,"uuid":"404324198","full_name":"vedanthv/SQL","owner":"vedanthv","description":"SQL Zoo Exercise Solutions and University Course Material Queries","archived":false,"fork":false,"pushed_at":"2021-10-15T05:26:26.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T12:47:23.360Z","etag":null,"topics":["sql"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vedanthv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-08T11:37:56.000Z","updated_at":"2021-10-15T05:26:28.000Z","dependencies_parsed_at":"2023-04-26T15:02:26.708Z","dependency_job_id":null,"html_url":"https://github.com/vedanthv/SQL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vedanthv/SQL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vedanthv%2FSQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vedanthv%2FSQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vedanthv%2FSQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vedanthv%2FSQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vedanthv","download_url":"https://codeload.github.com/vedanthv/SQL/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vedanthv%2FSQL/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30320886,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sql"],"created_at":"2024-11-16T06:37:40.201Z","updated_at":"2026-03-10T01:31:16.148Z","avatar_url":"https://github.com/vedanthv.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀SQL Practice from SQLZoo and University Course Material\n\nI've compiled the solutions to all of all 10 levels on the [SQL Zoo Tutorial](http://sqlzoo.net/wiki/SQL_Tutorial).  \n\n\n## SELECT basics\nSimple queries to get started.\n\n1. Introducing the world table of countries\n\n```sql\nSELECT population FROM world\n  WHERE name = 'Germany'\n```\n2. Scandinavia\n\n```sql\nSELECT name, population FROM world\n  WHERE name IN ('Sweden', 'Norway', 'Denmark');\n```\n\n3. Just the right size\n\n```sql\nSELECT name, area FROM world\n  WHERE area BETWEEN 200000 AND 250000\n  ```\n## Select Names\n\nSome pattern matching queries\n\n1. Find the country that start with Y\n\n```sql\nSELECT name FROM world\n  WHERE name LIKE 'Y%'\n  ```\n\n2. Find the countries that end with y\n\n```sql\nSELECT name FROM world\n  WHERE name LIKE '%Y' \n  ```\n\n3. Find the countries that contain the letter x\n\n```sql\nSELECT name FROM world\n  WHERE name LIKE '%x%'\n  ```\n\n4. Find the countries that end with land\n\n```sql\nSELECT name FROM world\n  WHERE name LIKE '%land'\n  ```\n\n5. Find the countries that start with C and end with ia\n\n```sql\nSELECT name FROM world\n  WHERE name LIKE 'C%' AND name LIKE '%ia' \n  ```\n\n6. Find the country that has oo in the name\n\n```sql\nSELECT name FROM world\n  WHERE name LIKE '%oo%'\n  ```\n\n7. FInd the Countries with Three or more `a` in name [TRICKY]\n\n```sql\nSELECT name FROM world\n  WHERE name LIKE '%a%a%a%';\n  ```\n\n8. Find the countries that have \"t\" as the second character.\n\n```sql\nSELECT name FROM world\n WHERE name LIKE '_t%'\nORDER BY name\n```\n\n9. Lesotho and Moldova both have two o characters separated by two other characters.\nFind the countries that have two \"o\" characters separated by two others.\n\n```sql\nSELECT name FROM world\n WHERE name LIKE '%o__o%'\n ```\n\n10. Find the countries that have exactly four characters.\n\n```sql\nSELECT name FROM world\n WHERE name LIKE '____'\n ```\n11. The capital of Luxembourg is Luxembourg. Show all the countries where the capital is the same as the name of the country\nFind the country where the name is the capital city.\n\n```sql\nSELECT name\n  FROM world\n WHERE name=capital\n ```\n\n12. Find the country where the capital is the country plus \"City\".[TRICKY]\n\n```sql\nSELECT name\n  FROM world\n WHERE capital = concat(name, ' City');\n ```\n\n13. Find the capital and the name where the capital includes the name of the country.\n**Tricky ATM will come back to it later!**\n\n14. Find the capital and the name where the capital is an extension of name of the country.\n**Tricky ATM will come back to it later!**\n\n15. Show the name and the extension where the capital is an extension of name of the country.\n**Tricky ATM will come back to it later!**\n\n## SELECT from WORLD Tutorial\n\nIn this tutorial you will use the SELECT command on the table world:\n\n1. Introduction\n\n```sql\nSELECT name, continent, population \n    FROM world\n```\n\n2. Large Countries\nShow the name for the countries that have a population of at least 200 million. 200 million is 200000000, there are eight zeros.\n\n```sql\nSELECT name FROM world\n    WHERE population \u003e 200000000\n```\n3. Per capita GDP\nGive the name and the per capita GDP for those countries with a population of at least 200 million.\n\n```sql\nSELECT name, gdp/population\nFROM world \nWHERE population \u003e 200000000\n```\n4. South America In millions\nShow the name and population in millions for the countries of the continent 'South America'. Divide the population by 1000000 to get population in millions.\n\n```sql\nselect name, population/1000000\nfrom world \nwhere continent = 'South America'\n```\n\n5. Show the name and population for France, Germany, Italy\n\n```sql\nselect name,population \nfrom world\nwhere name in ('France','Germany','Italy')\n```\n\n6. United\nShow the countries which have a name that includes the word 'United'\n\n```sql\nselect name\nfrom world \nwhere name like '%United%'\n```\n\n7. Two ways to be big: A country is big if it has an area of more than 3 million sq km or it has a population of more than 250 million.\nShow the countries that are big by area or big by population. Show name, population and area.\n\n```sql\nselect name,population, area\nfrom world\nwhere area \u003e 3000000 or population \u003e 250000000\n```\n\n8. Show the countries that are big by area (more than 3 million) or big by population (more than 250 million) but not both. Show name, population and area.\n\n```sql\nselect name, population, area \nfrom world\nwhere area \u003e 3000000 xor population \u003e 250000000\n```\n9. Rounding\nFor South America show population in millions and GDP in billions both to 2 decimal places.\n\n```sql\nselect name, ROUND(population/1000000,2), ROUND(gdp/1000000000, 2)\nfrom world\nwhere continent = 'South America'\n```\n\n10. Trillion dollar economies[Important]\nShow the name and per-capita GDP for those countries with a GDP of at least one trillion (1000000000000; that is 12 zeros). Round this value to the nearest 1000.\n**Show per-capita GDP for the trillion dollar countries to the nearest $1000.**\n\n```sql\nSELECT name, ROUND(gdp/population, -3)\nFROM world\nWHERE gdp \u003e 1000000000000;\n```\n\n11. Show the name and capital where the name and the capital have the same number of characters.\n\n```sql\nSELECT name, capital\nFROM world\nWHERE LENGTH(name) = LENGTH(capital)\n```\n\n12. Show the name and the capital where the first letters of each match. Don't include countries where the name and the capital are the same word.\n\n```sql\nSELECT name, capital\nFROM world\nWHERE LEFT(name,1) = LEFT(capital,1) \nAND name != capital;\n```\n\n13. Find the country that has all the vowels and no spaces in its name.\n\n```sql\nSELECT name\nFROM world\nWHERE name LIKE '%a%' \nAND name LIKE '%e%' \nAND name LIKE '%i%' \nAND name LIKE '%o%' \nAND name LIKE '%u%' \nAND name NOT LIKE '% %';\n```\n\n## SELECT from Nobel\n\n1. Winners from 1950\n\n```sql \nSELECT yr, subject, winner\nFROM nobel\n WHERE yr = 1950\n ```\n\n2. Show who won the 1962 prize for Literature.\n\n```sql\nSELECT winner\n  FROM nobel\n WHERE yr = 1962\n   AND subject = 'Literature'\n   ```\n\n3. Show the year and subject that won 'Albert Einstein' his prize.\n\n```sql\nSELECT yr, subject \nFROM nobel\nWHERE winner = 'Albert Einstein'\n```\n\n4. Give the name of the 'Peace' winners since the year 2000, including 2000.\n\n```sql\nSELECT winner \nFROM nobel\nWHERE yr \u003e= 2000 AND subject = 'Peace'\n```\n\n5. Show all details (yr, subject, winner) of the Literature prize winners for 1980 to 1989 inclusive.\n\n```sql\nSELECT * \nFROM nobel\nWHERE yr \u003e= 1980 AND yr \u003c= 1989 AND subject = 'Literature'\n```\n\n6. Show all details of the presidential winners:\n\n```sql\nSELECT * FROM nobel\n WHERE winner IN ('Theodore Roosevelt',\n                  'Woodrow Wilson',\n                  'Jimmy Carter',\n                  'Barack Obama')\n```\n\n7. Show the winners with first name John\n\n```sql\nSELECT winner\nFROM nobel\nWHERE winner LIKE 'John%'\n```\n\n8. Show the year, subject, and name of Physics winners for 1980 together with the Chemistry winners for 1984.\n\n```sql\nSELECT * \nFROM nobel\nWHERE yr = 1980 AND subject = 'Physics' \nOR yr = 1984 AND subject = 'Chemistry'\n```\n\n9. Show the year, subject, and name of winners for 1980 excluding Chemistry and Medicine\n\n```sql\nSELECT *\nFROM nobel\nWHERE yr = 1980 AND subject NOT IN ('Chemistry', 'Medicine')\n```\n\n10. Show year, subject, and name of people who won a 'Medicine' prize in an early year (before 1910, not including 1910) together with winners of a 'Literature' prize in a later year (after 2004, including 2004)\n\n```sql\nSELECT * \nFROM nobel\nWHERE yr \u003c 1910 AND subject = 'Medicine' OR yr \u003e= 2004 AND subject = 'Literature'\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvedanthv%2Fsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvedanthv%2Fsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvedanthv%2Fsql/lists"}