Get the correct output

  • Jonathan AC Roberts

    SSCoach

    Points: 17273

    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 16 total)

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