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?
For the following MIPS instructions, (1) show its format or type (I-format, R- format, or J-...
For the following MIPS instructions, (1) show its format or type (I-format, R- format, or J- format); (2) translate them into binary using the follow procedure (Note: $s0-$s7 are the 16-23th registers, $t0-$t7 are the 8-15th registers). For example, addi    $s0, $s1, 2               # the op code of addi is 0010002 Format (?): lw       $s1, 4($s1)               # the op code of lw is 1000112 Format (?): bne     $s1, $t1, loop           # the value of loop here is...
Can someone show me how this is supposed to look in a table format. I want...
Can someone show me how this is supposed to look in a table format. I want to double check that I'm formatting and doing the numbers properly. Thank you! Timber Construction constructs furniture.  They’ve decided they need to layout out their budgets for the first Quarter of 2019 to see if they will make a profit and have cash for a future expansion that will cost $400,000. They always must keep $100,000 minimum in the checking account every month.  (Assume the beginning...
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...
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 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)...
(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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT