diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalEventMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalEventMapper.xml
index 58cd60d098f..7ccbc6af795 100644
--- a/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalEventMapper.xml
+++ b/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalEventMapper.xml
@@ -181,7 +181,7 @@
- Group by clinical_event.EVENT_TYPE, patient.STABLE_ID
+ Group by clinical_event.EVENT_TYPE, patient.INTERNAL_ID
diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/GenePanelMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/GenePanelMapper.xml
index 96a1d434c15..9b070e64ab1 100644
--- a/src/main/resources/org/cbioportal/persistence/mybatis/GenePanelMapper.xml
+++ b/src/main/resources/org/cbioportal/persistence/mybatis/GenePanelMapper.xml
@@ -121,6 +121,7 @@
WHERE
+ SAMPLE_ID IS NOT NULL AND
genetic_profile.STABLE_ID IN
#{item}
@@ -132,6 +133,7 @@
+ SAMPLE_ID IS NOT NULL
AND NULL
diff --git a/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml
index 4fb339978e2..74a2ac58cd9 100644
--- a/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml
+++ b/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml
@@ -38,7 +38,7 @@
SELECT * FROM (
SELECT sample_derived.sample_unique_id
- FROM sample_profile
+ FROM sample_profile GYMP
JOIN genetic_profile gp ON sample_profile.genetic_profile_id = gp.genetic_profile_id
JOIN cancer_study cs ON gp.cancer_study_id = cs.cancer_study_id
JOIN sample_derived on sample_profile.sample_id = sample_derived.internal_id
@@ -48,8 +48,10 @@
#{studyId}
AND
-
- gp.stable_id LIKE concat('%_', #{genomicProfileId})
+
+
+ gp.stable_id=concat(#{studyId}, '_', #{genomicProfileId})
+