Skip to content
Advertisement

Tag: google-bigquery

BigQuery: need a clever solution for a difficult query

The context of this problem is a Live Chat service. Each conversation consists of multiple messages of which the timestamp is registred. Conversations are held in one or more channels, depending on the difficulty of the inquiry. The picture below shows an example of the data. For testing purposes the sheet can be found here. In the picture you see

Aggregrate the variable from timestamp on bigQuery

I am planning to calculate the most frequency part_of_day for each of the user. In this case, firstly, I encoded timestamp with part_of_day, then aggregrate with the most frequency part_of_day. I use the ARRAY_AGG to calculate the mode (). However, I’m not sure how to deal with timestamp with the ARRAY_AGG, because there is error, so my code structure might

SQL return max in unnest

I have the following query: What should I do if I only want the query to return one array.col1 per row in table_a (let’s say I want only the max value for each case)? Answer You can use a subquery:

Group rows based on column values in SQL / BigQuery

Is it possible to “group” rows within BigQuery/SQL depending on column values? Let’s say I want to assign a string/id for all rows between stream_start_init and stream_start and then do the same for the rows between stream_resume and the last stream_ad. The amount of stream_ad event can differ hence I can’t use a RANK() or ROW() to group them be

Calculating average time (in days) between customer first and second order on BigQuery

I’m trying to figure out the avg days it takes for a customer to repeat purchase. Here is what I have It’s returning this I want to now get the average days between all first and second purchases, then second and third et Sample data set |———————|——————|——————|——————| | Email_address | Order_name | Order_number | Date | |———————|——————|——————|——————| | test@test.com |

Left join matching between dates

I am trying to pair the date of a national holiday with time bucket boundaries. I would like to left join against buckets. So I can identify if a holiday falls within a certain time frame has_holiday. With the following query, I receive a Query error: Query error: LEFT OUTER JOIN cannot be used without a condition that is an

Advertisement