Added SQL for analytics and scoring