Updates in SQL queries to calculate similarities