Acounting problem with SQL and detail files