Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


need mysql to add debit and credit values separately

need mysql to add debit and credit values separately

need mysql to add debit and credit values separately

suppose I have a table having these columns


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

RE: need mysql to add debit and credit values separately

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


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: MySQL. 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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close