Question

In: Computer Science

I have a table of bike riders in the following format: Bike_number, Start_date(date and time), End_date(date,...

I have a table of bike riders in the following format:

Bike_number, Start_date(date and time), End_date(date, time)

I also have a table of temperatures per hour

Using sql: how do I calculate Count/min/max/average of riders as compared to the temperature at the hour

Solutions

Expert Solution

Assuming that for temperatures table, the hour is denoted by its start_time such that the table looks something like this -

The SQL query is -

select TO_CHAR(temperatures.Start_date, 'YYYY-MM-DD HH24:MI:SS') as start_time, temp, count(Bike_number)
from bike_riders, temperatures
where bike_riders.Start_date < (temperatures.Start_date + 1/24)
AND bike_riders.End_date > temperatures.Start_date
group by temperatures.Start_date, temp
order by temperatures.Start_date;

Here, all the bikers who started before the end of the hour and ended after the start of the hour are counted.

TO_CHAR() is used to format date.

Sample output -


Related Solutions

How would I structure the following PHP (PDO) code into a table format using only PHP?...
How would I structure the following PHP (PDO) code into a table format using only PHP? //Our SQL statement, which will select a list of tables from the current MySQL database. $sql = "SELECT * FROM jobs"; //Prepare our SQL statement, $statement = $pdo->prepare($sql); //Execute the statement. $statement->execute(); //Fetch the rows from our statement. $tables = $statement->fetchAll(PDO::FETCH_NUM); //Loop through our table names. foreach($tables as $table){ //Print the table name out onto the page. echo $table[0], ' '; echo $table[1], '...
Romeo and Juliet have a date at a given time, and each will arrive at the...
Romeo and Juliet have a date at a given time, and each will arrive at the meeting place with a delay between 0 and 1 hour, with all pairs of delay being equally likely. The first to arrive will wait for 15 minutes and will leave if the other has not yet arrived. What is the probability that they will meet?
This is what I have so far. The out print I am looking for is Date...
This is what I have so far. The out print I am looking for is Date is 7/22/2020 New month: 9 New day: 5 New Year: 2020 Date is 9/5/2020 #include    class Date {    public:        Date::Date(int dateMonth, int dateDay, int dateYear)        month{dateMonth}, day{dateDay}, int dateYear}{}               //void displayDate();         //set month        void Date::setMonth(std::int dateMonth){            month = dateMonth;        }        //retrieve month   ...
I have a python dictionary with the following format Key Type Value January str ['January 01...
I have a python dictionary with the following format Key Type Value January str ['January 01 2020', 'January 02 2019', 'January 03 2018'] June str ['June 04 2018', 'June 05 2018', 'June 06 2016] August str ['Augsut 07 2016', 'August 08 2016'] How do return the following conclusion with python code? January has the most day (1) in 2020 January has the most day (1) in 2019 June has the most days (2) in 2018 August has the most days...
Imagine a Book table that had the following: Book Table BookId Category Price Discount Publisher Date...
Imagine a Book table that had the following: Book Table BookId Category Price Discount Publisher Date Next, let's say you had to group by Publisher and Category while retrieving the total price and total number of rows within that grouping. 1. Write the SQL to figure out how many types of Publisher values and Category values there are. 2. How would you write an equation to demonstrate the number of groupings you would expect if you knew the exact number...
* I have already posted but they answered it incorrectly The contribution format income statement for...
* I have already posted but they answered it incorrectly The contribution format income statement for Huerra Company for last year is given below: Total Unit Sales $ 1,006,000 $ 50.30 Variable expenses 603,600 30.18 Contribution margin 402,400 20.12 Fixed expenses 322,400 16.12 Net operating income 80,000 4.00 Income taxes @ 40% 32,000 1.60 Net income $ 48,000 $ 2.40 The company had average operating assets of $507,000 during the year. Required: 1. Compute the company’s return on investment (ROI)...
Say I'm on a date. The probability of my date showing up on time for the...
Say I'm on a date. The probability of my date showing up on time for the first date is 0.5 (since possible outcomes are either “on time” or “not on time”, the probability of being “not on time” is 1 – P (on time) = 1 - 0.5 = 0.5). For the second date, the probability of the same person showing up on time is 0.90 if she was on time for the first date. However, this probability is only...
I                 You have a bike store. Your assets consist of $10,400 in inventory, $1,000 in equipment...
I                 You have a bike store. Your assets consist of $10,400 in inventory, $1,000 in equipment (phones, computers, etc.) and $600 cash. You are capitalized with $10,000 owners’ equity and $2,000 debt at 6%. Assume your only variable cost are the bikes you purchase from the manufacturer, $60/bike. Your fixed costs total $2500.                   During the year you purchased 250 bikes and sold them at $80/bike. But you only paid for half the bikes you bought; the rest were sold...
(C++) Write a program that prints a table in the following format given a "x" read...
(C++) Write a program that prints a table in the following format given a "x" read from the keyboard. For example, if x is 4, it prints out 0 0 1 1 2 4 3 9 4 16 To avoid mismatch, put 8 white spaces between two numbers.
Write a Java console application that reads a string for a date in the U.S. format...
Write a Java console application that reads a string for a date in the U.S. format MM/DD/YYYY and displays it in the European format DD.MM.YYYY  For example, if the input is 02/08/2017, your program should output 08.02.2017
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT