Imのピックアップ列の1つはPolicyType
で、その条件はTransactionType = 'Policy'
です。 しかし、同じInsured
は同じTransactionType
値を持つことができますが、異なるPolicyType
値を持つことがあります。だから私は同じTransactionType
と同じ被保険者を持っているが、異なるPolicyType
- どのようにプライオリティとPolicyType='New Business'
でそれを無視して、ポリシータイプ='Rewrite'
を持つレコードを選択することができますか? は単純CASE
文である必要がありますが、私はあなたのサンプルデータをチェックした後 列名に基づいて優先順位を持つレコードを選択しない方法
SELECT CAST(YEAR(EffectiveDate) as CHAR(4))+'/'+ CAST(MONTH(EffectiveDate) AS VARCHAR(2)) AS YearMonth,
Insured,
PolicyNumber,
EffectiveDate,
PolicyType,
TransactionType,
SUM(Premium) as Premium,
ExperienceMod,
ISNULL(ScheduleMod,0) as ScheduleMod,
TerritoryMod,
ISNULL(EffectiveMod,0) as EffectiveMod
FROM ProductionReportMetrics
WHERE EffectiveDate >=DateAdd(yy, -1, DATEADD(d, 1, EOMONTH(GETDATE()))) AND EffectiveDate <= EOMONTH(GETDATE())
AND CompanyLine = 'Arch Insurance Company' AND Insured <>'Jerry''s Test' AND TransactionType = 'Policy' --and PolicyNumber ='ZAWCI2517900'
GROUP BY Insured,
PolicyNumber,
PolicyType,
TransactionType,
EffectiveDate,
experienceMod,ScheduleMod,TerritoryMod,EffectiveMod, Premium,EffectiveDate
ORDER BY YEAR(EffectiveDate), (MONTH(EffectiveDate)), PolicyType
素晴らしい!!!!!!!!!!非常に@ダンスヘンリーありがとう – Oleg