Hi Luis,
I like your two solutions. Especially the first one, which I take to be an example of using a common table expression. I've heard of CTE's, but have never used one. I tried that first, but unfortunately it gave me the following errors:
Msg 207, Level 16, State 1, Line 31
Invalid column name 'race'.
Msg 207, Level 16, State 1, Line 31
Invalid column name 'YesNoDesc'.
Msg 207, Level 16, State 1, Line 28
Invalid column name 'YesNoDesc'.
Msg 207, Level 16, State 1, Line 32
Invalid column name 'race'.
The second one was closer to working, but it also gave me an error:
Msg 8127, Level 16, State 1, Line 42
Column "dbo.asiatrsupplement.Race" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
Kindest Regards, Rod Connect with me on LinkedIn.