I need to get one column from one table and put it in a temp table but also add another column to the temp table that would be the row number but I am not sure how to do that.
The basic problem I have is I have a table of communities and a table of sales and I need to go through the sales table and count how many were in each community. Then if a community has more than 5 then to increment a variable that signifies how many models made quota. My thought was to have a temp table that has each community in it alone with a row number and loop through that based on that row number through the sales table to make sure that I check each sale with each community.
Thanks for the input!
You can use IDENTITY on a #temp table.
Output: