I have the following table: I’m using this query to get the above result: However, I would like to combine both rows in a single one, something like this: How am I able to output this in Google SQL? I’m new to SQL world, happy if you could help me out 🙂 Thanks in advance for the assistance. Answer Just
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
Big Query Deduplication of rows with nested data
If having a table looking like this: last_updated, uuid, headline, topics 2020-01-01, abc123, “BigQuery is nice”, [‘big query’, ‘data warehousing’, ‘trouble’] 2020-01-02, abc123, “…
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
Order string_agg over partition | BigQuery
Here’s the piece of my query in question: string_agg(product_type, “|” order by product_type desc) over(partition by email, processed_date) as full_basket I’m having issues with ordering my …
Select rows where array contains one of several values in bigquery (ideally with dbplyr)
I have a large set of tweets on bigquery and now want to filter those that contain at least one of a list of hashtags. The hashtags are saved in an array column (uploaded from a list column in R). How can I select rows that contain one of multiple values in any place in that array? Below the code
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