Skip to content

Tag: google-bigquery

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 all…

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 wo…

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…

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 Advertis…

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…

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 li…