sql sum based on distinct other column. The sum of the k large