GithubHelp home page GithubHelp logo

taevonlewis / booktown Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sei-r-10-5/booktown

0.0 0.0 0.0 367 KB

Queries upon queries in Booktown, USA [sql, databases]

License: Other

TSQL 100.00%

booktown's Introduction

Booktown, USA

For each question below, find the approriate SQL query to obtain the information requested. Put all your answers in the solutions.txt file.

Getting Started

To get started we'll need to import the booktown.sql file.

  1. Fork and clone this repository
  2. cd into the repository
  3. use the command psql -f booktown.sql
  4. type psql to open your psql console
  5. type \list to ensure the booktown database was successfully completed
  6. type \c booktown to connect to the booktown database
  7. type \d to see a list of all the tables in the booktown database
  8. type \d [TABLE_NAME] to see information about columns and their types for a specific table. You should see output like below:
booktown=# \d books
       Table "public.books"
   Column   |  Type   | Modifiers 
------------+---------+-----------
 id         | integer | not null
 title      | text    | not null
 author_id  | integer | 
 subject_id | integer | 
Indexes:
    "books_id_pkey" PRIMARY KEY, btree (id)
    "books_title_idx" btree (title)

Queries

Complete the following exercises to practice using SQL.

Order

  1. Find all subjects sorted by subject
  2. Find all subjects sorted by location

Where

  1. Find the book "Little Women"
  2. Find all books containing the word "Python"
  3. Find all subjects with the location "Main St" sort them by subject

Joins

  1. Find all books about Computers and list ONLY the book titles
  2. Find all books and display a result table with ONLY the following columns
    • Book title
    • Author's first name
    • Author's last name
    • Book subject
  3. Find all books that are listed in the stock table
    • Sort them by retail price (most expensive first)
    • Display ONLY: title and price
  4. Find the book "Dune" and display ONLY the following columns
    • Book title
    • ISBN number
    • Publisher name
    • Retail price
  5. Find all shipments sorted by ship date display a result table with ONLY the following columns:
    • Customer first name
    • Customer last name
    • ship date
    • book title

Grouping and Counting

  1. Get the COUNT of all books
  2. Get the COUNT of all Locations
  3. Get the COUNT of each unique location in the subjects table. Display the count and the location name. (hint: requires GROUP BY).
  4. List all books. Display the book_id, title, and a count of how many editions each book has. (hint: requires GROUP BY and JOIN)

YAY! You're done!!


Licensing

  1. All content is licensed under a CC-BY-NC-SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].

booktown's People

Contributors

bhague1281 avatar geluso avatar 009kings avatar connorjclark avatar taylordarneille avatar brandiw 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.