Быстрый вопрос : Как я могу изменить предложение WHERE, чтобы получить все эти метрики, а затем сравнить его> 0
вместо необходимости делать (d.metric1> 0 или d.metric2> 0 или d.metric3> 0 или d.metric4> 0 или d.metric5> 0)
SELECT a.No as NoRB,
a.Account# as Account#RB,
b.Account# as Account#2,
b.No as No2,
b.type_cd as type_cd2,
b.EffectiveDate as EffectiveDate2,
b.ExpirationDate as ExpirationDate2,
b.EntranceDate as EntranceDate2,
c.postalCode as postal_code2,
d.No,
d.ExpirationDate,
d.EntranceDate,
d.metric1,
d.metric2,
d.metric3,
d.metric4,
d.metric5,
d.metric6,
d.metric7,
d.metric8,
d.metric9,
d.metric10,
d.metric11
FROM DB.CarInsurance a INNER JOIN
DB.CarInsurance b
ON a.No = b.No INNER JOIN
2ndDB.CarInsuranceINT c
ON a.Account# = c.Account# INNER JOIN
2ndDB.CarDriver d
ON a.No = d.No
WHERE a.type_cd in ('OcPr','OcNotPr') and
b.type_cd = 'Pr' and
a.DateDelivery >= '2020-02-01 00:00:00' and
(d.metric1 > 0 or d.metric2 > 0 or d.metric3 > 0 or d.metric4 > 0 or d.metric5 > 0)
ORDER BY a.No, a.Account#, a.ExpirationDate, a.EntranceDate , a.EffectiveDate;