in reply to Re: Adding numbers from a loop
in thread Adding numbers from a loop
I don't need to simply add up the $total fields (i.e. 3 + 6 = 9). I need to know that one record had $total = 3 so $revenue = 30 and the next record is $total = 6 so $revenue = 48. $total_revenue = 78.$SQL = "select * from datbase where (TO_DAYS(NOW())-TO_DAYS(dateadded) +<1)"; # look for records less than 1 day old &Do_SQL; while ($pointer = $sth->fetchrow_hashref) { $total = $pointer->{'total'}; if ($total eq "3") { $revenue = 30; } elsif ($total eq "6") { $revenue = 48; } elsif ($total eq "10") { $revenue = 50; } } $sth->finish();
I hope that makes it clearer. I don't think the SUM function can do that for me OR I just don't know how to do it. I can easily grab the SUM of the $total fields, but that's not what I need.
Appreciate the help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Adding numbers from a loop
by stevieb (Canon) on Aug 07, 2019 at 00:03 UTC | |
|
Re^3: Adding numbers from a loop
by syphilis (Archbishop) on Aug 07, 2019 at 03:37 UTC | |
|
Re^3: Adding numbers from a loop
by 1nickt (Canon) on Aug 07, 2019 at 02:25 UTC | |
|
Re^3: Adding numbers from a loop
by tweetiepooh (Hermit) on Aug 07, 2019 at 11:58 UTC |