0

I have 3 tables in Microsoft SQL Server. 2 tables “Claims” and “Claims_Details” are populated when we ingest claims from our EDI software. Claims enter image description here Claims_Details

enter image description here Once those two tables are populated, we want to populate the third table which is “Claims_Transmittal”.

I use insert into query to update fields from “claims” and “claims_details” table. I manage to populate the table. However, the problem is claim details has these columns that are “procedure_code” and “procedure_cost” and are in new row for each claim Id. For example, claim id 1 will have 1+ procedure code and each will have unique cost associated with it. These are important to calculate total cost. For each batch there could be 1+ claims and each claims will have 1+ procedure code and procedure cost. I would like to update the claims transmittal where the claim number will have all these procedure code and procedure cost for each claim. Something Like this:

enter image description here How do I do it? I can’t even think about where to begin?

INSERT To Claim_Transmittals
FROM Claims_Details

I wanted to update

Dale K
  • 25,246
  • 15
  • 42
  • 71
sqlhelp99
  • 9
  • 1
  • 2
    As per the question guide, please do not post images of code, data, error messages, etc. - copy or type the text into the question. Please reserve the use of images for diagrams or demonstrating rendering bugs, things that are impossible to describe accurately via text. – Dale K Nov 03 '22 at 01:04

1 Answers1

-1

Use left join example:

UPDATE user_login a 
LEFT JOIN p_pegawai b
    ON a.id_pegawai = b.id
SET a.password = 'Keluarga1'  
WHERE b.NIP = '195812'; 
rabie jegham
  • 125
  • 2
  • 3
  • Thats not SQL Server syntax... – Dale K Nov 03 '22 at 01:14
  • The OP tagged SQL Server as the relational database engine they are using. Your update statement is not valid on SQL Server - if you check the documentation I think you will find I know exactly what I am talking about. Different relational database engines have different statement syntax, you have clearly provided syntax for a different RDBMS. – Dale K Nov 08 '22 at 01:06
  • based on your query:INSERT To Claim_Transmittals FROM Claims_Details i showed you another query witch can update tables with data from other tables. – rabie jegham Nov 08 '22 at 02:19