I would like to sum the numbers after loop pass. Code idea: I would like to count how many same records are there in a column with the same row id in sql. How to do it?