1 |
dpavlin |
1.1 |
#!/usr/local/bin/perl -w |
2 |
|
|
|
3 |
|
|
use DBI; |
4 |
|
|
|
5 |
|
|
my $connect = "DBI:Pg:dbname=corp"; |
6 |
dpavlin |
1.2 |
my $sql="select date(s1.date),avg(s1.current) as zse,avg(s2.current) as ftse |
7 |
|
|
from stocks as s1,stocks as s2 where time(s1.date) != '23:23:23' and |
8 |
|
|
time(s2.date) != '23:23:23' and s1.date=s2.date and |
9 |
|
|
s1.type='LSE' and s2.type='FTSE' |
10 |
|
|
group by date(s1.date),date(s2.date) |
11 |
|
|
"; |
12 |
dpavlin |
1.1 |
|
13 |
|
|
my $dbh = DBI->connect("$connect","","") || die $DBI::errstr; |
14 |
|
|
|
15 |
|
|
$dbh->do("set datestyle='german'") || die $dbh->errstr(); |
16 |
|
|
|
17 |
|
|
$sth = $dbh->prepare("$sql") || die $dbh->errstr(); |
18 |
|
|
$sth->execute() || die $sth->errstr(); |
19 |
|
|
|
20 |
|
|
print "#",join("\t",@{ $sth->{NAME} }),"\n"; |
21 |
|
|
while (@arr = $sth->fetchrow_array() ) { |
22 |
|
|
print join("\t",@arr),"\n"; |
23 |
|
|
} |