<?xml version='1.0' ?>

 <!-- Taxon details
     XML Report by Graham French, NBN Technical Liaison Officer
      Version 1.1.2 27/08/2009
-->
<CustomReport title="Details for recorded taxa" menupath="NBN"  
description="This report gives details of which taxa have been used for all the records currently in Recorder 6" >
<SQL>
    SELECT t.item_name as TaxonName, tl.item_name AS ListName, tv.taxon_version_key as taxonversionkey, count(toc.taxon_occurrence_key) AS RecordNumber FROM taxon_occurrence toc
    INNER JOIN taxon_determination td ON toc.taxon_occurrence_key = td.taxon_occurrence_key
    INNER JOIN taxon_list_item tli ON td.taxon_list_item_key = tli.taxon_list_item_key
    INNER JOIN taxon_list_version tlv ON tli.taxon_list_version_key = tlv.taxon_list_version_key
    INNER JOIN taxon_list tl ON tlv.taxon_list_key = tl.taxon_list_key
    INNER JOIN taxon_version tv ON tli.taxon_version_key = tv.taxon_version_key
    INNER JOIN taxon t ON tv.taxon_key = t.taxon_key
    WHERE td.preferred = 1
    GROUP BY tl.item_name, t.item_name, tv.taxon_version_key
    ORDER BY TaxonName  
    <Where keytype="Default" />
</SQL>
<Columns>  
    <Column name="TaxonName" width="200" position="1" caption="Taxon Name" />
    <Column name="ListName" width="400" position="2" caption="List Name" />
    <Column name="TaxonVersionKey" width="150" position="3" caption="TaxonVersionKey" />
    <Column name="RecordNumber" width="150" position="4" caption="Number of Records" />
</Columns>
</CustomReport>
