learn-co-curriculum / sql-aggregate-functions-readme Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
The second Objective has an extra 'r' in aggregate:
"Use the following aggregrate functions in SQL queries: average, sum, count, minimum, maximum"
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
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_categoryFailures:
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 failureFailed 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
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."
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.