Have the following SQL: case when m.taxcode + 'M' in ( '142M', '144M', '160M', '211M', '225M', '230M', '231M', '233M', '234M', '235M', '236M', '237M', '238M', '239M', '240M', '266M', '270M', '275M', '645M', '647M', '649M', '745M', '760M', '650M' ) then m.PerformPostingDate else COALESCE(m.PerformTradeDate, m.PerformSettlementDate, m.PerformPostingDate) end as Effective_Date, case when m.taxcode + 'M' in ( '142M', '144M', '160M', '211M', '225M', '230M', '231M', '233M', '234M', '235M', '236M', '237M', '238M', '239M', '240M', '266M', '270M', '275M', '645M', '647M', '649M', '745M', '760M', '650M' ) then m.PerformPostingDate else COALESCE(m.PerformTradeDate, m.PerformSettlementDate, m.PerformPostingDate) end as TradeDate, case when m.taxcode + 'M' in ( '142M', '144M', '160M', '211M', '225M', '230M', '231M', '233M', '234M', '235M', '236M', '237M', '238M', '239M', '240M', '266M', '270M', '275M', '645M', '647M', '649M', '745M', '760M', '650M' ) then m.PerformPostingDate else COALESCE(m.PerformSettlementDate, m.PerformPostingDate) end as SettlementDate,
This is piece of a sql statements happen about 5 times throughout a procedure as I have several joins that basically do the same thing with different filters. My question is, and am newer to the game with SQL, is there any better way to clean this up and make it more efficient through the procedure rather then having it repeat so many times?