-
Couldn't load subscription status.
- Fork 0
Submit SQL and Ruby assignment #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,12 @@ SELECT with JOIN practice: | |
| Join the OrderDetails and Products tables, to show a report where the columns are OrderID, ProductName, and Quantity. | ||
| Paste the SQL statement you used below. | ||
|
|
||
| SELECT od.OrderID, prod.ProductName, od.Quantity FROM OrderDetails od INNER JOIN Products prod ON od.ProductID = prod.ProductID; | ||
|
|
||
| Join the Orders, OrderDetails, and Employees tables to return a report with with the EmployeeName, ProductID, and Quantity. | ||
| Paste the SQL statement you used below. Hint: EmployeeName is not a column in the Employee table, but you can generate a | ||
| report with EmployeeName by starting your SQL this way: SELECT (Employees.FirstName || " " || Employees.LastName) AS EmployeeName, | ||
|
|
||
|
|
||
| SELECT (e.FirstName || " " || e.LastName) AS EmployeeName, od.ProductID, od.Quantity FROM Orders o | ||
| INNER JOIN OrderDetails od ON o.OrderID = od.OrderID | ||
| INNER JOIN Employees e ON o.EmployeeID = e.EmployeeID; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is very well done. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #Write a program which asks the user for a number of years, and then prints out how many hours are in that many years. | ||
| puts "Enter a number of years" | ||
| years = gets.chomp # this returns a string | ||
| years = years.to_i # this converts a string to an integer | ||
| hours = years * 365 * 24 | ||
| puts "That's #{hours} hours." | ||
|
|
||
| #Then it asks for a number of decades, and prints out the number of minutes are in that many decades. | ||
| def years_to_days(years) | ||
| leap_years = years/4 | ||
| leap_years * 366 + (years - leap_years) * 365 | ||
| end | ||
|
|
||
| puts "Enter a number of decades" | ||
| decades = gets.chomp | ||
| decades = decades.to_i | ||
| minutes = years_to_days(decades * 10) * 24 * 60 | ||
| puts "That's #{minutes} minutes in #{decades} decades." | ||
|
|
||
| #Then it asks for the user's age, and prints out the number of seconds old the user is. Call this program years_to_hours.rb. | ||
| puts "Enter your age" | ||
| age = gets.chomp | ||
| age = age.to_i | ||
| seconds = years_to_days(age) * 24 * 60 * 60 | ||
| puts "You're #{seconds} seconds old." | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is pretty well done. John mentioned that he mistakenly asked you all to worry about leap years too. So you came up with a solution to that when you shouldn't have needed too. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very well done.