Skip to content
Advertisement

Tag: count

MYSQL subquery results columns not as expected

I am trying to build a query that will build a output like this. The output that I go is this I was following the instructions here https://www.mysqltutorial.org/mysql-subquery/ My query is this What I was expecting to happen was the alias ‘patient appt’ to be populated with the data from the nested select statement. I was thinking this would work

Order count per ID and calculate time between orders in BigQuery

I am working with customer purchase data and am trying to write a query in Google BigQuery that sorts all purchases by date and adds a purchase/order count per customer (order_count). Also, I would like to calculate a time-delay (in days) between the orders of one customer (purchase_latency). My query currently looks like this: The result including “order_count” and “purchase_latency”

Advertisement