|
-
Sep 21st, 2009, 07:13 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Select sum(d),sum(k) from deposit group by sendernumber;
I am sorry if this is not the right category to post.
A Deposit tabel having structure like this;
CREATE TABLE IF NOT EXISTS `deposit` (
`id` smallint(5) NOT NULL auto_increment,
`SenderNumber` varchar(15) NOT NULL,
`D` int(10) NOT NULL,
`K` int(10) NOT NULL,
`text` varchar(160) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
INSERT INTO `smsd`.`deposit` (`id`, `SenderNumber`, `D`, `K`, `text`) VALUES (NULL,
'+6285668878868', '100000', '0', '+6285668878868+100');
INSERT INTO `smsd`.`deposit` (`id`, `SenderNumber`, `D`, `K`, `text`) VALUES (NULL,
'+6285668878868', '100000', '0', '+6285668878868+100');
INSERT INTO `smsd`.`deposit` (`id`, `SenderNumber`, `D`, `K`, `text`) VALUES (NULL,
'+6285668878868', '0', '10000', '+6285668878868+100');
INSERT INTO `smsd`.`deposit` (`id`, `SenderNumber`, `D`, `K`, `text`) VALUES (NULL,
'+6285668878868', '0', '10000', '+6285668878868+100');
INSERT INTO `smsd`.`deposit` (`id`, `SenderNumber`, `D`, `K`, `text`) VALUES (NULL,
'+6285668878868', '0', '10000', '+6285668878868+100');
when I use sum like following line in phpmyadmin it woring fine
SELECT SUM(D),SUM(K) FROM DEPOSIT GROUP BY SENDERNUMBER;
SELECT SUM(D),SUM(K) FROM DEPOSIT WHERE SENDERNUMBER=+6285668878868;
I have problem on calculation and to
add another collum call 'balance' as a variabel of sum(D) - sum(K).
that is;D - K = balance
anyone help me to solve this problem?
thanks a lot for your advise
kind Regards,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|