Git Product home page Git Product logo

dsc-selecting-data-lab-seattle-ds-062419's Introduction

Selecting Data - Lab

Introduction

NASA wants to go to Mars! Before they build their rocket, NASA needs to track information about all of the planets in the Solar System. In this lab, you'll practice querying the database with various SELECT statements. This will include selecting different columns, and employ other SQL clauses like WHERE to return the data desired.

solar_system

Objectives

You will be able to:

  • Retrieve all the information from a table
  • Retrieve a subset of records from a table using a WHERE clause
  • Retrieve a subset of columns from a table

Connecting to the DataBase

To get started, connect to the database titled planets.db. Don't forget to also make a cursor so that you can later execute your queries.

#Your code here

Selecting Data

Here's an overview of the planet's table you'll be querying.

name color num_of_moons mass rings
Mercury gray 0 0.55 no
Venus yellow 0 0.82 no
Earth blue 1 1.00 no
Mars red 2 0.11 no
Jupiter orange 67 317.90 no
Saturn hazel 62 95.19 yes
Uranus light blue 27 14.54 yes
Neptune dark blue 14 17.15 yes

Write SQL queries for each of the statements below.

Select just the name and color of each planet

#Your code here
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
name color
0 Mercury gray
1 Venus yellow
2 Earth blue
3 Mars red
4 Jupiter orange
5 Saturn hazel
6 Uranus light blue
7 Neptune dark blue

Select all columns for each planet whose mass is greater than 1.00

#Your code here
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
id name color num_of_moons mass rings
0 5 Jupiter orange 68 317.90 0
1 6 Saturn hazel 62 95.19 1
2 7 Uranus light blue 27 14.54 1
3 8 Neptune dark blue 14 17.15 1

Select the name and mass of each planet whose mass is less than or equal to 1.00

#Your code here
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
name mass
0 Mercury 0.55
1 Venus 0.82
2 Earth 1.00
3 Mars 0.11

Select the name and color of each planet that has more than 10 moons

#Your code here
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
name color
0 Jupiter orange
1 Saturn hazel
2 Uranus light blue
3 Neptune dark blue

Select the planet that has at least one moon and a mass less than 1.00

#Your code here
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
id name color num_of_moons mass rings
0 3 Earth blue 1 1.00 0
1 4 Mars red 2 0.11 0

Select the name and color of planets that have a color of blue, light blue, or dark blue

#Your code here
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
name color
0 Earth blue
1 Uranus light blue
2 Neptune dark blue

Summary

Congratulations! NASA is one step closer to embarking upon its mission to Mars. In this lab, You practiced writing select statements that query a single table to get specific information. You also used other clauses and specified column names to cherry pick the data we wanted to retrieve.

dsc-selecting-data-lab-seattle-ds-062419's People

Contributors

cutterbuck avatar tkoar avatar peterbell avatar mathymitchell avatar fpolchow avatar loredirick avatar

Watchers

James Cloos 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.