Problem with accounting and sql