Skip to content
Advertisement

Tag: google-bigquery

Create a Month function

I would like to run a query that runs monthly but it will check daily if the timestamp from the records is from the previous month. If yes then it will run the query and append to the previous monthly data. So, I want to create a simple function to return TRUE if the RecordTimestamp is from the previous month.

Translating Oracle Date Functions to BigQuery

I’m having trouble translating these Oracle date functions to BigQuery because BigQuery doesn’t allow such user-friendly additions to dates/timestamps. Any help is appreciated. Below are the two date functions in Oracle and my attempted (failed) versions in BigQuery: Oracle: BigQuery attempt: Answer You can use below for the first one and for second – try below

Remove duplicated rows with same Timestamp but different values

I have “duplicated” rows in Bigquery and I need to keep just the last occurrence grouped by id of element. As you can see, these are not duplicated rows, those are duplicated Timestamps with different values. I need to keep one registry per Timestamp. I run this query to get the example: Table with data example: Answer In your sample

Using SQL result as a filter for another query

Here’s my code and there’s a thousand transaction_no result. Which is I have to use as a filter for another code with the same table. Answer You could use in, if you want to filter on the transactions: If you want all rows for transactions that have the specified item, you can also use qualify:

Combining two queries with case statement in BigQuery

I’m new to SQL and have been trying to combine two queries that give me a count of unique uses by day of the week (‘weekday’ – with days of the week coded 1-7) and by user type (‘member_casual’ – member or casual user). I managed to use a case statement to combine them into one table, with the following

Advertisement