Re: Need help on MySQL query
| From: | Carlos Medina | Date: | Thu, 11 Dec 2008 07:34:38 +0000 |
| Subject: | Re: Need help on MySQL query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-284463@lists.php.net to get a copy of this message | ||
Rahat Bashir schrieb:
Hi Experts, EID Mubarak to all. I need your help on writing a MySQL query. Scenario: CREATE TABLE transaction (you can see more information about MySQL on www.mysql.com and show how to build/make Queries well. Regards Carlos Medinaidint NOT NULL ATUTO INCREMENT,datedatetime NOT NULL,withdrawndouble (12,2) NULL,depositdouble (12,2) NULL ); SELECT * FROM transaction;id date withdrawn deposit ----- ----------------------------- --------------- -------------- 1 2008-12-01 00:00:00 NULL 10000.00 2 2008-12-02 00:00:00 4000.00 NULL 3 2008-12-04 00:00:00 2000.00 NULL 4 2008-12-05 00:00:00 NULL 4500.00 5 2008-12-06 00:00:00 500.00 1500.00The above is all I have. I want to make query which should output an extra calculated column named "balance", something like following: Expected output from query:id date withdrawn deposit balance ----- ----------------------------- --------------- -------------- ------------- 1 2008-12-01 00:00:00 NULL 10000.00 10000.00 2 2008-12-02 00:00:00 4000.00 NULL 6000.00 3 2008-12-04 00:00:00 2000.00 NULL 4000.00 4 2008-12-05 00:00:00 NULL 4500.00 8500.00 5 2008-12-06 00:00:00 500.00 1500.00 9500.00Thanks in advance Hi Rahat,