Я хочу сказать :
«Где первые 2 буквы не равны 10, а те, которые начинаются с 10, исключают только буквы с 2018 года и далее»
where (left(c.DealCode, 2) <> '10'
and estyear > 2018)
Не работает.. Что мне не хватает?


where left(c.DealCode, 2) <> '10' or (left(c.DealCode, 2) = '10' and estyear > 2018)
или
where c.DealCode not like '10%' or (c.DealCode like '10%' and estyear > 2018)
Ты говоришь:
'Where the first 2 letters are not 10 and for those that do start with 10 only exclude the ones from 2018 onward'
но что вы должны сказать:
'Where the first 2 letters are not 10 or for those that do start with 10 only exclude the ones from 2018 onward'
Поэтому вы должны использовать OR вместо AND в своем заявлении.
Также заявление типа:
(a doesn't start with 10) or ((a starts with 10) and (estyear > 2018))
эквивалентно
(a doesn't start with 10) or (estyear > 2018)
поэтому ваше условие должно быть:
where c.DealCode not like '10%' or estyear > 2018
не уверен, хотя если
"exclude the ones from 2018 onward"
должно быть estyear > 2018 или estyear < 2018
Отредактируйте вопрос, добавьте некоторые образцы данных, и желаемый результат будет полезен.