Get the correct output

  • SELECT * 
    FROM #aaa a
    WHERE EXISTS(select * from #aaa b where b.alertid = a.alertid and b.alerttypeid = 4)
    AND EXISTS(select * from #aaa b where b.alertid = a.alertid and b.alerttypeid = 6)
    AND NOT EXISTS(select * from #aaa b where b.alertid = a.alertid and b.alerttypeid not in(4,6))

Viewing post 16 (of 15 total)

You must be logged in to reply to this topic. Login to reply