I'm very new to T-SQL so sorry if this is not right.
Using T-SQL, how do I pull the max number from a record using 2 other columns? I have a unique ID number, visit number per ID and then the number of rooms that person have been to (Can do multiple rooms in one visit). How do I get it so that I can only select the row which has the highest number of Rooms a person visits using the persons ID and Visit Number?
Let's say I have this table;
What I want to have is just the rows with the highest Room number per ID and Visit_No. So with this table I would want to retrieve this dataset;
Dataset Wanted:
I thought using a ROW_SEQUENCE would work but I have tried but I don't think I am doing it correctly.