Coder Social home page Coder Social logo

simple-sql-queries's Introduction

simple-sql-queries

For today we will be practicing inserting and querying data using SQL.

Here is a website that will let us write queries to interact with some data. http://jxs.me/chinook-web/

On the left are the Tables with their fields. The right is where we will be writing our queries. The bottom is where we will see our results.

Let's start with grabbing some data from the Artist table.

SELECT *
FROM Artist

This will select all the records and fields from the Artist table.

If we don't want to pull all the fields, we can be more specific in our SELECT statement

SELECT FirstName, LastName, Country
FROM Employee

If we want to put criteria on which records we pull, we use the WHERE statement.

SELECT Name, Composer, Milliseconds
FROM Track
WHERE Milliseconds > 299000

Now instead of displaying all the tracks that are over 299 seconds, we could us the count function to return only how many there are.

SELECT count(*)
FROM Track
WHERE Milliseconds > 299000

Now that we have some basic query examples. Let's try doing some more complicated ones. Use www.sqlteaching.com or sqlbolt.com as resources for the missing keywords you'll need.

  1. Find the average length of all tracks in Milliseconds
  2. Find the number of invoices in the USA
  3. Make a list of all the First Names of Customers that contain an 'a'
  4. Make a list of the 10 longest tracks
  5. Make a list of the 20 shortest tracks
  6. Find all the customers that live in California or Washington
  7. Find all the customers that live in California, Washington, Utah, Florida, or Arizona (Use IN keyword)
  8. Insert an artist to the database
  9. Insert yourself as a customer to the database
  10. Find a list of all Playlists that start with Classical
  11. You can either continue exploring this dataset or look into setting up postgres on your local machine.

Copyright

© DevMountain LLC, 2016. Unauthorized use and/or duplication of this material without express and written permission from DevMountain, LLC is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to DevMountain with appropriate and specific direction to the original content.

simple-sql-queries's People

Contributors

brackcarmony avatar jrobber avatar craig1123 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.