MSSQL: Select rows with more than 2 occurrences in another table

前端 未结 1 1580
青春惊慌失措
青春惊慌失措 2021-01-12 12:47

Basically I need to get a list of CampaignTitles that have more than 2 occurrences in StaffOnGrade and list the CampaignTitle, StaffNo who have a Grade rating higher then 2<

相关标签:
1条回答
  • 2021-01-12 13:12
    SELECT campaigntitle, StaffNo, COUNT (CAMPAIGNTITLE) As [count]
      FROM WORKSON
     WHERE StaffNo IN
           (SELECT STAFFNO
              FROM STAFFONGRADE
             WHERE GRADE > 2)
     GROUP BY CAMPAIGNTITLE
    HAVING COUNT(CAMPAIGNTITLE) >2
    
    0 讨论(0)
提交回复
热议问题