I have two tables, one is called original_table and the other is table_with_additional_column. table_with_additional_column is a subset of original_table but with an additional column called sequenceNr. I want to merge the two tables such that I can get all rows from original_table with sequenceNr set to NULL…
Format JSONB column by taking the text value from same jsonb coulmn
CREATE TABLE test(id serial, data jsonb); INSERT INTO test(data) values (‘dummydata-got-uploaded’); I need to correct the jsonb column value with below query. update test set data={“addDet”: data }::jsonb where id =1; ERROR: syntax error at or near “{” LINE 1: update test s…
Oracle bug when using JSON_ARRAYAGG with CASE expression to emulate standard SQL FILTER
I’m using Oracle 18c (reproduces in 19c as well) and I’d like to emulate the standard SQL FILTER clause in the JSON_ARRAYAGG() aggregate function to filter out values from the aggregation. However, this produces an error: The error being: ORA-40590: invalid format dbfiddle here. What’s causi…
How can I delete records that have the same values in two non-primary key columns while factoring in a third?
Here is a link to a sqlfiddle with sample data: http://sqlfiddle.com/#!18/d8d552/3 I’m trying to delete 1 row from rows that have the same values in both name and color. If they have they same score, then it doesn’t matter which one is deleted. If those rows have a different score, then I want to …
How to join a table with itself?
I want to ask how can I join the table with itself, using the same column twice, and giving each a different WHERE to sort out. I have an Employees table that contain Employee_name, job_id and manager_id. I want it to get the name of all the managers through the job_id on one column, and then all the employee…
How to select a table that have one to another and another table relationship
I don’t know if the question make sense or not. I’m trying to request information from 2 different tables that are linked (via FK) to a table and display the data with information from that linked tables. post user role Is there a way to select/show this table?: result Answer Try this:
How to count mention in one day [closed]
I am try to understant how to make a table that tells me in which specific day were written the most mentions about the persons in my table. SELECT person, COUNT(1) AS count_mentions, COUNT(…
Aggregation depends from value [closed]
I have a sample table ID Invoice_ID docType 1 100 email 2 100 sms 3 200 email 4 200 email 5 300 sms and I have to get results with only rows that have invoices with email and sms docType. For …
SQL Left Join Within Timeframe Window
I have two datasets: dataset_a time_stamp user group value 2021-06-20 12:48:24.521 A video 1 2021-06-15 12:50:24.521 A video 1 2021-06-10 12:…
How to Insert Large Amount of Varbinary(max) Rows Into Table
I use a local SQL Server. I have table with 250k of photos (DropPhotos). Photos are stored in a Varbinary(max) column which is called Content. I want to move all of this rows into another table within …