Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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.


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;

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.

25 changes: 25 additions & 0 deletions years_to_hours.rb
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."

Choose a reason for hiding this comment

The 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.