sql server - MS SQL Where one column is x or y and both returned -


i have table follows dates in. table has many more records simplified asking purposes:

name     | date       | grade person 1 | 01-01-2001 | b person 1 | 31-01-2001 | person 2 | 01-01-2001 | c person 3 | 31-01-2001 | 

i want return both records person 1 not either of other two. , returns nothing , or returns everything. want search on date not grade or person.

so result be:

name     | date       | grade person 1 | 01-01-2001 | b person 1 | 31-01-2001 | 

one simple way handle aggregate person , assert 2 dates of interest both present:

select t1.* yourtable t1 inner join (     select name     yourtable     date in ('2001-01-01', '2001-01-31')     group name     having count(distinct date) = 2 ) t2     on t1.name = t2.name 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -