<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Forum — Dodgy sort orders?]]></title>
		<link>https://forums.nbn.org.uk/viewtopic.php?id=391</link>
		<atom:link href="https://forums.nbn.org.uk/extern.php?action=feed&amp;tid=391&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Dodgy sort orders?.]]></description>
		<lastBuildDate>Fri, 13 Jul 2007 13:15:07 +0000</lastBuildDate>
		<generator>PunBB 1.4.6</generator>
		<item>
			<title><![CDATA[Re: Dodgy sort orders?]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=1794#p1794</link>
			<description><![CDATA[<p>Thanks Sarah, that makes sense.</p>]]></description>
			<author><![CDATA[null@example.com (charlesroper)]]></author>
			<pubDate>Fri, 13 Jul 2007 13:15:07 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=1794#p1794</guid>
		</item>
		<item>
			<title><![CDATA[Re: Dodgy sort orders?]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=1788#p1788</link>
			<description><![CDATA[<p>Hi Charles</p><p>Needs further investigation, but the key thing to note is that according to the TSD when building the Index_Taxon_Name table, the sort_order is derived from:</p><p>Sort Order from taxon_group table</p><p>&amp;</p><p>the Sort_code from the taxon_list_item table using the <em>recommended_taxon_list_item_key</em> from the nameserver.</p><p>So in the case of TLIk: NBNSYS0000002090 &#039;Hirundo atrocaerulea&#039;</p><p>- the sort order from the taxon_group table is &#039;106&#039; (so far so good)</p><p>- the recommended_taxon_list_item_key from the Nameserver table is &#039;NHMSYS000053396&#039;</p><p>- the sort_code for &#039;NHMSYS000053396&#039; in the Taxon_list_item table is &#039;null&#039; (not so good)</p><p>hence this particular species ends up with a sort_order of &#039;10600000000&#039; in the Index_Taxon_Name table.</p><p>Try running the following query instead:</p><div class="codebox"><pre><code>USE NBNDATA;
SELECT
  ITN.TAXON_LIST_ITEM_KEY,
  ITN.COMMON_NAME,
  ITN.PREFERRED_NAME,
  ITN.SORT_ORDER,
  TXG.SORT_ORDER,
  TLI2.SORT_CODE
FROM
  INDEX_TAXON_NAME ITN
INNER JOIN
  TAXON_LIST_ITEM TLI ON
  ITN.TAXON_LIST_ITEM_KEY = TLI.TAXON_LIST_ITEM_KEY
INNER JOIN
  TAXON_VERSION TXV ON
  TLI.TAXON_VERSION_KEY = TXV.TAXON_VERSION_KEY
INNER JOIN
  TAXON_GROUP TXG ON
  TXV.OUTPUT_GROUP_KEY = TXG.TAXON_GROUP_KEY
INNER JOIN
    NAMESERVER N ON
    TXV.TAXON_VERSION_KEY = N.INPUT_TAXON_VERSION_KEY
INNER JOIN
    TAXON_LIST_ITEM TLI2 ON
    N.RECOMMENDED_TAXON_LIST_ITEM_KEY = TLI2.TAXON_LIST_ITEM_KEY
WHERE
  TXG.TAXON_GROUP_NAME = &#039;bird&#039; AND
  ITN.SORT_ORDER = &#039;10600000000&#039;</code></pre></div><p>Hope that makes sense.</p><p>It&#039;s my first delve into this particular area and i&#039;m not sure why these taxon_list_item_keys don&#039;t have sort_orders.</p><p>John from the NHM may be able to shed some light on this?</p><p>Additional Note: I ran the above query in a 6.9.3 database. However, when I ran a query to find all the rows in Taxon_List_Item table with null sort codes (that are also recommended_taxon_list_item_keys in the Nameserver) in the most recent copy of the dictionary supplied by the NHM there are only 14 entries that potentially cause problems. However, I&#039;ll double check this in an updated copy of the Recorder 6 dictionary and also email John).</p><p>Kind regards,</p><p>Sarah</p><p>Sarah Shaw<br />Biodiversity Information Assistant<br />JNCC</p>]]></description>
			<author><![CDATA[null@example.com (Sarah Shaw)]]></author>
			<pubDate>Thu, 12 Jul 2007 12:28:08 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=1788#p1788</guid>
		</item>
		<item>
			<title><![CDATA[Re: Dodgy sort orders?]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=1785#p1785</link>
			<description><![CDATA[<p>Hi Charles</p><p>Thanks for raising this - I&#039;ll look into it and get back to you.</p><p>Best wishes,</p><p>Sarah</p><p>Sarah Shaw<br />Biodiversity Information Assistant<br />JNCC</p>]]></description>
			<author><![CDATA[null@example.com (Sarah Shaw)]]></author>
			<pubDate>Thu, 12 Jul 2007 09:22:52 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=1785#p1785</guid>
		</item>
		<item>
			<title><![CDATA[Re: Dodgy sort orders?]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=1770#p1770</link>
			<description><![CDATA[<p>There are quite a few other taxa that also have this problem. I assume it&#039;s something to do with the nameserver, no?</p><p>Test using this query:</p><div class="codebox"><pre><code>USE NBNData; 
SELECT
  ITN.TAXON_LIST_ITEM_KEY,
  ITN.COMMON_NAME,
  ITN.PREFERRED_NAME,
  ITN.SORT_ORDER,
  TXG.SORT_ORDER,
  TLI.SORT_CODE
FROM
  INDEX_TAXON_NAME ITN
INNER JOIN
  TAXON_LIST_ITEM TLI ON
  ITN.TAXON_LIST_ITEM_KEY = TLI.TAXON_LIST_ITEM_KEY
INNER JOIN
  TAXON_VERSION TXV ON
  TLI.TAXON_VERSION_KEY = TXV.TAXON_VERSION_KEY
INNER JOIN
  TAXON_GROUP TXG ON
  TXV.OUTPUT_GROUP_KEY = TXG.TAXON_GROUP_KEY
WHERE
  RIGHT(ITN.SORT_ORDER,8) = &#039;00000000&#039; AND
  TLI.SORT_CODE IS NOT NULL</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (charlesroper)]]></author>
			<pubDate>Mon, 09 Jul 2007 15:08:33 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=1770#p1770</guid>
		</item>
		<item>
			<title><![CDATA[Re: Dodgy sort orders?]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=1769#p1769</link>
			<description><![CDATA[<p>I recently noticed a few of our bird records appearing out-of-order (i.e., not in the correct taxonomic order) in reports. On closer inspection, I found that many species have a SORT_ORDER of 10600000000, which would indicate that these species don&#039;t have a SORT_CODE in the TAXON_LIST_ITEM table. However, it seems that they <strong>do</strong> have SORT_CODE, but for some reason, they&#039;re not being correctly generated when building the INDEX_TAXON_NAME.</p><p>Try running the following SQL to see what I mean:</p><div class="codebox"><pre><code>USE NBNData; 
SELECT
  ITN.TAXON_LIST_ITEM_KEY,
  ITN.COMMON_NAME,
  ITN.PREFERRED_NAME,
  ITN.SORT_ORDER,
  TXG.SORT_ORDER,
  TLI.SORT_CODE
FROM
  INDEX_TAXON_NAME ITN
INNER JOIN
  TAXON_LIST_ITEM TLI ON
  ITN.TAXON_LIST_ITEM_KEY = TLI.TAXON_LIST_ITEM_KEY
INNER JOIN
  TAXON_VERSION TXV ON
  TLI.TAXON_VERSION_KEY = TXV.TAXON_VERSION_KEY
INNER JOIN
  TAXON_GROUP TXG ON
  TXV.OUTPUT_GROUP_KEY = TXG.TAXON_GROUP_KEY
WHERE
  TXG.TAXON_GROUP_NAME = &#039;bird&#039; AND
  ITN.SORT_ORDER = &#039;10600000000&#039;</code></pre></div><p>Here&#039;s the first few rows I get back (copy and paste into a text file, save it as a .CSV then open in Excel for optimal viewing):</p><div class="codebox"><pre><code>TAXON_LIST_ITEM_KEY,COMMON_NAME,PREFERRED_NAME,SORT_ORDER,SORT_ORDER,SORT_CODE
NBNSYS0000001839,Aquila heliaca,Aquila heliaca,10600000000,106,85
NBNSYS0000002172,Aquila heliaca,Aquila heliaca,10600000000,106,62
NBNSYS0000002012,Threskiornis aethiopicus subsp. aethiopicus,Threskiornis aethiopicus subsp. aethiopicus,10600000000,106,118
NBNSYS0000002232,Columba palumbus subsp. azorica,Columba palumbus subsp. azorica,10600000000,106,122
NBNSYS0000001967,Gavia immer subsp. immer,Gavia immer subsp. immer,10600000000,106,73</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (charlesroper)]]></author>
			<pubDate>Mon, 09 Jul 2007 13:11:20 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=1769#p1769</guid>
		</item>
	</channel>
</rss>
