-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f04ce61
commit 13af076
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
tags: | ||
- language/sql | ||
- type/reporting | ||
date created: 2024-07-21 16:55:10 | ||
date modified: 2024-07-21 16:59:55 | ||
--- | ||
|
||
# Checkin Code Historical Lookup | ||
|
||
This will find all historical usage of a given checkin code. | ||
|
||
*Note: Every checkin gets assigned a code, even if it doesn't print on the label.* | ||
|
||
## Query | ||
|
||
```sql | ||
DECLARE @Code varchar(max) = 'BMD'; | ||
|
||
SELECT | ||
ac.[IssueDateTime] | ||
,p.[FirstName] | ||
,p.[LastName] | ||
,g.[Name] 'Group' | ||
,l.[Name] 'Location' | ||
,s.[Name] 'Schedule' | ||
FROM | ||
[AttendanceCode] ac | ||
JOIN [Attendance] a ON a.[AttendanceCodeId] = ac.[Id] | ||
JOIN [PersonAlias] pa ON pa.[Id] = a.[PersonAliasId] | ||
JOIN [Person] p ON p.[Id] = pa.[PersonId] | ||
JOIN [AttendanceOccurrence] ao ON ao.[Id] = a.[OccurrenceId] | ||
JOIN [Group] g ON g.[Id] = ao.[GroupId] | ||
JOIN [Location] l ON l.[Id] = ao.[LocationId] | ||
JOIN [Schedule] s ON s.[Id] = ao.[ScheduleId] | ||
WHERE ac.[Code] = @Code | ||
ORDER BY ac.[IssueDateTime] DESC | ||
``` |