Skip to content

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…

SQL good practices: should I use associative tables in this example?

I want to link two tables: a “company” table and a “branches” table. I find two ways to do it: Method 1: Method 2: In practice, I think that both ways work the same, but professionally speaking, I think Method 2, using associative tables, would be the proper way to do it following SQL …

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: Answ…

Why does this inner join of two tables create duplicate rows

I have the following tables: Users Conversations Group_Members I need to select all the conversations where a user with a specific ID takes part in. Users and Group_Members are in a many-to-many relationship. Why does the following query create duplicate rows on the last select, as seen in this image? User.Id…

How to use T-SQL to select N rows every N rows?

I have a few hundred rows of data numbered with SELECT ROW_NUMBER() OVER (ORDER BY LastName). I need to skip 3 of those rows every 3 rows in that selection. So I need to select rows 1, 2, 3… then …