############################### GivingTypesValidate SQL Script ############################### This SQL script creates a report for a particular FundSet/RowType/DateRange combination. The report will not run on it's own, but is started via links on the main GivingTypes Python report. Each link corresponds to a particular row and column in the main report. When the link is clicked, this report is run with correct parameters for the row/column and will display all the Contributions that make up that amount along with all the search data. Particularly helpful are the Priority TagName and a column for OtherTags so that it is easy to see which RowTypes a given contribution matched. To install this script, copy all of the code below. Create a new Sql document in Special Content using the name `GivingTypesValidate`. Then paste the code into editor and save. Explanation of the code ======================== .. literalinclude:: Files/Content/GivingTypesValidate.sql :linenos: ``Lines 3-15`` create a view of the ContributionTag table, adding MinPriority (``Line 6``) to the columns. The view rows are limited to a particular @FundSet (``Line 10``) and a to a date range (``Lines 12-14``) by searching the date range tags for a match with ``TagName = 'Gtr' + @DateRange``. The rest of the script pulls from this view and from eight other related tables composing all of the data that can be searched to determine Contibution Types. ``Lines 25-33`` are of particular note because it creates a single column of all the `OtherTags` (other than the Priority Tag) that may match the contribution. This `OtherTags` column uses an advanced technique involving converting matching rows into a single comma-separated, concatenated string using XML. The key to finding these is to search for ``Priority > MinPriority``. ``Line 47`` further limits the rows to only tags for a particular @RowType. This set of data, limited to @FundSet, @DateRange, and @RowType, is very useful when validating the final report.