Skip to content

Commit

Permalink
Sync: 2024-07-21 17:00:37
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelAllen committed Jul 21, 2024
1 parent f04ce61 commit 13af076
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Rock/CheckIn/checkin-code-historical-lookup.md
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
```

0 comments on commit 13af076

Please sign in to comment.