osama ezzat
osama ezzat

Reputation: 1

How to Group by hour in BigQuery

hi i'm trying to group the data by hour in big

enter image description here

so how can I group the data by the hour to count the orders per hour?

Upvotes: 0

Views: 325

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172974

Use below

select date, 
  extract(hour from parse_time('%I:%M:%S %p', time)) as hour,
  count(distinct order_id) as orders
from your_table
group by date, hour            

if applied to sample data in your question - output is

enter image description here

Upvotes: 1

Related Questions