Skip to content
Advertisement

Tag: google-bigquery

Data cleaning in BigQuery: When session_id has both null and valid find_term, only keeping the records that have valid find_terms

I need some help cleaning my data. I have a table like below: session_id find_term 11111 null 11111 candy 11111 chocolate 22811 null 11145 null 333222 dark chocolate When session_id has both null and valid find_term, I want to keep the records that only have valid find_terms (eg: for session_id 11111, I want to exclude the first record when find_term

ROW type/constructor in BigQuery

Does BigQuery have the concept of a ROW, for example, similar to MySQL or Postgres or Oracle or Snowflake? I know it sort of implicitly uses it when doing an INSERT … VALUES (…) , for example: Each of the values would be implicitly be a ROW type of the Inventory table, but is this construction allowed elsewhere in BigQuery?

Extract data from JSON column

i want to extract a value from a json column. The schema is (- first level, — second level): Currently i extract a value this way: Is there a better way to handle the task? Answer Assuming that: event_params is an array of struct type. user_id is a unique key in each event_params Following code style would be possible: You

Nested array in a SQL query

I’m fairly new to programming and I’m struggling with an SQL Query. I want, that the purchased articles (article_id) are grouped in an array, so they are connected to the date column. For a further process, they might be combined ( so date x is combined with articles_id [A,B,C]) To make it clearer I want to show what I’ve done

How to find employee department changes?

I have a table that has the old departments and new departments of various employees: EmployeeID OldDept NewDept 123 Design Design 234 Software Engineering 345 Design Software 456 Advertising Software How can I create a table that looks like this: Dept TransfersIn TransfersOut Software 2 1 Design 0 1 Advertising 0 1 Engineering 1 0 Answer Use below if applied

selecting columns which are NOT of a specific type SQL

I want to select all the columns in BigQuery that are not of the type “TIMESTAMP”. I have written the query which returns such columns which is: But I am struggling to return data from only these columns in SQL, I have tried the following query which results in “Scalar subquery produced more than one element”. Can anyone please help

How to get the minimum value for a given time-period

I have a table with equipment failure and resolved date. Until the failure is resolved, entries for each day will show as failed. Once the issue is resolved data will start from the next failure date. Below is an example I want an output which will give me the first failure time for each resolved timestamp like I tried to

Join two SQL/BigQuery tables that do not contain the same columns

I have two queries that create two separate tables, pulling on several foreign keys. Simplified and using retail food as an example, Table 1 looks like this: Transaction ID City Store Item Description 12320 Boston Joe’s Shop 12305 Banana 12321 LA Bob’s Market 12306 Apple 12322 NY Suzy’s Corner Store 12307 Strawberry Table 2 looks like this: Transaction ID City

Advertisement