I’ve got a table defined in Snowflake as: GLPCT and a file that looks like this: GLPCT.csv example: My copy into command looks like this: Problem Snowflake is throwing an error due to a column number mismatch. How can I get Snowflake to ignore the column that isn’t present in the file and not thro…
Mysql how to connect 2 subqueries
I have this mysql code: My code returns 2 different result set in mysql workbench. Is there any way I can connect those 2 result sets? Answer You can use double join clause among three tables : including distinct keyword.
T-SQL, looking to extract drug dose from column
I have a column of drug names with dose and I’m trying to extract the just the dose from the field. The difficulty comes in when I have combination drugs that have multiple doses. I can either extract the first numbers in the string, or all of them in one string with no way to separate them. Desired out…
Get Max And Min dates for consecutive values in T-SQL
I have a log table like below and want to simplfy it by getting min start date and max end date for consecutive Status values for each Id. I tried many window function combinations but no luck. This is what I have: This is what want to see: Answer This is a typical gaps-and-islands problem. You want to aggreg…
Sum IIF in T-SQL
a need a help with T-SQL, I have an query to select current row and subtract with previous row. The goal is SUM results from IIF and group by date and shift. the query: DECLARE @timeStart time(4) = ‘…
Extract string from the first position that’s not “0” SQL
I am trying to find the first position of a value that’s not “0” in a string so that I can extract the values that come after. The strings are all length 10. The strings all start with D and then a …
Optimalization of select containing Union
I have and easy select: define account_id = 7 select * from A where ACCOUNT_ID = &account_id UNION select * from B where ACCOUNT_ID = &account_id; I would like to have account_id as input …
Is there an alternative to timestamp in oracle to show the time?
I am wondering whether or not there is an alternative to timestamp to display the time as well as date? I don’t really want to use timestamp as it confuses me and I am not sure if I have done it right …
How to get ONLY NULL values from table MySQL
I have searched the forum profoundly but I did not see the answer to this specific case. Condiser this data model: I want to get only Building names where ALL of the rooms have no flowers (where …
Writing a Rails migration to collapse booleans into an enum
I made a mistake when modeling my data and created a model with 4 booleans, only one of which are active at a time. I want to create a column of Postgres enum type, and then set the value based on …