Change limit and Update definitions to SQL query