Skip to content

Tag: sql

Postgres Import from different table

I’m still fairly new to postgres. I have a table named: university_table with fields: name, nationality, abbreviation, adjective, person. I found this sql query to insert data from: https://stackoverflow.com/a/21759321/9469766 Snippet of query below. How can alter the query to insert these values into m…

How to use GROUP BY which takes into account two columns?

I have a message table like this in MySQL. Messages in a recepient’s inbox are to be grouped by thread_id like this: My problem is how to take recipient_read into account so that each row in the result also show what is the recipient_read value of the last message in the thread? Answer In the original q…

SQL Group By Column With Latest Date

I Have a table of following column name where we have date multiple bin have multiple date with 30-sec date slot I need to pull data based on last entry respect to bin Suppose 1990025I have 100 entry for today only when I query I need last enter record when I do get find All Entry group by bin am

COPY INTO Snowflake Table with Extra Columns

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…