my $dbh = DBI->connect( "$datenbankinformationen","$username","$password") || die "Database connection not made: $DBI::errstr"; my $sql = qq{SELECT sum(e.anzahl) as menge_gesamt, e.spot_id, e.tag, s.name, sp.title, e.anzahl FROM einblendungen e, clients c, standorte s, spots sp where c.id = e.client_id and c.standort_id = s.id and e.spot_id = sp.id and e.tag between '$zeitraumvon' and '$zeitraumbis' and e.spot_id like '$spot_id' group by e.client_id, e.spot_id};