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…
Tag: sql
PrestoDB/AWS Athena- Retrieve a large SELECT by chunks
I have to select more than 1.9 billion rows. I am trying to query a table hosted in a DB in AWS ATHENA console. The table is reading parquet files from the a S3 bucket. When I run this query: My query seems to time-Out as there are 1.9 billion rows that are returned when I run a COUNT on
Create a calendar database table like this
I would like to create a calendar SQL table like this one but for some years. (I’m using mysql 5.7.28) Date is DD-MM-YYYY Is it possible? Answer If you are running MySQL 8.0, you can use a recursive query: The recursive cte generates a list of datetimes between the given boundaries (here, that’s y…
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: INSERT multiple different hardcoded values in one column
I could not find a solution for this yet. I want to insert multiple rows with 2 or more different hardcoded values, but also with data that I get from another table. Example: I want to add 2 items into a table for a user that has the ID = ‘0’ in another table without running 2 queries. This is
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
Why I am getting error while performing group by in hive?
I am executing below command in hive: Select child.data_volume_gprs_dl + child.data_volume_gprs_ul as data_usage, parent.file_name, parent.record_number from table1 as parent left …
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…