diff --git a/sql.txt b/sql.txt index 5351a54..435e81f 100644 --- a/sql.txt +++ b/sql.txt @@ -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; diff --git a/years_to_hours.rb b/years_to_hours.rb new file mode 100644 index 0000000..2f51baa --- /dev/null +++ b/years_to_hours.rb @@ -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."