• how do the SQL query to calculate this value?