Hi @Jason_2021 ,
Welcome to Microsoft Q&A!
For this type of problem we recommend that you post CREATE TABLE statements for your tables together with INSERT statements with sample data, enough to illustrate all angles of the problem. We also need to see the expected result of the sample.
Please refer below example and check whether it is helpful to you.
create table Attendance
(Person_ID varchar(10),
Location varchar(10),
DateOfAttendance date)
insert into Attendance values
('John','A','2021-05-01'),
('John','A','2021-06-01'),
('Bob','A','2021-07-01'),
('Dave','A','2021-08-12'),
('Bob','A','2021-08-13')
SET DATEFIRST 7;
select a.Person_ID
from Attendance a
inner join
(select * from Attendance
where DateOfAttendance between DATEADD(wk, -1, DATEADD(DAY, 1-DATEPART(WEEKDAY, GETDATE()), DATEDIFF(dd, 0, GETDATE())))
AND DATEADD(wk, 0, DATEADD(DAY, 0-DATEPART(WEEKDAY, GETDATE()), DATEDIFF(dd, 0, GETDATE())))) b
on a.Person_ID=b.Person_ID and a.Location=b.Location
group by a.Person_ID,a.location
having count(a.DateOfAttendance)=1
Output:
Person_ID
Dave
Best regards,
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.