http://www.perlmonks.org?node_id=481416


in reply to Re^2: AVG returns COUNT
in thread AVG returns COUNT

I tried this, and I think I am missing something. Here is what my script looks like:
#!/usr/bin/perl #use strict; use warnings; use DBI; use Text::CSV; # Connect to the database, (the directory containing our csv file( +s)) my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n;"); # Associate our csv file with the table name 'results' $dbh->{'csv_tables'}->{'results'} = { 'file' => 'test.csv'}; # my ($avg) = $dbh->selectrow_array("SELECT avg(ERWWCOMMUNITIES_Mem +ory_Pages_sec) FROM results"); my ($r) = $dbh->selectall_arrayref("SELECT avg(ERWWCOMMUNITIES_Mem +ory_Pages_sec), count(1) FROM results"); my ($agv,$count) = @{$r->[0]}; # print ("$avg,\n"); print ("@r \n");
My output is
Possible unintended interpolation of @r in string at ./runsql.pl line +41. Name "main::r" used only once: possible typo at ./runsql.pl line 41. SQL ERROR: Bad table or column name '1' starts with non-alphabetic cha +racter! Execution ERROR: No command found!. Use of uninitialized value in array dereference at ./runsql.pl line 18 +.
Sorry to keep bothering with this.