Git Product home page Git Product logo

sql-aggregate-functions-readme's Issues

Spelling Mistake

The second Objective has an extra 'r' in aggregate:
"Use the following aggregrate functions in SQL queries: average, sum, count, minimum, maximum"

Issue with Data Presented in Cats Table

The instruction states that for Lil' Bub you should make net_worth = 2,000,000
INSERT INTO cats (name, age, breed, net_worth) VALUES ("Lil' Bub", 2, "Tortoiseshell", 2000000);

But when confirming table the lesson shows Lil' Bub's network as 20,000,000
name age breed net_worth


Maru 3 Scottish Fold 1000000
Hana 1 Tabby 21800
Grumpy Cat 4 Persian 181600
Lil' Bub 2 Tortoiseshell 20000000

So there is an extra 0 in the net_worth for Lil'Bub, this throws off all calculations for that column

Asked to comment out Test Case because identical Output Not recognized by Test Case

I am attempting to finish a test case for a lab but despite identical
results the test case is giving errors. (test case on line 109 for the
sql lab)

I spoke with Ms. Kenlyn Terai @ 1/22/20 2:20 PM< EST and was asked to
comment out the test case and submit since the output was identical
but the error was still there.

I am enclosing the error along with the src

=begin
#selects_user_names_and_amounts_of_all_pledges_grouped_by_name_then_orders_them_by_the_summed_amount
(FAILED - 1)
#selects_the_category_names_and_pledge_amounts_of_all_pledges_in_the_music_category
#selects_the_category_name_and_the_sum_total_of_the_all_its_pledges_for_the_books_category

Failures:

  1. crowdfunder sql questions
    #selects_user_names_and_amounts_of_all_pledges_grouped_by_name_then_orders_them_by_the_summed_amount
    Failure/Error:
    expect(@db.execute(selects_user_names_and_amounts_of_all_pledges_grouped_by_name_then_orders_them_by_the_summed_amount)).to
    eq([["Iguana", 10],
    ["Swizzle", 12], ["Sirius", 19], ["Alex", 20], ["Marisa", 24],
    ["Voldemort", 34], ["Amanda", 40], ["Bear", 50], ["Hermione", 50],
    ["Rosey", 50], ["Pacha", 60], ["So
    phie", 60], ["Finnebar", 70], ["Franz", 90], ["Ena", 100], ["Whale",
    125.5], ["Katie", 170], ["Squid", 270], ["Albus", 470], ["Victoria",
    1700]])

    expected: [["Iguana", 10], ["Swizzle", 12], ["Sirius", 19],
    ["Alex", 20], ["Marisa", 24], ["Voldemort", 34], ["... ["Ena", 100],
    ["Whale", 125.5], ["Katie",
    170], ["Squid", 270], ["Albus", 470], ["Victoria", 1700]]D
    got: [["Iguana", 10], ["Swizzle", 12], ["Sirius", 19],
    ["Alex", 20], ["Marisa", 24], ["Voldemort", 34], ["... ["Ena", 100],
    ["Whale", 125.5], ["Katie",
    170], ["Squid", 270], ["Albus", 470], ["Victoria", 1700]]

    (compared using ==)

    ./spec/crowdfunder_spec.rb:110:in `block (3 levels) in <top (required)>'

Finished in 0.68723 seconds (files took 1.38 seconds to load)
22 examples, 1 failure

Failed examples:

rspec ./spec/crowdfunder_spec.rb:109 # crowdfunder sql questions
#selects_user_names_and_amounts_of_all_pledges_grouped_by_name_then_orders_them_by_the_summed_amount

=end

SRC:

CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT,
age INTEGER);

CREATE TABLE projects (
id INTEGER PRIMARY KEY,
title TEXT,
category TEXT,
funding_goal NUMERIC,
start_date TEXT,
end_date TEXT);

CREATE TABLE pledges (
id INTEGER PRIMARY KEY,
amount NUMERIC,
user_id INTEGER,
project_id INTEGER);

--

# Write your sql queries in this file in the appropriate method like the example below:
#
# def select_category_from_projects
# "SELECT category FROM projects;"
# end

# Make sure each ruby method returns a string containing a valid SQL statement.

def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title
=begin
SELECT  projects.title, SUM(amount) FROM projects JOIN pledges ON pledges.project_id=projects.id GROUP BY projects.id ORDER BY projects.title
=end
  "SELECT  projects.title, SUM(amount) FROM projects JOIN pledges ON pledges.project_id=projects.id GROUP BY projects.id ORDER BY projects.title"
end

def selects_the_user_name_age_and_pledge_amount_for_all_pledges_alphabetized_by_name
=begin
SELECT users.name, users.age, SUM(amount) FROM users JOIN pledges ON pledges.user_id= users.id GROUP BY users.id ORDER BY users.name
=end
  "SELECT users.name, users.age, SUM(amount) FROM users JOIN pledges ON pledges.user_id= users.id GROUP BY users.id ORDER BY users.name"
end

def selects_the_titles_and_amount_over_goal_of_all_projects_that_have_met_their_funding_goal
=begin
  SELECT  projects.title,  (SUM(amount) -projects.funding_goal) AS over_goal FROM projects JOIN pledges ON pledges.project_id=projects.id GROUP BY projects.id HAVING SUM(amount)> projects.funding_goal
=end
  "SELECT  projects.title,  (SUM(amount) -projects.funding_goal) AS over_goal FROM projects JOIN pledges ON pledges.project_id=projects.id GROUP BY projects.id HAVING SUM(amount)>= projects.funding_goal"

end

def selects_user_names_and_amounts_of_all_pledges_grouped_by_name_then_orders_them_by_the_summed_amount
=begin
SELECT users.name,  SUM(pledges.amount) AS total FROM users JOIN pledges ON pledges.user_id= users.id GROUP BY users.id ORDER BY total
=end
  "SELECT users.name,  SUM(pledges.amount) FROM users JOIN pledges ON users.id=pledges.user_id  GROUP BY users.id ORDER BY SUM(pledges.amount)"
end

def selects_the_category_names_and_pledge_amounts_of_all_pledges_in_the_music_category
=begin
SELECT projects.category, pledges.amount FROM pledges JOIN projects ON pledges.project_id=projects.id where projects.category="music"
=end
  "SELECT projects.category, pledges.amount FROM pledges JOIN projects ON pledges.project_id=projects.id where projects.category=\"music\""
end

def selects_the_category_name_and_the_sum_total_of_the_all_its_pledges_for_the_books_category
=begin
  SELECT projects.category, SUM(pledges.amount) FROM pledges JOIN projects ON pledges.project_id=projects.id GROUP BY projects.category HAVING projects.category="books"
=end
  "SELECT projects.category, SUM(pledges.amount) FROM pledges JOIN projects ON pledges.project_id=projects.id GROUP BY projects.category HAVING projects.category=\"books\""
end

and/or typo

Near Top of Lesson, under subtitle, "Aggregate Functions", this line is missing the / in the 'and or' .

"We'll craft queries that select a desired set of values from a table and then aggregate that data using the above aggregators, in addition to clauses that will group and or order the returned data based on various conditions."

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.