Skip to content

Non-matching records using SQL IN

Lets say I have a list of employee names and I want to select all rows with those names: Perhaps Jane and Joe don’t exist in this table. How can I create a query that identifies items in my list that don’t exist at all. I’m not looking for any specific format as the returned result; it can b…

Oracle SQL- Stack dates if they match diagonally

The goal is to stack dates if DT and VAR are same, and END_DATE matches the START_DATE of next highest START_DATE In the example, row 2 and 3 are combined because END_DATE of row 2 matches START_DATE of row 3. Original Expected I have tried the query below but the solution won’t work when there is addit…

Redshift Postgres 8

I’m trying to write a query to solve a logical problem using Redshift Postgres 8. Input column is a bunch of Order IDs and Step Group IDs and desired output is basically a sequence of the IDs as you can see in the screenshot. If you could help me answer this question, that would be great, thanks! This i…

Google Sheets – Query from selected tab

I have multiple tabs with the same structure, and a query tab. There, I am using the following query formula: =query({‘Sheet1’!A2:L},”select * “& IF(COUNTA(B2:B3)>0,”where “&…

How to use an alias in Hive?

I am trying to find unique cities using the window function, I am not able to use an alias in this query Answer You cannot have a window function in the where clause. Put it in a subquery and do the filter afterwards:

Finding groups within time series in Postgre

I have a list of timestamps and i want to tag them as a group when they are close enough (less than 15 sec intervall). This is what I want to have eventually : time group number 18:01:00 1 18:01:06 …

~ operator in SQLITE

I’m running this part of a query on Postgres and it’s running fine But when I try to run it in SQLite, I get this error: near “~”: syntax error Do you have any idea how I can run this function in SQLite? Answer Actually, if you want columns that start with a digit, you can simply use: …