Results 1 to 3 of 3

Thread: [RESOLVED] Select sum(d),sum(k) from deposit group by sendernumber;

  1. #1

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Resolved [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,

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Select sum(d),sum(k) from deposit group by sendernumber;

    Sum(d) - Sum(k) As `Balance`

    That's about as simple as it gets.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width