I have a table like the following in SQL Server 2008
AMID TierLevel
-------- -------------
999 GOLD
1000 SILVER
1000 GOLD
1000 PLATINUM
1000 BRONZE
1001 GOLD
1001 SILVER
1002 SILVER
1003 GOLD
Now I want to Update this table like the following
AMID TierLevel
-------- -------------
999 GOLD
1000 PLATINUM
1000 PLATINUM
1000 PLATINUM
1000 PLATINUM
1001 GOLD
1001 GOLD
1002 SILVER
1003 GOLD
Here the conditions are
-
I want unique Tier value for the same AMID, and the Tier values should be selected in priority base like
- PLATINUM
- GOLD
- SILVER
- BRONZE
-
It means if it is having the highest one present in its Tier values then select that. Like I shown in the second table, Platinum for 1000 and Gold for 1001..
please help me with this
Thanks,
Harry
I would do this using a temporary table to store the rank of each Tier:
This was done using the following sample data: