Someone please change my title to better reflect what I am trying to ask.
I have a table like Table(id,value,value_type,data)
ID is NOT unique. There is no unique key.
value_type has two types. lets say A and B.
Type B is better than A, but often not available.
For each id if any records with value_type B exsits I want all the records with that id and value_type B.
If no record for that id with value_Type B exists I want all records with that id and value_type A.
Notice that if B exsists for that id I don't want records with type A.
I currently do this with a seris of temp tables. Is there a single select statment (sub quries OK) that can do the job?
Thanks so much!
Additional Details:
SQL 2005