i have a query, which it's results based in id and other columns.
i gave each row a row number and a count based on the id
SELECT ROW_NUMBER() OVER(Partition BY Id ORDER BY Id) as RowNo,
COUNT OVER(Partition BY Id ORDER BY Id) as count,
* FROM ......
where (total=1) or (total>1 and rowcount>1)
how can i improve it so i don't use the row number and count (if possible)