Skip to content

Tag: google-bigquery

Extract date from a column

How to extract date from a string like ‘2:24 PM 6-20-2021’? For example, I have a column called Dates (datatype ‘String’) in the table like below – The output should be Answer How to extract date from a string? If you want to extract date as a date type so you will be able then t…

Combine 2 sql queries in Bigquery

I currently have two queries that i’ve stitched together using views in Bigquery. I am wondering if there’s a way to combine them into a single query and eliminate the need for multiple views. The first query concatenates a few strings to create a field “id” The second query de-dupes t…

Split large texts into chunks in separate rows

I have a table, where some texts are atrociously big. I want to make sure every row in the query output does not exceed, say, 100.000 characters. How do I do that? Here is a quick sample: Let’s say I want output text column to be less than 10 characters. So, I need this result: It would be even better

How to convert X items into array and looping

I have a table with 100k records. I want to create an array for each 10k items and loop this, i.e. first 10k items-> array(first 10k items), then seconds array(10k different items), then third and so on. In other words, each array contains 10k different records. This is what I tried: This is the error I ge…

Counting unique values within a time window

I have data that looks like (over 100.000 rows): What I would like: Explanation CONTEXT I want to find out how many people (person) are working in the same location (Location) by looking at a time window (timestamp) of max 10 minutes and checking whether a person is really working simultaneously or just takin…