Hi,
I am after a T-SQL (Microsoft SQL 2005) that can do the following.
Ok Table1 Contains
SiteCode Package ID Targeted Installed
--------- ---------- -------- ---------
AA1 P1 1 0
AA1 P2 1 1
AA1 P3 1 0
AA1 P4 1 1
AA2 P1 1 1
AA2 P2 0 0
AA2 P3 1 1
AA3 P1 1 1
AA3 P3 1 1
AA4 P4 1 1
Ok I would like to work out how to do SQL that does the following:
1. Return the sitecode where there any of the result set is Targetd = 1 and Installed = 0.
So the result set I would back is a single row being:
AA1
2. Return the sitecode where only if every record that every Row that is Targeted = 1
also has Installed = 1. (So if there is anything that is Targeted = 1 and Installed = 0
it would be eliminated). So the result I would get back here would be
AA2
3. Return the sitecode where only where every row must match Targeted = 1 and Installed = 1
So the result returned would be:
AA3
Thanks,
Ward.
Our community of experts have been thoroughly vetted for their expertise and industry experience.