Here is a toy example: select * from( select 1 as row_num,298807 as id1,104 as id2,’2018-07-10′ as date union all select 2,298807,104,’2018-08-02′ union all select 3,298807,104,’2018-08-06′ union all …
Tag: google-bigquery
Finding the overall data from specific date using bigquery
I am creating a query using bigquery that will calculate the overall number of data within 5 days from a specific date for each ID. So far I managed to get the result where the result return the data for each day (day 1 until 5), which means there are 5 dates in the result. However, what I want is
Determining Where Date Ranks | BigQuery
I have purchase data that I’m trying to analyze. I’m attempting to find the 2nd and 3rd purchases (and potentially 4, 5, etc.) for each user. The data I have currently looks like this: The first order column is looking at what was in the first basket that the customer purchased. Is there a way I can create another column
Left join only on first row
I have the following sample query: and I’d like the following output I read many questions on the similar topic but I wasn’t able to make it work. Answer You can use row_number():
Combine / Join SQL queries
I have a query which gets data from a JSON document, checks which values have been returned and then returns that count. As part of this query, I’d like to also return cat_name, dog_name and add a WHERE pet_store = ‘london’ I’m not sure exactly where I’m suppose to add the other parameters or if I should join the subquery?
Count number of values in SQL query / bigquery
I have a query which extracts some data from a JSON document and I have a query that based on the number of values returned displays an overall column count. I can’t seem to work out how to combine these into a single query? assume that I need to use a sub-query but not sure where to go from here?
Defining a subtable and then query from that table using SQL
I have a table with many columns, and I want to count the unique values of each column. I know that I can do Here sho is the table and sho_01,…. are the individual columns. This is BigQuery by the way, so they use UNION ALL. Next, I want to do the same thing, but for a subset of sho,
Unrecognized name: error in nested query using bigquery standard sql
I am running the query where the inner statement (in this case I use when..case) and it is expected to run the query from the outer statement’s result. But, the result from the outer statement is in string datatype , so I added “as INT64” to solve this. However, the query still throw error “Unrecognized name: (score at [12:33]” Code:
How to group distinct values and calculate fields in one SQL query
This is only my second time using Stack Overflow so I’m open to any constructive criticism on how to better format my questions. I have a list of orders and I’m wanting to create a table of useful customer information. I’ve created a new table that identifies unique customers (using just a select distinct of customer IDs) but I’m not
Return the highest count record
The data I am working on looks like below- A_ID B_ID count 123 abcd 1000 123 aaaa 2000 123 aaaa 3000 456 null …