Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need mysql to add debit and credit values separately

Status
Not open for further replies.

tanveerhabib

Programmer
Dec 8, 2015
27
PK
suppose I have a table having these columns

ID
Asset
Debit
Credit

and i need to add debit and credit separately like if asset has debit values 100+200+300 and credit have values -100-200-300 both of them must have total debit = =300 and credit = -300
what will be mysql command to enter
regards

 
If I understand correctly, something like the following should get you close:

Code:
SELECT asset, CONCAT("-",SUM(credit)) AS credit, SUM(debit) AS debit FROM assets GROUP BY asset

With that said, since this is an entirely MYSQL-based question, it would be better posted in: forum436. Nothing to do with PHP really.
----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top