GithubHelp home page GithubHelp logo

sql_countrybase's Introduction

Countrybase

Here are the eight most populous countries in the world:

Id Name Area Population Source
18 India 3,287,240 1,348,834,400 Based on 2011 census
27 Bangladesh 143,998 166,774,136
34 Pakistan 803,940 205,095,217 Official population clock
42 Nigeria 923,768 200,962,000 UN projection
46 United States 9,833,517 329,424,894 Official population clock
54 Brazil 8,515,767 210,076,263
59 China 9,640,821 1,397,906,480 Official estimate
60 Indonesia 1,904,569 268,074,600 Official annual projection
  1. Using your favorite DB client, design and create a database table called countries that would store the information presented above (create a database first if you don’t have any existing ones to play with). Don’t bother with creating any keys or indices for now, just create the five columns. Copy and paste the SQL query generated by the client below (it should start with create table or something similar; if it is difficult to find the query generated by your client, ask for assistance):

    CREATE TABLE ...
    
  2. Manually create a query or a series of queries that would fill the table with the information above. Put the query/queries below:

    ... here goes your SQL ...
    
  3. Create a query that would return everything from the table:

    ... here goes your SQL ...
    
  4. Create a query that would return a single row: the country with the ID of 46.

    ... here goes your SQL ...
    
  5. Create a query that would return the four countries with the following IDs: 18, 34, 54, 59.

    ... here goes your SQL ...
    
  6. Create a query that would return all the countries except the country with the ID of 27 (Bangladesh).

    ... here goes your SQL ...
    
  7. Create a query that would select the names and sources for the countries whose area is over 1,000,000 km2:

    ... here goes your SQL ...
    
  8. Create a query that would select the IDs of the countries with missing sources:

    ... here goes your SQL ...
    
  9. Create a query that would return the area, population, and population density (a computed column aliased density) of every country that has a source.

    ... here goes your SQL ...
    
  10. Create a query that would return the list of all sources, without repetition:

    ... here goes your SQL ...
    
  11. Create a query that would select the countries whose source is official (starting with Official) or the area is below 1,000,000 km2:

    ... here goes your SQL ...
    
  12. Create a query that would select the countries whose source is official (starting with Official) and the area is below 1,000,000 km2:

    ... here goes your SQL ...
    
  13. Create a query that would select all the countries except those whose source is official (starting with Official):

    ... here goes your SQL ...
    
  14. Create a query that would select the countries whose names start with an N, O, P, ..., X, Y, or Z:

    ... here goes your SQL ...
    
  15. Create a query that would return all the countries sorted by their name alphabetically:

    ... here goes your SQL ...
    
  16. Create a query that would return the population density figures of the countries sorted in the descending order. The column should be aliased density.

    ... here goes your SQL ...
    
  17. Create a query that would return the countries sorted by their source alphabetically, and then (if two or more countries share the same source) by their name in the reverse alphabetical order:

    ... here goes your SQL ...
    
  18. Set all sources to NULL:

    ... here goes your SQL ...
    
  19. Update the sources for the countries with the population over 1,000,000,000 to Official:

    ... here goes your SQL ...
    
  20. Multiply the area by 100 and add 10 to the population for every country whose ID is greater than 50:

    ... here goes your SQL ...
    
  21. Delete from the table every country whose population is less than 300,000,000:

    ... here goes your SQL ...
    
  22. Delete all countries from the table:

    ... here goes your SQL ...
    

Don’t forget to create a pull request.

sql_countrybase's People

Contributors

danmysak avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.