Count Meetings By Org =========================== This script runs from the `OrgSearch BlueToolbar`. It displays a simple list of organizations found on the Organization Search page for which there were meetings during a specified date range, with a count for each organization. When you run the report, you will be prompted for Start and End dates. The report will have three columns: * Organization ID * Organization Name * Number of Meetings And at the bottom of the report will be a count of the organizations included in the report. Only organizations with at least one meeting during the specified date range will be included, so this report could also have been called Count of Organizations with Meetings. This suggests two use cases. .. admonition:: Use Case 1 - Find How Many Classes Were Active in a Past Year You want to see how your current number of youth classes compares with the corresponding number three years ago. It's a simple matter to see how many youth classes are currently active, but how can you tell how many were active in a past year? You do it by seeing how many youth classes had meetings during the date range in interest. .. admonition:: Use Case 2 - Find How Often an Organization Has Met Your church has small groups that meet in homes. You are interested to learn how many meetings each group has had throughout the past year. Select these groups on the Organization Search page and run this report. You will have the information you need. As with all SqlScript reports, you have a `Download to Excel` button. The recommended name is ``CountMeetingsByOrg`` Use the following code to Create the SQL Script. See :doc:`../CreateSqlScript`. .. code-block:: sql --class=StartEndReport select o.OrganizationId, o.OrganizationName, count(*) NumberMeetings from dbo.Meetings m join dbo.Organizations o on o.OrganizationId = m.OrganizationId where o.OrganizationId in (select value from dbo.SplitInts(@orgids)) and convert(date,m.MeetingDate) >= @MeetingDate1 and convert(date,m.MeetingDate) <= @MeetingDate2 and exists (select null from dbo.Attend a where a.MeetingId = m.MeetingId and a.AttendanceFlag = 1) group by o.OrganizationId, o.OrganizationName order by count(*) desc