How would I dynamically count the rows in a query like this:
Select distinct name from @table where %rules
When I add ROW_NUMBER () OVER (), I lose my individual property and return each item in the table with a unique row number.
Select distinct ROW_NUMBER OVER(order by name), name from @table where %rules
I do not want to create a temporary table, otherwise I would make a primary key for the temporary table and insert rows this way.
Thanks in advance!
source share