Skip to content
Advertisement

Tag: google-bigquery

Add one year to age based on date BigQuery

I have a table containing birthday information: I’m trying to calculate the current age but only want to add on a year when the date is 12-01. For example the first row was born in June, 2016. The current age should be 3.5 and come Dec 1, 2020 the age would increase to 4.5. So I only want it to

Big Query – Transpose array/json objects into columns

This question is a continuation of these two: Big Query – Transpose arrays into colums Big Query – Transpose Specific fields into Columns We have a table in Big Query like below. Input table: Note: All the values in the Answer column are stringified values and the Arrays / JSON objects are dynamic. We want to convert the above table

Issues with GROUP BY and NULL (SQL / BigQuery)

I have some bad data that I need to transform a bit and am struggling to do. Below is example data and desired output. What I’m hoping for is if PUNCHIN is NULL, but there is another value of PUNCHIN for that EmployeeNum and APPLY_DATE, then use the other value. Otherwise, use SHIFTSTARTTIME. And the same goes for PUNCHOUT and

SQL: Return Column Name With Highest Value From Subquery

Working with a large data set in Big Query that assigns a specific grade to an item. For example: To summarize these, I wrote out some COUNT & CASE functions, like: It results in something like below: I have been attempting to have this computation happen in a subquery, and then use the alp_a or org_a to populate in a

De-duplicate rows in GCP Big Query (SQL) based on two columns [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 2 years ago. Improve this question I’m trying to output all columns while have certain rows de-duplicated. Everything I’ve

fetch the data from array of objects sql BigQuery

I need to fetch key value pairs from the second object in array. Also, need to create new columns with the fetched data. I am only interested in the second object, some arrays have 3 objects, some have 4 etc. The data looks like this: The desired output: Answer Below is for BigQuery Standard SQL if applied to sample data

Advertisement