I wanted to know how to get the row number of a specific item in mssql.
Lets say I have a table like this:
ID Type Brand Model
1 Guitar Ibanez custom33
2 Guitar Ibanez custom45
3 Guitar Ibanez custom27
40 Guitar Fender strat45
41 Guitar Fender strat30
42 Guitar Fender strat15
For example i want to get the items for Fender. I want the table to be like this now(Assuming I'm using a select statement to get all the items with the brand "Fender" in it):
ID Type Brand Model
40 Guitar Fender strat45
41 Guitar Fender strat30
42 Guitar Fender strat15
Then for example, I want to get the row number of Brand "Fender" and Model "strat30". The returned value should be 2. If i want the Model "strat15", the row number should be 3 and vice versa.
I probably might be needing to nest some sql syntax but i don't know how to combine the SELECT * FROM statement to SELECT ROW_NUMBER statement. Hope you guys can provide example for this.
Feel free to suggest the best way to achieve this output.