You could try something like this....it may need some tweaking
select name, code, start_date, end_date, class
from test_table a
where class = 'M'
and convert(smalldatetime, start_date) < getdate()
and not exists
(select 1
from test_table b
where a.name = b.name
and a.code = b.code
and...