<DIV style="font-family:Arial, sans-serif; font-size:10pt;"><FONT size="2">This is a sql problem not really a Perl problem.<BR>I don't know your table and column names so you'll have to translate.<BR>It looks like your query is:<BR>select market,col1, col2<BR>from marketing_table;<BR>Let's change the query to<BR>select market, sum(col1) sum_col1, sum(col2) sum_col2<BR>from marketing_table<BR>group by market;<BR><BR>The first column will have unique names,<BR>the second and third will be sums per distinct market.<BR><BR>HTH<BR></FONT><BR>--- staurofilax77@gmail.com wrote:<BR><BR>From: Lisa Cloutier <staurofilax77@gmail.com><BR>To: dfw-pm@pm.org<BR>Subject: [DFW.pm] Adding variables together based on commonality of        different variable<BR>Date: Tue, 25 Mar 2014 11:12:35 -0500<BR><BR><DIV dir="ltr"><DIV><DIV><DIV><DIV><DIV><DIV><DIV><DIV><DIV><DIV>Hi All,<BR><BR></DIV>This should be easy and I've done similar things before, but I can't seem to get the data structure to output properly. <BR><BR>
</DIV>I have data in the following format:<BR><BR></DIV>Market1 65000 3000<BR></DIV>Market1 130000  5000<BR></DIV>Market1 65000   4500<BR></DIV>Market2 65000  3000<BR></DIV>Market3 32000  800<BR></DIV>Market3 32000  1000<BR>
<BR></DIV>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.  <BR>
<BR>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.  <BR><BR>Any help would be greatly appreciated. <BR>
<BR>Thanks,<BR><BR></DIV>Lisa<BR></DIV>
_______________________________________________
Dfw-pm mailing list
<A href="/eonapps/ft/wm/page/compose?send_to=Dfw-pm%40pm.org">Dfw-pm@pm.org</A>
<A href="http://mail.pm.org/mailman/listinfo/dfw-pm">http://mail.pm.org/mailman/listinfo/dfw-pm</A>
</DIV>