Skip to content
Advertisement

Tag: sql

How to in insert new rows from one table to another based on date?

I am having two tables (table1 and table2). I have columns Date, A, B, C in table1 and columns Date, D, E in table2. I need to transfer column D and E from table2 to table1 based on Date in both the tables. I tried below code but getting ‘multi-part identifier “table1.Date” could not be bound.’ error Expected output: Answer

Update a field in a JSON column in PostgreSQL

I have a work_item table that has the following schema and a document_type table with the following schema: The data column is a json column that has a Type field. This is a sample column data: I need to update data columns whose data_type column value is DocumentModel and Type field values matches a value in the name column of

SQL Server: Update table based on JSON

I am trying to update rows in table based on JSON I have. JSON has the following structure: Table dbo.sensors has same structure + few more columns. To insert such JSON object, not array, into table, I would do it this way: So I have 2 questions: how to iterate over each element in JSON array and update each row

displays all data with certain field types, from the results of the query [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed last year. Improve this question displays all data with certain field types, from the results of the query …

Fetch most recent value – sql execution time too long

I have a Firebird database with a table with two columns: Date and value. I want to get the most recent value. Problem is, that this table can have easily over 200k rows. My select query takes more than 400ms, which is just to long for my application. Is there any way, I can speed this up? I can’t change

SQL Update One Table If Record Does Not Exist In Another Table

The above works to give me all the customer accounts that have no invoices. It takes a long time to run, but I’m not concerned with the speed. I will likely only run this a couple times a year. What I can’t get right is updating a record in the customers table when the account has no invoices. I have

Advertisement