Mr. Puneet Kishor wrote, On 2/2/2012 9:57 AM:
On Feb 2, 2012, at 9:46 AM, Petite Abeille wrote:

On Feb 2, 2012, at 4:37 PM, Bill McCormick wrote:

Does SQLite have FIRST and LAST  aggregate function?
No, sadly, SQLite doesn't support any analytic functions (aka window function) 
such as first, last, lead, lag, rank, etc, etc... [1]

To achieve the same, you will have to roll your own, which is not always a 
piece of cake. Oh, well...

[1] http://orafaq.com/node/55
to the OP... since you are using Perl (I believe, based on your earlier 
emails), you can get your data out and then use the most excellent List::Util 
(https://metacpan.org/module/List::Util). List::MoreUtils 
(https://metacpan.org/module/List::MoreUtils) and Scalar::Util 
(https://metacpan.org/module/Scalar::Util)

Yes, but I was hoping to pretty much go right from the SQL output right into a CSV file. I'm trying to avoid any extra processing in between, a la ...

# Open a new Text::CSV_XS object
my $csv = Text::CSV_XS->new( );

my $raw_aref = $rawData_sth->{NAME};
# Combine column names for CSV output
$csv->combine( @$raw_aref );
# Print column headers to file
print RPTRAW $csv->string() . "\n";

#
# Retrieve the rows from the SQL server
#
while( $raw_aref = $rawData_sth->fetchrow_arrayref )
{
    # Combine the fields for ouput
    $csv->combine( @$raw_aref );
    # Print the record to file
    print RPTRAW $csv->string() . "\n";
}

Obviously, I've left a few things out here, but I think you get the idea. Short of some VERY simple solution, I save this for some other day.

Thanks!!
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to