Change positive float to negative

Alles, was MariaDB und MySQL betrifft, kann hier besprochen werden.

Change positive float to negative

Postby lonesoac0 » 03. January 2024 02:57

Hello all,

I have a CSV that has the values of:

Booking Date,Amount,Credit Debit Indicator,type,Type Group,Reference,Instructed Currency,Currency Exchange Rate,Instructed Amount,Description,Category,Check Serial Number,Card Ending
12/29/2023,0.01,Credit,Credit,Credit,,,,,Interest Income,Interest,,
12/29/2023,216.95,Debit,POS,POS,,,,,Prestige Tuxedo,Clothing/Shoes,,


My issue is that all of the values in the CSV are positive but they should be negative for the most part. If the transaction "Credit Debit Indicator" is Credit then leave positive. If "Credit Debit Indicator" is Debit, then change it to negative. How can I do that in MariaDB. The records are already present, I just need to update most of them.

Thank you.
lonesoac0
 
Posts: 3
Joined: 17. October 2017 23:11
Operating System: Debian 9

Re: Change positive float to negative

Postby Nobbie » 03. January 2024 22:06

UPDATE table_name
SET Amount = -Amount
WHERE `Credit Debit Indicator` = 'Debit';
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04


Return to MariaDB - MySQL

Who is online

Users browsing this forum: No registered users and 37 guests