SQL based log statistics  and analysis tool