次のような行を SQL select 句に追加することをお勧めします。
count(distinct case when medication in ('Aspirin', 'Warfarin')
then medication end)
over (partition by patient) as mandatory_meds,
count(distinct case when medication in ('Clopidogrel', 'Prasugrel', 'Ticagrelor')
then medication end)
over (partition by patient) optional_meds,
- 次に、次の条件を SQL where 句に追加します。
and mandatory_meds = 2 and optional_meds >= 1
または、次の方法で Crystal で同様の結果を得ることができます。
- レポートを患者ごとにグループ化する
- 次のような式で、mandatory_meds と呼ばれる結晶式を作成します。
if {myTable.medication} = "Aspirin" or {myTable.medication} = "Warfarin"
then {myTable.medication}
- 次のような式で、optional_meds と呼ばれる結晶式を作成します。
if {myTable.medication} = "Clopidogrel" or {myTable.medication} = "Prasugrel"
or {myTable.medication} = "Ticagrelor" then {myTable.medication}
- 次のようなグループ選択式に条件を追加します。
DistinctCount({@mandatory_meds})=2 and DistinctCount({@optional_meds})>=1