@Amrit - You don't seem to understand the problem. If
dealId
is the primary key, then its easier to explain. If the conditions that you put on your
WHERE
returns more than one row as a result (let's suppose that it returns 3 rows), then, since you are grouping by the primary key, you will have 3 rows with a count value of 1, instead of 1 row with the count value of 3. And of course, the result that you are getting can't be assigned to a scalar variable. —
Lamak 7 mins ago