[DFW.pm] Adding variables together based on commonality of different variable

Lisa Cloutier staurofilax77 at gmail.com
Tue Mar 25 09:52:22 PDT 2014


Thank you for your input, John.


On Tue, Mar 25, 2014 at 11:40 AM, Jason H King <jhking at airmail.net> wrote:

> This is a sql problem not really a Perl problem.
> I don't know your table and column names so you'll have to translate.
> It looks like your query is:
> select market,col1, col2
> from marketing_table;
> Let's change the query to
> select market, sum(col1) sum_col1, sum(col2) sum_col2
> from marketing_table
> group by market;
>
> The first column will have unique names,
> the second and third will be sums per distinct market.
>
> HTH
>
> --- staurofilax77 at gmail.com wrote:
>
> From: Lisa Cloutier <staurofilax77 at gmail.com>
> To: dfw-pm at pm.org
> Subject: [DFW.pm] Adding variables together based on commonality of
> different variable
> Date: Tue, 25 Mar 2014 11:12:35 -0500
>
>
> Hi All,
>
> This should be easy and I've done similar things before, but I can't seem
> to get the data structure to output properly.
>
> I have data in the following format:
>
> Market1 65000 3000
> Market1 130000  5000
> Market1 65000   4500
> Market2 65000  3000
> Market3 32000  800
> Market3 32000  1000
>
> What I need to do is get the markets so that they are unique so that I can
> use them as hash keys.  So I need to add all of the 2nd column and all of
> the 3rd column for each market so that there is only one entry per market,
> with the duplicate entries all added together.
>
> The data is coming out of an arrayref (from an Oracle database) so I don't
> have any code that shows the problem, just the foreach loop iterating
> through each reference in the arrayref.
>
> Any help would be greatly appreciated.
>
> Thanks,
>
> Lisa
> _______________________________________________ Dfw-pm mailing list
> Dfw-pm at pm.org <http://eonapps/ft/wm/page/compose?send_to=Dfw-pm%40pm.org>
> http://mail.pm.org/mailman/listinfo/dfw-pm
>
> _______________________________________________
> Dfw-pm mailing list
> Dfw-pm at pm.org
> http://mail.pm.org/mailman/listinfo/dfw-pm
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/dfw-pm/attachments/20140325/63c64371/attachment-0001.html>


More information about the Dfw-pm mailing list