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…
How do I write a Ruby where clause with dates and array lookup?
I want to do something like the above. I first want to check if the model external id is in the array of appointment_ids, then make sure it is not soft deleted and then check if the record start time is between dates.. Any help much appreciated. Answer You don’t need to use a SQL string to create that q…
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 can I select all rows from a table where the combination of two columns is distinct on each row (SQL Server)?
I have a table like this: UsersPositions id Name PositionId UserId Code ————————————————————— 1 | Produce | …
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 …
How Do I Modify First Digit of Attribute in XML with SQL?
This is the section of my xml I am trying to modify: <ORDER ORDER_NAME="10009999" ORDER_NAME is an attribute. This is what I have come up with so far and I think it's close, but slightly …
~ 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: …