updated analysis sql script