sroux has asked for the wisdom of the Perl Monks concerning the following question:
And the expected result:Account Entity Unit Jan Feb Mar Account01 Entity01 Unit01 1 2 3 Account01 Entity01 Unit01 4 5 6 Account01 Entity01 Unit01 7 8 9 Account02 Entity02 Unit02 10 11 12
This is what I run from my database:Account Entity Unit Jan Feb Mar Account01 Entity01 Unit01 12 15 18 Account02 Entity02 Unit02 10 11 12
If found this piece of code but not clear on how to define the hash header/keys (Account to Mar) and columns to group (Jan to Mar)CREATE TABLE concat_FRA3 AS SELECT Account, Entity, Unit, SUM(Jan) Jan, SUM(Feb) Feb, SUM(Mar) Mar FROM concat_FRA2 GROUP BY Account, Entity, Unit;
Thank you for any hint or advice. Sebastien# Store my %storage; foreach my $row (@$result_set) { my $hash_key = encode_hash_key(row); my $new_row = $row; if (exists $storage{$hash_key}) { $new_row = merge_rows($row, $storage{$hash_key}); } $storage{$hash_key} = $new_row; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Group by from array
by Corion (Patriarch) on Sep 01, 2022 at 08:13 UTC | |
|
Re: Group by from array
by tybalt89 (Monsignor) on Sep 01, 2022 at 09:48 UTC | |
by LanX (Saint) on Sep 01, 2022 at 11:28 UTC | |
by choroba (Cardinal) on Sep 01, 2022 at 14:16 UTC | |
by sroux (Sexton) on Sep 02, 2022 at 08:12 UTC | |
by tybalt89 (Monsignor) on Sep 02, 2022 at 08:25 UTC | |
by tybalt89 (Monsignor) on Sep 02, 2022 at 09:06 UTC | |
| |
by LanX (Saint) on Sep 02, 2022 at 10:42 UTC | |
|
Re: Group by from array
by erix (Prior) on Sep 02, 2022 at 12:44 UTC | |
|
Re: Group by from array
by Marshall (Canon) on Sep 02, 2022 at 09:33 UTC | |
|
Re: Group by from array
by tybalt89 (Monsignor) on Sep 02, 2022 at 15:21 UTC |