How can I add two rows in SQL

0
id  Nombre  monto  
1   David  $500.00   
2   Andres $100.00  
3   Pedro  $600.00 

How many friends can help me? I want to add the amount of David plus Andres and send that to another table. What I want is to do as a type of transfer is to say David has 500 and I make a transfer of 200 to Andres and Andres has a total of 300 Please help with that or maybe a better idea !!!

    
asked by davidLDU 04.10.2018 в 21:16
source

1 answer

0

INSERT INTO sums (client, amount) VAULES SELECT 'David', SUM (amount) FROM money WHERE id IN (1,2) That's the same as I say: INSERT INTO sums (client, amount) VALUES ('david ', (500 + 100))

    
answered by 05.10.2018 в 02:38