+ 1

MySQL stuck at time...

This is the beginning of my code: At the end you can see the question I am stuck at... SET time_zone = 'America/New_York'; create database mileage; use mileage; create table fillups ( id int not null primary key auto_increment, date_time datetime, volume dec(7, 3), vehicle_id int, odometer int, mpg dec(7, 2), total_cost dec(7, 2), price_per_gal dec(7, 3), is_partial int, `restart` int ); — Write a SQL query that will show how many times gas was pumped for any given hour of the day that gas was pumped. SELECT cast (date_time as date), datepart (hour, date_time), count(1) [sales count] from fillups group by cast (date_time as date), datepart (hour, date_time) order by 1, 2; But of course it don’t work. I tried different things, but nothing really comes to mind how else I can do it. For any hints or suggestions I would really appreciate.

6th Apr 2020, 9:44 PM
Stef
Stef - avatar
3 Respostas
+ 1
What error are you seeing? Is the count per hour wrong, or does it not even run?
6th Apr 2020, 10:41 PM
Brian
Brian - avatar
0
SQL Error [1584] [42000]: incorrect parameters in the call to stored function ‘cast’
6th Apr 2020, 10:44 PM
Stef
Stef - avatar
0
so, I got this now.. select hour (date_time) as ‘hour’ from fillups group by ‘hour’ asc; yay, no i just need to count how many times per hour it happened. so I probably use COUNT(*) ???
7th Apr 2020, 3:23 PM
Stef
Stef - avatar