<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Trevor Dwyer · sqlartist</title><description>Making SQL Server do things it was never meant to do, and writing about data, retro computing and life.</description><link>https://sqlartist.github.io/</link><item><title>I Built My Head Out of Lego. Inside SQL Server 2025.</title><link>https://sqlartist.github.io/posts/i-built-my-head-out-of-lego-inside-sql-server-2025/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/i-built-my-head-out-of-lego-inside-sql-server-2025/</guid><pubDate>Fri, 16 Oct 2026 11:16:54 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_NFRn5gbVPBwvhrClTJmSnQ.png&quot; alt=&quot;The money shot: the 3D scan on the left, me in Lego on the right. 4,149 bricks in 13 colours, designed from start to finish by SQL Server 2025.&quot;&gt;
&lt;em&gt;The money shot: the 3D scan on the left, me in Lego on the right. 4,149 bricks in 13 colours, designed from start to finish by SQL Server 2025.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_g936iwmJXgNvSLByyRu0Ow.gif&quot; alt=&quot;I could predict the comments if I didn’t give it a brain&quot;&gt;
&lt;em&gt;I could predict the comments if I didn’t give it a brain&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The last time my head went into SQL Server it came out lopsided, 6,000 metres tall and with a stunt rear head. If you missed it, that was the Relational Space Carving article, and I finished it by promising you robot eyes and the beginning of a cloning process.&lt;/p&gt;
&lt;p&gt;The robot eyes are still in a drawer.&lt;/p&gt;
&lt;p&gt;Another time I tried to render my head so that I could create a Metahuman and please do not ask me how this happened, but this came out…&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_ukKfcDRjIEUGdJQP6HhspA.png&quot; alt=&quot;I have no words really, but I think its something to do with an unclosed mesh.&quot;&gt;
&lt;em&gt;I have no words really, but I think its something to do with an unclosed mesh.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Instead, I asked myself a much simpler question. &lt;strong&gt;Is there any clever maths behind Lego?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I was expecting the answer to be “not really, it’s plastic”. It turns out there is, and nearly all of it is something a relational database is already very good at. So, the plan became: store Lego bricks in SQL Server, build something simple, then build something hard. And the hardest thing I could think of was me.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;I approached the next section from two directions:&lt;/p&gt;
&lt;h2 id=&quot;create-from-a-simple-front-facing-photo&quot;&gt;Create from a simple front-facing photo&lt;/h2&gt;
&lt;p&gt;I feed a standard 2D photograph of my own face into SQL Server 2025 and have pure T-SQL sculpt, colour-match, hollow out, interlock, and export a life-size, physically buildable 3D Lego bust.&lt;/p&gt;
&lt;p&gt;No Python. No C#. No external mesh slicers. Just an uncompressed bitmap, and a relational schema&lt;/p&gt;
&lt;h2 id=&quot;create-from-an-existing-objfile&quot;&gt;Create from an existing OBJ file&lt;/h2&gt;
&lt;p&gt;Create the Lego head from an existing 67 MB OBJ of my head. Everything that follows (loading it, turning it into bricks, colouring it and writing out a file Lego’s own design software can open) runs in T-SQL on SQL Server 2025.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;how-it-wasdone&quot;&gt;How it was done&lt;/h2&gt;
&lt;h2 id=&quot;option-2&quot;&gt;Option 2&lt;/h2&gt;
&lt;h3 id=&quot;the-lego-grid-is-all-integers-if-you-pick-the-rightunit&quot;&gt;The Lego grid is all integers, if you pick the right unit&lt;/h3&gt;
&lt;p&gt;A Lego stud is 8 mm from the next one. A brick is 9.6 mm tall. A plate is 3.2 mm, a third of a brick.&lt;/p&gt;
&lt;p&gt;The bit I love is this. Five plates stacked up is 16 mm, which is exactly two studs. That 5:2 ratio is why you can build sideways (“studs not on top”, if you’re a proper adult fan of Lego) and everything still lines up.&lt;/p&gt;
&lt;p&gt;For a database person that’s wonderful news. Store X and Z in studs and Y in brick layers and &lt;strong&gt;every coordinate is an integer&lt;/strong&gt;. No floating point, no tolerances, and every “does this touch that?” question becomes an equality join. LDraw, the open file format the whole Lego CAD world runs on, does the same thing: 20 units per stud, 24 per brick, 8 per plate.&lt;/p&gt;
&lt;p&gt;There’s one trap, and I nearly fell straight into it. &lt;strong&gt;A 1×1 brick is not a cube.&lt;/strong&gt; It’s 8 × 8 × 9.6 mm. Chop a model into cubes, call each one a brick, and your head comes out 20% too tall. Mine is long enough already and the first time I did this I looked like the statues on Easter Island.&lt;/p&gt;
&lt;h3 id=&quot;two-24-bricks-24-ways-and-burnsides-lemma&quot;&gt;Two 2×4 bricks, 24 ways, and Burnside’s lemma&lt;/h3&gt;
&lt;p&gt;The most famous bit of Lego maths is counting. How many ways can you join six 2×4 bricks? Lego quoted roughly 103 million for years. Then in 2005 a mathematician, Søren Eilers, actually counted them properly: &lt;strong&gt;915,103,765&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Six is far too many to brute-force in a query. Two is perfect, though, and it’s a lovely bit of maths.&lt;/p&gt;
&lt;p&gt;Fix the bottom brick. Slide the top brick over it, either parallel or turned 90 degrees, keeping at least one stud in contact. That gives 46 positions. But spin the whole thing round 180 degrees and some of those positions turn into each other, so they aren’t different builds.&lt;/p&gt;
&lt;p&gt;Burnside’s lemma says the number of genuinely different builds is the average number of positions each rotation leaves unchanged. Doing nothing leaves all 46 alone. The 180-degree turn leaves only the 2 positions that are dead centre. (46 + 2) / 2 = 24.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TopBrick &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, l &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;             -- parallel&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UNION ALL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;           -- turned 90 degrees&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Placement &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, dx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, dz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TopBrick &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; b&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GENERATE_SERIES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; x&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GENERATE_SERIES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; z&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;     -- the footprints overlap in X...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;     -- ...and in Z&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; RawPlacements  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       FixedBy180     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;IIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; dx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; dz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; l &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       DistinctBuilds &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;IIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; dx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; dz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; l &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Placement;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;RawPlacements  FixedBy180  DistinctBuilds&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;- - - - - - - - - - - - - - - - - - - - - &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;46             2           24&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Have a look at that WHERE clause. “Do these two bricks overlap?” is exactly the “do these two date ranges overlap?” test every SQL developer has written a hundred times, once for each direction. That turns out to be the theme of this whole article. &lt;strong&gt;Lego problems keep turning into SQL problems we already know.&lt;/strong&gt;&lt;/p&gt;
&lt;h3 id=&quot;something-simple-first-ornot&quot;&gt;Something simple first. Or not.&lt;/h3&gt;
&lt;p&gt;My original plan was a little Lego minifigure first, then my head. Then I realised a minifigure isn’t brick-built at all. It’s a handful of moulded parts, so there’s nothing to calculate. The classic six-brick duck (which ties in nicely with those 915 million) or a Benchy would be better, and they’re coming next time.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The next time is when I create a complete 3D Printer Slicer sending directly to a PRUSA CORE ONE filament printer, again all in Transact-SQL.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;I went straight for the head. Of course I did.&lt;/p&gt;
&lt;h3 id=&quot;loading-a-67-mb-obj-file-with-string_split&quot;&gt;Loading a 67 MB OBJ file with STRING_SPLIT&lt;/h3&gt;
&lt;p&gt;An OBJ file is just text:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;v  -0.089426 0.033380 -0.017880 &amp;lt;- a vertex&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;vt  0.074025 0.377586           &amp;lt;- a texture coordinate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;f   1/1/1    2/2/2     3/3/3    &amp;lt;- a triangle: vertex/texture/normal&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The catch is that faces point at vertices by &lt;strong&gt;their position in the file&lt;/strong&gt;. The first `v` line is vertex 1, the second is vertex 2, and so on. So, line order matters, and `BULK INSERT` into a table doesn’t promise you the order. `STRING_SPLIT` with its `enable_ordinal` argument does:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @doc &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; BulkColumn&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; OPENROWSET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(BULK &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;D:\_Articles\lego\Trevor_3d_Head3.obj&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SINGLE_CLOB&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; f;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; LineNum &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ordinal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Line&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Line&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; STRING_SPLIT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@doc, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s          &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- the 1 switches on the ordinal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;v %&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;vt %&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;f %&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* the nth &quot;v&quot; line is vertex n */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; obj&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Vertex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (MeshID, VertexID, X, Y, Z)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @MeshID,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;       ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LineNum&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;       CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(REGEXP_SUBSTR(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Line&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;\S+&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; float&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;       CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(REGEXP_SUBSTR(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Line&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;\S+&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; float&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;       CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(REGEXP_SUBSTR(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Line&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;\S+&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; float&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Line&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; l&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Line&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;v %&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That’s `REGEXP_SUBSTR`, new in SQL Server 2025, pulling the 2nd, 3rd and 4th words out of each line.&lt;/p&gt;
&lt;p&gt;My first run failed instantly. I had called the line-number column `LineNo`, and it turns out `LINENO` is a reserved word in T-SQL. Thirty years, and I never knew. Later, I did exactly the same thing by calling a variable `by`. Also reserved. Obviously.&lt;/p&gt;
&lt;p&gt;Second run: &lt;strong&gt;343,220 vertices and 686,435 triangles in 28 seconds.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;My head is in metres, Y is up and my face points along +Z. It measures 18 × 29 × 24 cm. That’s including the neck, I should add.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Is my head watertight? Euler’s formula is a GROUP BY&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Before you turn a mesh into bricks you want to know it’s a closed surface. No holes for the inside to leak out of.&lt;/p&gt;
&lt;p&gt;There’s a lovely bit of 18th-century maths for this. For anything shaped like a sphere,&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;V − E + F = 2&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;vertices, minus edges, plus faces. That’s Leonhard Euler. And in a watertight mesh every edge is shared by exactly two triangles.&lt;/p&gt;
&lt;p&gt;Both checks are a `GROUP BY`:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Edge &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; A &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LEAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;B&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), B &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GREATEST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;B&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; obj&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Face&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; f&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;V1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;V2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;V2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;V3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;V3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;V1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e(A, B)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; A, B, Uses &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)      &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- 1 = the edge of a hole, 2 = fine, 3+ = something weird&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Edge&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; A, B;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;V      E       F      BoundaryEdges NonManifoldEdges Euler&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;343220 1029653 686435 2             1                2&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Euler says 2. Two edges out of just over a million belong to only one triangle. I’ll take that.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;turning-my-head-into-bricks-is-a-windowfunction&quot;&gt;Turning my head into bricks is a window function&lt;/h3&gt;
&lt;p&gt;Here’s the core idea. It’s the same idea my 3D printers’ slicer uses to fill in each layer.&lt;/p&gt;
&lt;p&gt;Fire a ray straight through my head along every row of the brick grid. Each time the ray crosses the surface it goes outside → inside → outside → inside. Sort the crossings along the ray, pair them up (1st with 2nd, 3rd with 4th) and everything between a pair is solid head.&lt;/p&gt;
&lt;p&gt;Finding where a ray hits a triangle is barycentric coordinates in a `CROSS APPLY`. Pairing the crossings up is `ROW_NUMBER()` and `LEAD()`, and filling in the bricks between them is `GENERATE_SERIES`:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Ray &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; j, k, t,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           n    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; j, k &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           tOut &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LEAD&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(t)      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; j, k &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           Hits &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; j, k)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Hit&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; lego&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Voxel&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (ModelID, X, Y, Z)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ModelID, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;k&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Ray &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; r&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GENERATE_SERIES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CEILING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; int&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FLOOR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;tOut&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; int&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; i&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; % &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;                -- entering the solid&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hits&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; % &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;             -- a ray that leaks through a hole is skipped&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CEILING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; FLOOR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;tOut&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;One subtle thing. If a ray passes &lt;em&gt;exactly&lt;/em&gt; through a vertex or along an edge it gets counted twice, and inside and outside swap places. So, I nudge every ray about a micron off the exact grid. After that, any ray with an odd number of crossings must have leaked through a hole, and it gets skipped.&lt;/p&gt;
&lt;p&gt;At life size: &lt;strong&gt;619 rays, 1,256 crossings, zero odd rays, in under a second.&lt;/strong&gt; Out came 8,331 1×1 bricks on a 23 × 31 × 30 grid.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_ms5wNrclr3HTxOsYFReHpg.png&quot; alt=&quot;8,331 1×1 bricks. You can already see the ears, the nose in profile and the flared neck cut.&quot;&gt;
&lt;em&gt;8,331 1×1 bricks. You can already see the ears, the nose in profile and the flared neck cut.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_v4-U99BQTHHKh7qKnXqXfQ.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;hollowing-my-head-peel-theonion&quot;&gt;Hollowing my head: peel the onion&lt;/h3&gt;
&lt;p&gt;Nobody builds a solid Lego head. You build a shell.&lt;/p&gt;
&lt;p&gt;So, every brick gets a Depth. Depth 1 is any brick touching empty space. Depth 2 is any brick touching a Depth 1, and so on. A WHILE loop peels the onion one layer at a time until nothing changes. Mathematically it’s a discrete distance transform. In SQL it’s an `UPDATE … WHERE EXISTS` over six neighbour offsets.&lt;/p&gt;
&lt;p&gt;My head is 11 layers deep at the thickest point (insert your own joke here). A hollow shell two studs thick is simply `WHERE Depth &amp;lt;= 2`: 3,340 bricks instead of 8,331.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Merging bricks is the date-range overlap query&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;3,340 1×1 bricks would be miserable to build and wouldn’t hold together. Real Lego sculptures use 2×4s, 2×8s, 1×3s and so on.&lt;/p&gt;
&lt;p&gt;So, it goes biggest part first. Find every spot where a 2×8 fits, with all its cells free and the same colour. Those candidates overlap each other, so in each round I keep only the ones that no better-ranked candidate overlaps. The best candidate on each layer always wins, so every round makes progress. In graph theory that’s building a maximal independent set in rounds. In SQL it’s the date-range query again, once per axis:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Cand &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                  FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Cand &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; o&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                  WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Pri&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Pri&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SizeX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SizeX&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SizeZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SizeZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Even layers prefer bricks running across, odd layers prefer bricks running front to back. That way the joints in one layer are always covered by the bricks above. Proper brickwork bond, like a garden wall.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;15 rounds, half a second, 731 bricks.&lt;/strong&gt; Then I checked it the way you should check anything you’re proud of: zero overlapping bricks, zero missing cells, zero extra cells.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_ms5wNrclr3HTxOsYFReHpg.png&quot; alt=&quot;Life size, 731 bricks, hollow. In the side view you can see the alternating layers.&quot;&gt;
&lt;em&gt;Life size, 731 bricks, hollow. In the side view you can see the alternating layers.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Getting it out: LDraw is a SELECT&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;LDraw is a text format with one line per brick: colour, position, a 3×3 rotation matrix and the part number. `3001.dat` is the classic 2×4.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CONCAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;1 &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ColourID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SizeX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;cx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,          &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- x: centre of the footprint&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;y0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 24&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,                       &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- y: top of the layer (Y is down)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SizeZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;cz&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,         &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- z: flipped so the face is at the front&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;       IIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SizeX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SizeZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;1 0 0 0 1 0 0 0 1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,       &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- long side along X as drawn...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;                               &apos;0 0 1 0 1 0 -1 0 0&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),     &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- ...or turned 90 degrees&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;       &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PartID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;.dat&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;0 Trevor head (2x life size)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;0 Author: LegoSQL on SQL Server 2025&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;1 19 -20 -24 -70 1 0 0 0 1 0 0 0 1 3008.dat&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;1 19 90 -24 -70 1 0 0 0 1 0 0 0 1 3622.dat&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;0 STEP&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A couple of gotchas. LDraw’s Y axis points &lt;em&gt;*down*&lt;/em&gt;, and a brick’s origin is the centre of its top face. Flipping Y and Z together gives you a 180-degree turn rather than a mirror image. Mirror-image me would be very unsettling.&lt;/p&gt;
&lt;p&gt;Put a `0 STEP` line after each layer and the file should become layer-by-layer building instructions in BrickLink Studio, for free. (Spoiler: it does. More on that at the end.)&lt;/p&gt;
&lt;h3 id=&quot;life-size-was-a-disappointment&quot;&gt;Life size was a disappointment&lt;/h3&gt;
&lt;p&gt;At life size my face is only 23 studs across, so the features are just one or two bricks deep. It’s a head. It isn’t obviously &lt;em&gt;*my*&lt;/em&gt; head.&lt;/p&gt;
&lt;p&gt;So: `@Scale = 2.0`. That gives 66,645 voxels on a 45 × 61 × 60 grid, a 14,544-cell shell and &lt;strong&gt;2,969 bricks, in about 3 seconds&lt;/strong&gt;. Brow, eye sockets, nose, mouth, chin and ears all come through.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_xBgS_dUV1I1btJuyRnYIQA.png&quot; alt=&quot;2× life size, before colour. The three-quarter view is where it starts to look like me.&quot;&gt;
&lt;em&gt;2× life size, before colour. The three-quarter view is where it starts to look like me.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;colour-the-texture-that-wasntthere&quot;&gt;Colour: the texture that wasn’t there&lt;/h3&gt;
&lt;p&gt;The OBJ pointed at a material file that wasn’t in the folder. When I found it, it had no texture in it at all. The colour lived in the original Blender file, with four images packed inside it: the 4096 × 4096 Base Colour map, plus a metallic/roughness map, a normal map and an emission map.&lt;/p&gt;
&lt;p&gt;Getting it out cost me five minutes of staring at a Blender process that had used five seconds of CPU and was doing absolutely nothing. Running it headless with ` — factory-startup -noaudio` sorted that out. This is the one step outside SQL Server I had to take: a tiny Blender script finds whatever image feeds Base Colour and saves it as a 1024 × 1024, 24-bit BMP.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_RE-swfEc4Q9314-kcSAMGQ.png&quot; alt=&quot;My face as a texture atlas. A patchwork quilt of skin, stubble and the occasional eyeball.&quot;&gt;
&lt;em&gt;My face as a texture atlas. A patchwork quilt of skin, stubble and the occasional eyeball.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;a-bmp-is-just-substring-again&quot;&gt;A BMP is just SUBSTRING (again)&lt;/h3&gt;
&lt;p&gt;If you read the Space Carving article, you’ll know I’ve been here before. You’ll also know about my 32-bit alpha channel disaster. This time it’s 24-bit. I learned my lesson.&lt;/p&gt;
&lt;p&gt;SQL Server can’t decode a JPEG or a PNG. But a 24-bit BMP is just a 54-byte header followed by raw pixels: bottom row first, three bytes each, stored Blue-Green-Red, with each row padded out to a multiple of 4 bytes. So `OPENROWSET(… SINGLE_BLOB)` plus `SUBSTRING` is a perfectly good image decoder:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Stride &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@W &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;      &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- each row is padded to 4 bytes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; obj&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Texel&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (MeshID, PX, PY, R, G, B)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @MeshID, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;       CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@bmp, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Byte0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; tinyint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),     &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- stored B, G, R&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;       CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@bmp, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Byte0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; tinyint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;       CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@bmp, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Byte0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; tinyint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GENERATE_SERIES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @W &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @H &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; g&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; % @W, PY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @W) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; xy&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; xy&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;xy&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Byte0 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Offset &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; xy&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Stride &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; xy&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;1,048,576 pixels in 6 seconds.&lt;/strong&gt; I spot-checked three of them against Python’s imaging library and they were identical.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Is that actually my face? Checking the UVs&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The OBJ had been exported from an earlier version of the Blender file (“Head2”), and the texture came from a later one (“Head3”). If the texture coordinates didn’t match, I’d be painting an ear onto my forehead.&lt;/p&gt;
&lt;p&gt;So before trusting anything, I splatted every triangle onto a flat image, coloured from the texture through its UVs.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_LUVhUB3FrCqp8YK26EsqvA.png&quot; alt=&quot;Eyes, nose, beard and ears, all exactly where they should be.&quot;&gt;
&lt;em&gt;Eyes, nose, beard and ears, all exactly where they should be.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;nearest-colour-is-vector_distance&quot;&gt;Nearest colour is VECTOR_DISTANCE&lt;/h3&gt;
&lt;p&gt;Now for the fun part. For every one of the 686,435 triangles:&lt;/p&gt;
&lt;p&gt;- its centre’s texture coordinate picks a pixel, which gives a colour&lt;br&gt;
 — its centre’s position picks a grid cell, which gives a brick&lt;br&gt;
 — its area is the weight&lt;/p&gt;
&lt;p&gt;Each brick’s colour is the area-weighted average of all the triangles that land on it, snapped to the nearest real Lego colour.&lt;/p&gt;
&lt;p&gt;“Nearest” has to be measured the way eyes see colour, not in RGB, so everything is converted to CIELAB first. And this is where SQL Server 2025 really is necessary. Every Lego colour is stored as a `VECTOR(3)`, and finding the nearest one is just this:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ColourID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; lego&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Colour&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;InPalette&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; VECTOR_DISTANCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;euclidean&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Lab&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @pixel);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That’s a feature Microsoft built for AI embeddings, being used to choose between Medium Nougat and Dark Tan 😊&lt;/p&gt;
&lt;p&gt;The first result was… camouflage.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_bDEwEsIPFN4XUJoJVvrqzA.png&quot; alt=&quot;First attempt. Me, in army camouflage.&quot;&gt;
&lt;em&gt;First attempt. Me, in army camouflage.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;There were two problems. Stubble averaged with skin came out as Dark Tan, which is a sort of olive green, so my cheeks went military. And my skin was far too dark, because the scan had its lighting baked into the texture. A typical skin pixel was around 48 on the Lab lightness scale. In a photo of the real me it’s nearer 74.&lt;/p&gt;
&lt;p&gt;I tried a “dominant colour” mode, where each brick takes whichever Lego colour covers most of its area rather than the average. It’s sharper, but it lost the tiny dark pupils, so I went back to the average.&lt;/p&gt;
&lt;p&gt;The real fixes were two parameters:&lt;/p&gt;
&lt;p&gt;- &lt;strong&gt;A portrait palette.&lt;/strong&gt; An `InPalette` flag on the colour table. Out go Red, Blue, Yellow and that olive Dark Tan.&lt;br&gt;
 — &lt;strong&gt;Exposure.&lt;/strong&gt; Multiply the Lab lightness before snapping to a colour.&lt;/p&gt;
&lt;p&gt;Here’s one skin pixel before and after:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Exposure 1.0  Exposure 1.25&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Name          Distance Name          Distance&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Medium Brown  8.5      Medium Nougat 13.3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Sand Red      10.3     Nougat        15.6&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Medium Nougat 14.8     Medium Tan    17.5&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_cYuJamqrhlplM_7pDVtuNw.png&quot; alt=&quot;Exposure 1.0, 1.25 and 1.45. At 1.45 my forehead starts turning into white bricks.&quot;&gt;
&lt;em&gt;Exposure 1.0, 1.25 and 1.45. At 1.45 my forehead starts turning into white bricks.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So, 1.25 it is. Proper skin tones, eyes with irises, the grey goatee and the grey sides of the buzz cut.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;into-bricklink-studio&quot;&gt;Into BrickLink Studio&lt;/h3&gt;
&lt;p&gt;Then I did the thing I’d been putting off. I installed BrickLink Studio and opened the file SQL Server had written.&lt;/p&gt;
&lt;p&gt;4,149 bricks, each one exactly where a SELECT statement put it, in the right colour and the right way round. And, unlike last time, no head 6,000 metres tall.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_4OnnP4l-qgUO74JQYuFnOw.png&quot; alt=&quot;Rendered in BrickLink Studio. Every brick placed by a SELECT statement.&quot;&gt;
&lt;em&gt;Rendered in BrickLink Studio. Every brick placed by a SELECT statement.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;And here’s the build, from the very first brick.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_E6LXi37XcoO0Tbx3Ch5Igw.gif&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;And those `0 STEP` lines? Studio turned them into proper building instructions: &lt;strong&gt;61 steps across 16 pages&lt;/strong&gt;, one step per layer, with the parts for each layer in a box at the top, exactly like a real Lego manual.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_oQhhf4wJ_QFQ9JZDkZUqBw.png&quot; alt=&quot;Steps 41 to 44 of 61. SQL Server wrote my building instructions.&quot;&gt;
&lt;em&gt;Steps 41 to 44 of 61. SQL Server wrote my building instructions.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;the-bill-of-materials-what-does-my-head-cost-on-bricklink&quot;&gt;The Bill of Materials: What Does My Head Cost on BrickLink?&lt;/h2&gt;
&lt;p&gt;The greedy mesher compressed &lt;strong&gt;65,204 raw studs&lt;/strong&gt; down to &lt;strong&gt;15,274 interlocked plates&lt;/strong&gt;, for an estimated BrickLink total of &lt;strong&gt;£576.19&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Two statistics jump right out on the Bill of Materials&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;The Red Core Savings:&lt;/strong&gt; Just &lt;strong&gt;1,157 Red 2 × 8 plates&lt;/strong&gt; swallowed &lt;strong&gt;18,512 individual interior studs&lt;/strong&gt; inside my cranium — eliminating over 17,000 parts and costing just &lt;strong&gt;£23.14&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Price of a Salt-and-Pepper Beard:&lt;/strong&gt; Why are the top three rows of the Bill of Materials dominated by 1 × 1 and 1 × 2 &lt;em&gt;Light&lt;/em&gt; and &lt;em&gt;Dark Bluish Gray&lt;/em&gt; plates (£239.16 worth of tiny grey pieces)? Because every fleck of grey hair in my beard and temples alternates pixel-by-pixel. The greedy mesher refused to merge adjacent grey and brown voxels into larger plates, preserving the exact dithered texture of the beard.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The one bit I’m not happy with is the chin. On the scan it’s a grey goatee. In Lego it’s a brown patch with a black hole under the jaw. That’s the shadow under my chin, baked into the texture and now faithfully reproduced in plastic. SQL Server did exactly what I asked it to. It always does. That’s the problem.&lt;/p&gt;
&lt;h3 id=&quot;i-have-nobrain&quot;&gt;I have no brain&lt;/h3&gt;
&lt;p&gt;Then I watched the build animation again and noticed something. About a third of the way in, the camera looks straight down into my head, and there’s nothing there. Two studs of wall and a lot of fresh air.&lt;/p&gt;
&lt;p&gt;I’d built myself without a brain. Brian could have told you that.&lt;/p&gt;
&lt;p&gt;So, a new plan for a video. Build the head almost to the top. Stop. Rewind back down to about half way. Grow a brain inside. Then close the skull back over it. And, obviously, do the whole thing in SQL Server.&lt;/p&gt;
&lt;h3 id=&quot;growing-a-brain-is-three-ellipsoids-and-asquare&quot;&gt;Growing a brain is three ellipsoids and a SQUARE()&lt;/h3&gt;
&lt;p&gt;A Lego brain, it turns out, is three shapes:&lt;/p&gt;
&lt;p&gt;- &lt;strong&gt;the cerebrum&lt;/strong&gt;, a big ellipsoid filling the top of the skull&lt;br&gt;
- &lt;strong&gt;the cerebellum&lt;/strong&gt;, a smaller one tucked in low at the back&lt;br&gt;
- &lt;strong&gt;the brain stem&lt;/strong&gt;, a cylinder that carries on down through my neck as the spinal cord. Turns out I do have a backbone.&lt;/p&gt;
&lt;p&gt;Everything is placed relative to my head’s own bounding box (0 to 1 across, up, and front to back), so the same numbers work at any scale. An ellipsoid is just x² + y² + z² ≤ 1 with each axis stretched, so `SQUARE()` did all the anatomy:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Part &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;u&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;41&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;74&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;19&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;45&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;38&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;cerebrum&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;u&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;27&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;57&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;08&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;17&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;cerebellum&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;u&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;07&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;29&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;05&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BETWEEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;07&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;62&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;stem&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ModelID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @HeadModelID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Depth&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Gap              &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- inside the 2-brick skull, plus a gap&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Remember the onion peel? It pays off again here. “Inside my skull” is simply `Depth &amp;gt; 2`, and I leave one more empty layer between skull and brain. That gap is my cerebrospinal fluid. Technically it’s air, but it’s air with a medical name.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The folds&lt;/strong&gt; are where it got interesting. A smooth pink blob doesn’t say “brain”. Wrinkles do. So, I made a wiggly 3D wave (three sine waves, each one wobbled by another) and cut a groove wherever it crosses zero.&lt;/p&gt;
&lt;p&gt;My first attempt said, “close to zero counts”, and it came out as a pink blob with a rash. Scattered speckles, no lines. The wave changes faster than one brick, so a “near zero” test skips straight over cells. The fix is to ask a better question: &lt;em&gt;*is the wave positive here and negative next door?*&lt;/em&gt; That gives an unbroken line one brick wide, every time:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Depth&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;                                              -- surface bricks only&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; lego&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;BrainWave&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Scale, @k) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;           -- positive here...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  AND&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;              FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; d(dx, dy, dz)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;              WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; lego&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;BrainWave&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dy&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dz&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Scale, @k) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- ...negative next door&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The bricks exposed at the bottom of each groove turn Dark Pink, there’s a slot down the middle between the two halves, and the stem is Light Pink. All three colours are flagged `InPalette = 0`, so no query will ever decide my cheeks are Dark Pink.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2,287 bricks of brain&lt;/strong&gt;: 1,409 Pink, 711 Dark Pink and 167 Light Pink.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_dRsoCbYgavndbHsPkkl62A.png&quot; alt=&quot;2,287 bricks of brain, with the spinal cord heading off down my neck.&quot;&gt;
&lt;em&gt;2,287 bricks of brain, with the spinal cord heading off down my neck.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-videos-script-is-aselect&quot;&gt;The video’s script is a SELECT&lt;/h3&gt;
&lt;p&gt;This is the bit I’m pleased about because the whole video, every brick appearing, disappearing and coming back, is a table.&lt;/p&gt;
&lt;p&gt;Every brick gets up to three frame numbers: &lt;strong&gt;T1&lt;/strong&gt; when it first appears, &lt;strong&gt;T2&lt;/strong&gt; when it’s rewound away, and &lt;strong&gt;T3&lt;/strong&gt; when it comes back. The renderer shows a brick when:&lt;/p&gt;
&lt;p&gt;(frame &amp;gt;= T1 AND frame &amp;lt; T2) OR frame &amp;gt;= T3&lt;/p&gt;
&lt;p&gt;The bricks below the half-way point only ever get a T1. The ones between half way and the top get all three. The brain, and the very top of my head, only ever appear once.&lt;/p&gt;
&lt;p&gt;The frame numbers are `ROW_NUMBER()` divided by a bricks-per-frame rate. Within each layer the bricks go in order of their angle around the middle (`ATN2`), so every layer sweeps round like the hand of a clock. And the rewind is literally the same query with `DESC` on the end:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* A. Build the head up to the stop layer */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; A &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; T1, n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Y, Angle) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #T &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ModelID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @HeadModelID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Stop)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; A &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; T1 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @f &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @BuildRate;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* B. Rewind: the same bricks, backwards, faster */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; B &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; T2, n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Angle &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #T &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ModelID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @HeadModelID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Back &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Stop)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; B &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; T2 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @EndA &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @RewindRate;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Phase    FromFrame ToFrame Layers&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;A build  1         264     0–53&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;B rewind 294       337     53–36&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;C brain  352       542     all&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;D finish 572       698     36–60&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;lights-camerablender&quot;&gt;Lights, camera, Blender&lt;/h3&gt;
&lt;p&gt;SQL Server can’t render video. Yet. So Blender reads the script, and every brick and every stud becomes a Geometry Nodes instance: 6,436 bricks and 20,389 studs, as two clouds of points. A handful of nodes check the same `T1`/`T2`/`T3` rule on every frame. Each brick drops into place from 3.5 cm up, and in the rewind they lift back off, like a tape running backwards.&lt;/p&gt;
&lt;p&gt;On my RTX 5090 that’s about a second a frame in Cycles. 854 frames, 28.5 seconds of video, about a quarter of an hour.&lt;/p&gt;
&lt;p&gt;The failures, as is tradition:&lt;/p&gt;
&lt;p&gt;- &lt;strong&gt;The first test frames were so overexposed&lt;/strong&gt; I looked like I’d been carved out of a bar of soap. The fix was to let the camera see a bright white backdrop while the bricks are lit by a much dimmer version of it.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Rewinding to exactly half way cut off my eyes&lt;/strong&gt;, and the brain ended up floating above the stump like a pink lollipop on a stick. Half of the &lt;em&gt;*head*&lt;/em&gt; (not counting the neck) is eye level, 58% of the way up. With the eyes back, the brain sits in the skull like it should.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_AJwTtJ8eWKT8PEikYxlzgg.png&quot; alt=&quot;Build. Nearly there. Hang on. Rewind. Grow a brain. Close the skull. Spin.&quot;&gt;
&lt;em&gt;Build. Nearly there. Hang on. Rewind. Grow a brain. Close the skull. Spin.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_g936iwmJXgNvSLByyRu0Ow.gif&quot; alt=&quot;The whole thing. Every frame of it decided by a SELECT statement.&quot;&gt;
&lt;em&gt;The whole thing. Every frame of it decided by a SELECT statement.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Last time I promised you a cloning process. Growing my own brain out of a SELECT statement is as close as I’m going to get.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-finalnumbers&quot;&gt;The final numbers&lt;/h3&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt; |                                | Life size | 2× life size |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; | - - - - - - - - - - - - - - - - - - -      | - - - - - - -|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; | 1×1 voxels                     | 8,331     | 66,645       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; | Hollow shell (2 studs)         | 3,340     | 14,544       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; | Bricks, uncoloured             | 731       | 2,969        |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; | Bricks, coloured               | 1,061     | 4,149        |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; | Colours                        | 11        | 13           |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; | Building steps (one per layer) | 30        | 61           |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice that colour costs bricks. A brick can only be one colour, so every colour boundary chops the big bricks up. Life size went from 731 bricks to 1,061.&lt;/p&gt;
&lt;p&gt;The 2× parts list is a fun read: 1,224 1×1 bricks, 1,187 1×2s and 770 2×2s. The biggest colour by a mile is Light Bluish Grey, with 1,057 bricks. Apparently, I am mostly grey. Bit depressing.&lt;/p&gt;
&lt;p&gt;Add the brain and it’s &lt;strong&gt;6,436 bricks&lt;/strong&gt;. A third of them are brain. I’m choosing to be flattered by that.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;whats-next&quot;&gt;What’s next&lt;/h3&gt;
&lt;p&gt;- &lt;strong&gt;Fix my chin.&lt;/strong&gt; Probably by keeping Medium Brown out of the beard, or by switching to dominant colour just for that area.&lt;br&gt;
- &lt;strong&gt;Will it fall apart?&lt;/strong&gt; Every brick needs to connect to the bricks below it through at least one stud. That’s a graph reachability problem, and SQL Server has graph tables and `SHORTEST_PATH`.&lt;br&gt;
- &lt;strong&gt;Actually building it.&lt;/strong&gt; 4,149 small plastic bricks and Brian the sausage dog in the same house. That’s a problem for future me.&lt;/p&gt;
&lt;p&gt;And the robot eyes are still in the drawer.&lt;/p&gt;
&lt;p&gt;Hope you enjoyed the article, and the failures. I’ll get the code up on GitHub.&lt;/p&gt;
&lt;p&gt;Trevor (@sqlartist)&lt;/p&gt;
</content:encoded><category>Brain</category><category>SQL</category><category>Animation</category><category>Lego</category><category>Vector Database</category></item><item><title>Order! Order!</title><link>https://sqlartist.github.io/posts/order-order/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/order-order/</guid><pubDate>Wed, 14 Oct 2026 10:32:20 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_mPZLv8icTl8C05RLe-Dqiw.jpeg&quot; alt=&quot;I wouldn’t trust any one of them.&quot;&gt;
&lt;em&gt;I wouldn’t trust any one of them.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;the-question&quot;&gt;The question&lt;/h2&gt;
&lt;p&gt;When I put 1.7 million speeches through two graphics cards to see whether ministers ever steal the Opposition’s ideas, one thing kept nagging at me. It wasn’t the speeches. It was the man in the big chair, shouting “Order!” every few minutes.&lt;/p&gt;
&lt;p&gt;How often does the Speaker actually have to step in? Leave the parties to their own devices and they become a rabble. Everyone knows that. But how much of a rabble, and has it changed?&lt;/p&gt;
&lt;p&gt;So I asked SQL Server.&lt;/p&gt;
&lt;h2 id=&quot;why-a-hypercube&quot;&gt;Why a hypercube&lt;/h2&gt;
&lt;p&gt;My website already has a toy on it: every story I’ve written, placed inside a rotating four-dimensional cube. I wanted to give it something worth looking at.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_wxmxdBCWzJ2DbKUje1uaPg.png&quot; alt=&quot;The Hypercube — a 4D OLAP Cube analysing articles on my website.&quot;&gt;
&lt;em&gt;The Hypercube — a 4D OLAP Cube analysing articles on my website.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Here’s the thing most people don’t know. SQL Server has had a hypercube built in since 2008. &lt;code&gt;GROUP BY CUBE&lt;/code&gt; takes a list of dimensions and works out every combination of them in one statement. Give it five (year, Speaker, type of business, party, Government or Opposition) and it computes all 32 ways of slicing the House, from the finest detail right up to the grand total.&lt;/p&gt;
&lt;p&gt;I made one rule for myself. The database does the thinking. The viewer only draws what SQL Server worked out, and it never adds anything up itself.&lt;/p&gt;
&lt;h2 id=&quot;my-visit-to-thechambers&quot;&gt;My Visit to the Chambers&lt;/h2&gt;
&lt;p&gt;I almost forgot about this, but I have been to the House of Commons as a guest of a friend and his charitable work. We were to have dinner with Peter Lilly, one of the MP’s who sat in Margret Thatchers cabinet. It was an interesting visit.&lt;/p&gt;
&lt;p&gt;I arrive and go through the many security gates and arrive in the main building, we then have a quick tour — first to the House of Commons where we weren’t allowed to sit on the seats — by this time my back had gone and I was in terrible pain so I just kept thinking — whats the harm, but I observed the rules.&lt;/p&gt;
&lt;p&gt;Before we went into the chamber there is a life size statue of Sir Winston Churchill in Bronze, its aged but his left foot is shiny, I asked why and apparently people touch his foot for luck when they enter the chamber.&lt;/p&gt;
&lt;p&gt;The House of Lords was closed that day so we went down into the depths of the building and ended up in a dinning room over looking the Thames. It was at this point I realised I was the only person in the entire group of 20 that wasn’t wearing a tie. Londoners don’t wear ties these days, except in a few places and this was one of them.&lt;/p&gt;
&lt;p&gt;I sat directly opposite the &lt;a href=&quot;https://www.peterlilley.co.uk/about/&quot;&gt;Rt Hon Lord Lilley&lt;/a&gt;, and it was interesting as I only eat bread at these functions — I never want to eat under cooked lamb or a shrimp starter so I stick with bread. towards the end of the meal I want to smoke, so I go to leave and it turns out I need an escort. An armed Police Officer with an MP5 machine gun escorted me all the way to the main entrance, I smoked and he escorted me all the way back. At this point I saw people were chatting and I happened to be standing next to Peter Lilly and I remarked to him that I though his body of work was astounding. He was quite taken back. I had read every one of his ministerial papers the night before and back then I had a very decent memory. So I ended up chatting, with no tie to Margret Thatchers’ Minister for quite some time. All because regardless what he was actually like as an MP, but because he quite obviously believed in the data and that was evident in the huge amount of papers he had published and that meant in my eyes he was “a decent guy”.&lt;/p&gt;
&lt;h2 id=&quot;my-first-numbers-werewrong&quot;&gt;My first numbers were wrong&lt;/h2&gt;
&lt;p&gt;I started with the data I already had, the 1.7 million speeches from the vector search work. The first results came back and looked lovely. Bercow intervened more than anyone. Opposition and Government were treated much the same. I nearly wrote it up.&lt;/p&gt;
&lt;p&gt;Then the cracks showed. The years 2002 to 2004 were almost empty. The speeches weren’t in the order they were spoken. And when I went back to the source, Evan Odell’s &lt;em&gt;Hansard Speeches 1979–2021&lt;/em&gt;, it had 2.7 million rows, not 1.7.&lt;/p&gt;
&lt;p&gt;The missing million told the story. To build embeddings, I’d thrown away every speech too short to mean anything. And what’s the shortest speech in Parliament? “Order.” My cleaned-up dataset had quietly kept about a quarter of everything the Chair ever said. I was measuring the Speaker with most of the Speaker removed.&lt;/p&gt;
&lt;p&gt;That’s the lesson I’d pass on. Data you prepared for one question will happily answer a different one, and it won’t tell you it’s wrong. It’ll give you a neat answer.&lt;/p&gt;
&lt;p&gt;Getting it back was satisfying. Every row in the source carries a TheyWorkForYou ID that records the sitting, the column and the paragraph, which is the true order of speaking. I matched my speeches back to it by date and their first 80 characters. 1,700,614 out of 1,700,647 paired up, in 34 seconds. Then I loaded the whole source instead, all 2.7 million rows, procedural lines and all.&lt;/p&gt;
&lt;p&gt;I also wrote a second version of the counting rules in Python, whose only job was to disagree with the SQL. It found a bug on day one. “Order. Order.” was being counted once, because the full stop that ends the first call is also the one that starts the second. Two implementations, one argument, one fix. It’s the same trick that saved me on the AS/400.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* =====================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Order! Order!  -  Commons Hypercube&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   00_adapter.sql : maps the HANSARD database onto what the build needs.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Source tables (already in HANSARD from the Hansard vector work):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     dbo.speech         one row per Commons speech, 1979 onwards&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     dbo.speaker_party  each speaker&apos;s main party - fills in speeches&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;                        where dbo.speech.party is NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     dbo.gov_period     who governed when - the same definition of&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;                        &quot;Government&quot; the Hansard article used&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Seq: speech_id is NOT in sitting order (diagnostic H). The real&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     order comes from the source dataset (Odell, Hansard Speeches&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     1979-2021, biglam/hansard_speech): each row&apos;s TheyWorkForYou id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     carries sitting, column and paragraph. python/load_source_order.py&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     loads those ids into hc.SourceOrder, EXEC hc.usp_MatchOrder (07)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     pairs them with dbo.speech into hc.SpeechOrder. Until then Seq is&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     NULL and &quot;who had the floor&quot; is left Unknown rather than guessed.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Also check:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     - The table is Commons only. If Lords rows are in there, filter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       them out in the WHERE clause below.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   ===================================================================== */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;USE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [HANSARD];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SCHEMA_ID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;hc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXEC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;CREATE SCHEMA hc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* The source&apos;s own order, loaded by python/load_source_order.py.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Created here (and never dropped by later scripts) because the view&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   below needs it to exist. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; OBJECT_ID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;hc.SourceOrder&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.SourceOrder&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Gid          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,  &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- uk.org.publicwhip/debate/1979-05-24a.1254.1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SittingDate  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Sitting      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,              &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- the &apos;a&apos; after the date&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ColNum       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Para         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeechClass  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,                  &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Speech | Procedural | ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeakerName  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    TextKey      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;80&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;               -- first 80 non-space characters&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; OBJECT_ID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;hc.SpeechOrder&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.SpeechOrder&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    speech_id   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Seq         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,                &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- position within the sitting day&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Gid         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; VIEW &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vSpeech&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeechId     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SittingDate  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_date&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Seq          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Seq&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,                             &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- NULL until hc.usp_MatchOrder has run&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeechClass  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Speech&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),      &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- dbo.speech holds speeches only&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- headings arrive wrapped in tabs and line breaks (&apos;\n\tPRIME MINISTER\n  &apos;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    MajorHeading &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; TRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;13&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LEFT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;major_heading&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    MinorHeading &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; TRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;13&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LEFT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;minor_heading&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeakerName  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LEFT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speaker_name&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PersonId     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;person_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Party        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;COALESCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LTRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RTRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;party&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;main_party&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;200&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- the post they held when they spoke: the reliable way to spot a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- Deputy Speaker who is printed under their own name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ParlPost     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LEFT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;pp&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;parl_post&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;500&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;500&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Body         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(max))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;LEFT JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_post&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; pp&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; pp&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;LEFT JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechOrder&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; o&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;LEFT JOIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- one main party per name; the biggest wins if a name appears twice&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; speaker_name, main_party,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           rn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; speaker_name &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rows_in_main &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speaker_party&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; sp&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; sp&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speaker_name&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speaker_name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; sp&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;rn&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* &quot;Government&quot; comes from dbo.gov_period, inclusive at both ends as&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   in dbo.usp_who_said_it_later. One party per period: if 2010-15 is&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   stored as Conservative only, Lib Dems count as Opposition then.   */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; VIEW &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vGovernment&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FromDate &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; date_from,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       ToDate   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; date_to,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       Party    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(gov_party &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;gov_period&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* Sanity check: one row per speech, sensible dates. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- SELECT COUNT_BIG(*) AS Speeches, MIN(SittingDate) AS FirstDay, MAX(SittingDate) AS LastDay,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;--        COUNT(DISTINCT SittingDate) AS SittingDays&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- FROM hc.vSpeech;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* =====================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Order! Order!  -  Commons Hypercube&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   00b_adapter_full.sql : the alternative to 00_adapter.sql.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Points hc.vSpeech at hc.SourceSpeech - the whole of Odell&apos;s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   &quot;Hansard Speeches 1979-2021&quot;, loaded by python/load_source_full.py.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Every speech and procedural line, 2001-04 included, in sitting order,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   with party and parliamentary posts as they were at the time.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Run order:  00b (creates the table)  -&amp;gt;  load_source_full.py&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;               -&amp;gt;  00b again is harmless  -&amp;gt;  01, 02, 03  -&amp;gt;  06&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   To go back to dbo.speech, just run 00_adapter.sql again.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   ===================================================================== */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;USE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [HANSARD];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SCHEMA_ID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;hc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXEC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;CREATE SCHEMA hc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; OBJECT_ID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;hc.SourceSpeech&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.SourceSpeech&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Id           &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;        IDENTITY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Gid          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNIQUE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,       &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- uk.org.publicwhip/debate/1979-05-24a.1254.1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SittingDate  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Seq          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,              &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- sitting letter, column, paragraph&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeechClass  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,                  &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Speech | Procedural | ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeakerName  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,                  &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- as printed: &apos;Mr. Speaker&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    DisplayAs    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PersonId     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Party        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;200&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    MajorHeading &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    MinorHeading &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ParlPost     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;500&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Body         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(max) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ix_day (SittingDate, Seq)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; VIEW &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vSpeech&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeechId     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SittingDate  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Seq          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Seq&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeechClass  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechClass&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    MajorHeading &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; TRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;13&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MajorHeading&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    MinorHeading &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; TRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;13&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MinorHeading&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeakerName  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeakerName&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PersonId     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PersonId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Party        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LTRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RTRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Party&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ParlPost     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ParlPost&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Body         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Body&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SourceSpeech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; VIEW &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vGovernment&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FromDate &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; date_from, ToDate &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; date_to, Party &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(gov_party &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;gov_period&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;from-keeping-order-to-keepingtime&quot;&gt;From keeping order to keeping time&lt;/h2&gt;
&lt;p&gt;With the whole record in place, the Chair intervened about 61,000 times in 42 years. Here’s how often, per 1,000 speeches by Members:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Bernard Weatherill (1983–92): 36.&lt;/strong&gt; Nearly 13 interventions on an average sitting day. The most policed House of the lot.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Betty Boothroyd (1992–2000): 30.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Michael Martin (2000–09): 26.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;George Thomas (1976–83): 24.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;John Bercow (2009–19): 19.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So the man everyone remembers shouting “Order!” was, by this measure, the least interventionist of the lot. That’s the opposite of what my first, broken numbers said.&lt;/p&gt;
&lt;p&gt;But Bercow was busy with something else. Telling people to get on with it: “short questions and short answers”, “be brief”, “there is a lot of interest”. Under Thomas, Weatherill and Boothroyd that came up less than once per 1,000 speeches. Under Martin it was about one. Under Bercow it was 3.6, and in 2018 it hit 4.8.&lt;/p&gt;
&lt;p&gt;The job changed. In the 1980s the Chair was keeping order. By the 2010s it was keeping time, trying to get as many Members in as possible before the clock ran out. Whatever else you think of Bercow, and there’s a lot to think, he was known for trying to call everyone who stood up.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_zZCbEdkZFqoXjvJHUnPU8g.jpeg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;the-government-lost-its-protection&quot;&gt;The Government lost its protection&lt;/h2&gt;
&lt;p&gt;This was the finding I didn’t expect, and it only appeared once the speeches were back in their proper order.&lt;/p&gt;
&lt;p&gt;For every intervention I worked out who had the floor at the time: the last Member to speak before the Chair stood up. Then I compared Government and Opposition, per 1,000 of their own speeches.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Thomas:&lt;/strong&gt; the Opposition was pulled up &lt;strong&gt;2.0 times&lt;/strong&gt; as often as the Government.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Weatherill:&lt;/strong&gt; &lt;strong&gt;2.1 times.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Boothroyd:&lt;/strong&gt; &lt;strong&gt;1.6 times.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Martin:&lt;/strong&gt; &lt;strong&gt;1.3 times.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bercow:&lt;/strong&gt; &lt;strong&gt;1.1 times.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Forty years ago, sitting opposite the Government roughly doubled your chances of hearing “Order!”. By the Bercow years it barely mattered which side you sat on.&lt;/p&gt;
&lt;p&gt;And it’s the side, not the party. Labour MPs were told off most under Weatherill, when they were in opposition. Under Martin, with Labour in government, the Conservatives took over. Whoever sits opposite gets the shouting.&lt;/p&gt;
&lt;p&gt;There’s a caveat here. The Opposition raises most of the points of order, and “That is not a point of order” counts as an intervention. Some of the old gap is just the machinery of opposition. But points of order are a small slice of the total, and the gap closes steadily across five Speakers. Something real changed.&lt;/p&gt;
&lt;h2 id=&quot;two-casts&quot;&gt;Two casts&lt;/h2&gt;
&lt;p&gt;Averages over 2.7 million speeches smooth everything out. The good stuff is in the people. So I split the Chair’s interventions in two. &lt;strong&gt;Personal&lt;/strong&gt; means sit down, withdraw that remark, or being named. &lt;strong&gt;At the House&lt;/strong&gt; means the Chair telling everyone else to be quiet. Then there’s Hansard’s own little stage direction, &lt;em&gt;[Interruption.]&lt;/em&gt;, which tells you the House was shouting while someone spoke.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* =====================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Order! Order!  -  Commons Hypercube&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   02_build.sql : hc.usp_Build turns hc.vSpeech into two fact tables.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     hc.Speech     one row per speech, no body: who, when, what kind of&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;                   business, their party and side, and - for the Chair -&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;                   who had the floor when it spoke.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     hc.ChairFlag  one row per (Chair speech, Category) that matched.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   EXEC hc.usp_Build;          -- full rebuild&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   ===================================================================== */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;USE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [HANSARD];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DROP&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IF&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairFlag&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Speech&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeechId     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SittingDate  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Yr           &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;smallint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Seq          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,      &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- NULL = position in the day unknown&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Member | Speaker | Deputy | Committee | Floor | Procedural&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    RoleSource   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Title | Post | Party | None&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Interrupts   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- &apos;[Interruption.]&apos; marks in the speech&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeakerName  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PersonId     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Party        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- canonical; &apos;Chair&apos;/&apos;House&apos; for non-members&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Side         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Government | Opposition | Unknown | Chair | House&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Reign        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    DebateType   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- who had the floor (the last Member to speak that day before this one)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    TargetName   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    TargetPerson &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    TargetParty  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    TargetSide   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ix_day (SittingDate, Seq)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.ChairFlag&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SpeechId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Category &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Family   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Hits     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (SpeechId, Category)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PROCEDURE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_Build&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOCOUNT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; XACT_ABORT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t0 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;datetime2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SYSDATETIME&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    TRUNCATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairFlag&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    TRUNCATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* -----------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       1. Classify every distinct heading pair once, not 1.7M times.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       ----------------------------------------------------------------- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DROP&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IF&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Heading;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MajorHeading&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MinorHeading&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           DebateType &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COALESCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateType&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                          CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MinorHeading&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MajorHeading&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;%[A-Z]%&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MajorHeading&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; COLLATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Latin1_General_CS_AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                  =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; UPPER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MajorHeading&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;COLLATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Latin1_General_CS_AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                               THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;Questions&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;                          N&apos;Other debate&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   #Heading&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT DISTINCT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; MajorHeading &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MajorHeading, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                           MinorHeading &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MinorHeading, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vSpeech&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; h&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    OUTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateType&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                 FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateTypePattern&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                 WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Field&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Major&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Either&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MajorHeading&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Pattern&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Field&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Minor&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Either&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MinorHeading&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Pattern&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                 ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Priority&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNIQUE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NONCLUSTERED&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; INDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ix &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Heading (MajorHeading, MinorHeading);  &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- nonclustered: 1,700-byte key limit&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* -----------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       2. One row per speech: role, party, side, reign, debate type.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       ----------------------------------------------------------------- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (SpeechId, SittingDate, Yr, Seq, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, RoleSource, Interrupts,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                      SpeakerName, PersonId, Party, Side, Reign, DebateType)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;YEAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Seq&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Source&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           Interrupts &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Body&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;%[[]Interruption%&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                             THEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DATALENGTH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Body&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; DATALENGTH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Body&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;[Interruption&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                  /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; DATALENGTH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;[Interruption&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                             ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeakerName&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PersonId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Party&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           Side &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Speaker&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Deputy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Committee&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Chair&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Floor&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Procedural&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)            &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;House&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Party&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;Unknown&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                        THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Unknown&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    WHEN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vGovernment&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; g&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                 LEFT JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PartyAlias&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ga &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ga&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Raw&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Party&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                 WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COALESCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ga&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Canon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Party&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Party&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                   AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BETWEEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FromDate&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ToDate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                                                     THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Government&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    ELSE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Opposition&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                  END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           rg&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speaker&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateType&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vSpeech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    LEFT JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PartyAlias&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Raw&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Party&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; rg&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FromDate&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; rg&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ToDate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* Who is in the Chair, in order of trust:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;         1. the printed title    &apos;Mr. Deputy Speaker&apos;, &apos;The Chairman&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;         2. the post they held   parl_post &apos;Speaker of the House of Commons&apos; / &apos;Deputy Speaker ...&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;         3. party &apos;Speaker&apos; - only if the name is the reigning Speaker&apos;s, because&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;            older rows carry party &apos;Speaker&apos; on the wrong people (&apos;Mr. Denzil Davies&apos;) */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    OUTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TitleRole &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairName&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                     WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeakerName&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Pattern&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                     ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Priority&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        PostRole  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ParlPost&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;%Speaker of the House of Commons%&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Speaker&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                         WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ParlPost&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;%Deputy Speaker%&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                  THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Deputy&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        PartyRole &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Canon&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;Speaker&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                          AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeakerName&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;%&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; rg&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speaker&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;%&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Speaker&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rr&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- unattributed procedural lines (&apos;Question put and agreed to.&apos;) are nobody&apos;s speech&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COALESCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;rr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TitleRole&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;rr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PostRole&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;rr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PartyRole&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                          CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechClass&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Procedural&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Procedural&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;                                          &apos;Member&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        Source &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; rr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TitleRole&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IS NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Title&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                      WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; rr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PostRole&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  IS NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Post&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                      WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; rr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PartyRole&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IS NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Party&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                      ELSE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;None&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; r&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Party &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Speaker&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Deputy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Committee&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;Chair&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Floor&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Procedural&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)            &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;House&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LEFT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;COALESCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Canon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LTRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RTRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Party&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Unknown&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                 END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Heading &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; h&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MajorHeading&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MajorHeading&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MinorHeading&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MinorHeading&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* -----------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       3. Who had the floor? For every speech, the most recent Member&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;          to speak that day. LAG ... IGNORE NULLS (SQL Server 2022+)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;          skips over the Chair and the shouting.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       ----------------------------------------------------------------- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- everyone off the floor starts as &apos;Unknown&apos;; placed speeches get a real target below&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UPDATE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TargetParty &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;Unknown&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, TargetSide &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Unknown&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Member&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SpeechId, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               TName   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LAG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Member&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(SpeakerName, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;?&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IGNORE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULLS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                             OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SittingDate &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Seq, SpeechId),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               TPerson &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LAG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Member&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(PersonId, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;?&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IGNORE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULLS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                             OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SittingDate &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Seq, SpeechId),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               TParty  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LAG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Member&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Party &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IGNORE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULLS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                             OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SittingDate &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Seq, SpeechId),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               TSide   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LAG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Member&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Side &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IGNORE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULLS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                             OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SittingDate &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Seq, SpeechId)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Seq &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;          -- no guessing: unplaced speeches keep &apos;Unknown&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TargetName   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TName&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;?&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           TargetPerson &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TPerson&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;?&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           TargetParty  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TParty&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Unknown&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           TargetSide   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TSide&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,  &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Unknown&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Member&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* -----------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       4. What did the Chair say? Only Chair speeches are scanned, and&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;          each is normalised once and tested against every pattern.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;          Hits = occurrences, counted with the REPLACE length trick.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       ----------------------------------------------------------------- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairFlag&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (SpeechId, Category, Family, Hits)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Category&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Family&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DATALENGTH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Norm&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; DATALENGTH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Norm&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Pattern&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;               /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; DATALENGTH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Pattern&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vSpeech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fnNorm&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Body&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;InterventionPattern&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Norm&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;%&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Pattern&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;%&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;COLLATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DATABASE_DEFAULT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Speaker&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Deputy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Committee&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Category&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* -----------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       5. Report.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       ----------------------------------------------------------------- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Step &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;built&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           Speeches       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT_BIG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           ChairSpeeches  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT_BIG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Speaker&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Deputy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Committee&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           Interruptions  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Interrupts &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           ChairByPost    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT_BIG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; RoleSource &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Post&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           PlacedInOrder  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT_BIG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Seq &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           Interventions  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DISTINCT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SpeechId) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairFlag&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Family &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Discipline&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           OrderCalls     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Hits &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairFlag&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Category &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;ORDER&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           Seconds&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; DATEDIFF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;second&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @t0, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SYSDATETIME&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;());&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The building the cube itself.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* =====================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Order! Order!  -  Commons Hypercube&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   03_cube.sql : GROUP BY CUBE over five dimensions.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   SQL Server has had a hypercube built in since 2008. GROUP BY CUBE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   computes every combination of the dimensions in one statement:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   five dimensions = 2^5 = 32 grouping sets, from &quot;every year, every&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Speaker, every party...&quot; down to the single grand total.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Dimensions : Year, Reign (which Speaker), DebateType, Party, Side&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Measures   : member speeches (the denominator), Chair interventions&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;                and their kinds, outbursts from the floor, and rates&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;                per 1,000 member speeches - all computed here, so the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;                viewer only ever draws what the database worked out.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   EXEC hc.usp_BuildCube;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   EXEC hc.usp_ExportCube;             -- one row, one JSON document&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   ===================================================================== */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;USE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [HANSARD];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DROP&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IF&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeDim&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.CubeCell&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    GroupingId     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- GROUPING_ID bitmask, 0 = finest grain&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Dims           &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;tinyint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- how many dimensions this cell keeps&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Yr             &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Reign          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    DebateType     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Party          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Side           &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    MemberSpeeches &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ChairSpeeches  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Interventions  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Chair speeches with any Discipline flag&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    BySpeaker      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- ... of which the Speaker personally&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    OrderCalls     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- every &quot;Order.&quot; counted&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SitDown        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Withdraw       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Named          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Suspended      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Noise          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Hurry          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- &quot;be brief&quot;, &quot;short questions&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    FloorOutbursts &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- &apos;[Interruption.]&apos; marks + &quot;Hon. Members:&quot; rows&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    RateInterventions &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;decimal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,    &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- per 1,000 member speeches&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    RateOrder         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;decimal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    RateHurry         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;decimal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    RateFloor         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;decimal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.CubeDim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Dim     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SortKey &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Dim, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PROCEDURE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_BuildCube&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOCOUNT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    TRUNCATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    TRUNCATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeDim&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; flags &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SpeechId,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               Disc     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Family   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Discipline&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               OrderHit &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Category &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;ORDER&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      THEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Hits &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               SitDown  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Category &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;SEAT&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               Withdraw &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Category &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;WITHDRAW&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               Named    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Category &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;NAME&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               Susp     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Category &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;SUSPEND&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               Noise    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Category &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;NOISE&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               Hurry    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Family   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Hurry&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairFlag&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SpeechId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    facts &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;        -- the denominator: every Member&apos;s speech, under their own party&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Yr, Reign, DebateType, Party, Side,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               Msp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Csp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Itv &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Bsp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Ord &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Sdn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Wdr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Nmd &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Sus &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Nse &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Hry &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               Flr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Interrupts                     &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- &apos;[Interruption.]&apos; while they spoke&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Member&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;        -- the Chair, filed under whoever had the floor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Yr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateType&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TargetParty&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TargetSide&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Disc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;               CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Speaker&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Disc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;OrderHit&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SitDown&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Withdraw&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Named&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Susp&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Noise&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hurry&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Interrupts&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        LEFT JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; flags &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; f &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Speaker&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Deputy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Committee&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;        -- the House shouting, filed under whoever had the floor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Yr, Reign, DebateType, TargetParty, TargetSide,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Floor&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        (GroupingId, Dims, Yr, Reign, DebateType, Party, Side,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;         MemberSpeeches, ChairSpeeches, Interventions, BySpeaker, OrderCalls,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;         SitDown, Withdraw, Named, Suspended, Noise, Hurry, FloorOutbursts)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GROUPING_ID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Yr, Reign, DebateType, Party, Side),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           5&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GROUPING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Yr) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GROUPING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Reign) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GROUPING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(DebateType)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GROUPING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Party) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GROUPING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Side)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Yr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), Reign, DebateType, Party, Side,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Msp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Csp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Itv &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Bsp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Ord &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Sdn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Wdr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Nmd &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Sus &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Nse &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Hry &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Flr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; facts&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CUBE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Yr, Reign, DebateType, Party, Side);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* Every base row has a real value on every dimension (hc.usp_Build&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       fills gaps with &apos;Unknown&apos;), so a NULL here always means &quot;rolled up&quot;. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UPDATE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; RateInterventions &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Interventions  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MemberSpeeches, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; decimal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           RateOrder         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; OrderCalls     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MemberSpeeches, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; decimal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           RateHurry         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Hurry          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MemberSpeeches, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; decimal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           RateFloor         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FloorOutbursts &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MemberSpeeches, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; decimal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;));&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* Axis order for the viewer: years in order, Speakers in order,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;       business from PMQs downwards, parties by how much they speak. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeDim&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Dim, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, SortKey)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Year&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Yr, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Yr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; int&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; GroupingId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 15&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt; /* Year only */&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Yr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS NOT NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Reign&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speaker&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ReignId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; r &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speaker&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;DebateType&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateType&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Priority&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateTypePattern&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateType&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateType&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;99&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GroupingId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 27&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt; /* DebateType only */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Party&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Party&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MemberSpeeches&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GroupingId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 29&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt; /* Party only */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Side&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Side&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Side&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Government&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Opposition&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GroupingId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 30&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt; /* Side only */&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Step &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;cube built&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           Cells        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT_BIG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           GroupingSets &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DISTINCT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; GroupingId)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* ---------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   The whole cube as one JSON document for the viewers.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Rolled-up dimensions are NULL, and FOR JSON leaves NULLs out, so&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   each cell&apos;s &quot;d&quot; object holds exactly the dimensions it keeps.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   @MinSpeeches drops cells too small to have a meaningful rate.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   --------------------------------------------------------------------- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PROCEDURE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_ExportCube&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @MinSpeeches &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOCOUNT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CubeJson &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            title     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;Order! Order!&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            source    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;Hansard, House of Commons&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            generated&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CONVERT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;19&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SYSDATETIME&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;126&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            dimensions &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; JSON_QUERY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; name&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       [values] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; JSON_QUERY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                            SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [value] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                            FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeDim&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                            WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                            ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SortKey&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                            FOR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; JSON&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PATH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Year&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Reign&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;DebateType&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Party&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Side&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; d(Dim, Ord)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Ord&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                FOR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; JSON&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PATH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            measures &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; JSON_QUERY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(N&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;                {&quot;key&quot;:&quot;rateInterventions&quot;,&quot;label&quot;:&quot;Interventions per 1,000 speeches&quot;},&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;                {&quot;key&quot;:&quot;rateOrder&quot;,&quot;label&quot;:&quot;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;Order!&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; per 1,000 speeches&quot;},&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;                {&quot;key&quot;:&quot;rateHurry&quot;,&quot;label&quot;:&quot;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;Be brief&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; per 1,000 speeches&quot;},&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;                {&quot;key&quot;:&quot;rateFloor&quot;,&quot;label&quot;:&quot;[Interruption] per 1,000 speeches&quot;},&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;                {&quot;key&quot;:&quot;interventions&quot;,&quot;label&quot;:&quot;Interventions (count)&quot;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;            ]&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            cells &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; JSON_QUERY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [d.Year]       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Yr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       [d.Reign]      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       [d.DebateType] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateType&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       [d.Party]      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Party&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       [d.Side]       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Side&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       speeches          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MemberSpeeches&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       chair             &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairSpeeches&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       interventions     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Interventions&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       bySpeaker         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;BySpeaker&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       orderCalls        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;OrderCalls&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       sitDown           &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SitDown&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       withdraw          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Withdraw&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       named             &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Named&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       suspended         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Suspended&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       noise             &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Noise&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       hurry             &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hurry&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       [floor]           &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FloorOutbursts&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       rateInterventions &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateInterventions&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       rateOrder         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateOrder&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       rateHurry         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateHurry&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                       rateFloor         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateFloor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MemberSpeeches&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @MinSpeeches&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                FOR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; JSON&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PATH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FOR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; JSON&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PATH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITHOUT_ARRAY_WRAPPER&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    );&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* =====================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Order! Order!  -  Commons Hypercube&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   04_findings.sql : the questions the article asks. Run after&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   hc.usp_Build and hc.usp_BuildCube. Each query stands alone.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   ===================================================================== */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;USE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [HANSARD];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* 0. Is there anything to report? Rerunning 02 or 03 recreates their&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      tables empty, so the builds have to be run again afterwards. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ViewRows   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT_BIG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vSpeech&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       SpeechRows &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT_BIG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       ChairFlags &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT_BIG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairFlag&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       CubeCells  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT_BIG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    RAISERROR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;hc.Speech is empty: run EXEC hc.usp_Build; then EXEC hc.usp_BuildCube;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IF&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    RAISERROR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;hc.CubeCell is empty: run EXEC hc.usp_BuildCube;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* 1. Which Speaker had the rowdiest House?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      Per 1,000 member speeches and per sitting day, with the Speaker&apos;s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      own interventions split from the deputies&apos;. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       Speeches        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MemberSpeeches&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       SittingDays     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Days&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       Interventions   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Interventions&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       PerThousand     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateInterventions&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       PerSittingDay   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Interventions&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Days&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; decimal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       SpeakerOwnShare &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;BySpeaker&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Interventions&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; decimal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       OrderPerK       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateOrder&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       HurryPerK       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateHurry&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       FloorPerK       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateFloor&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       Named           &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Named&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       Suspended       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Suspended&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Reign, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Days&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DISTINCT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SittingDate) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Reign) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; d&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; r &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speaker&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GroupingId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 23&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;   -- Reign only&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ReignId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* 2. Is PMQs louder than everything else? Each Speaker, each kind of business. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateType&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MemberSpeeches&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateInterventions&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateFloor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; r &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speaker&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GroupingId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 19&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;   -- Reign x DebateType&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MemberSpeeches&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 500&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ReignId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateInterventions&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* 3. The cameras. The Commons was first televised on 21 November 1989,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      in the middle of Weatherill&apos;s time - same Speaker, before and after.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      Three years before, and the rest of his time after (about 2.5 years),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      so the comparison isn&apos;t a change of Chair. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Era &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;1989-11-21&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;1 Before cameras&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;2 After cameras&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Interrupts&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;1986-11-21&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;1992-04-27&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Era&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       Speeches      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Member&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       Interventions &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DISTINCT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Family&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Discipline&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       PerThousand   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DISTINCT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Family&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Discipline&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                        /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Member&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; decimal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       InterruptPerK &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Member&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Interrupts&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                        /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Member&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; decimal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OUTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;cf&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Family&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairFlag&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; cf&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;             WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; cf&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; cf&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Family&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Discipline&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; f&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Era&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Era&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* 4. Who gets told off: Government or Opposition? Under each Speaker.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      Needs hc.usp_MatchOrder (or the full source) - depends on who had the floor. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Side&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MemberSpeeches&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Interventions&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateInterventions&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateFloor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; r &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speaker&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GroupingId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 22&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;   -- Reign x Side&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Side&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Government&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Opposition&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ReignId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Side&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* 5. Year by year: the line for the article&apos;s main chart. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Yr, MemberSpeeches, Interventions, RateInterventions, RateOrder, RateHurry, RateFloor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; GroupingId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 15&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;     -- Year only&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Yr;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* 6. The rowdiest days in the Commons since 1979. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;       s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;       s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       Interventions &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DISTINCT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Family&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Discipline&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       OrderCalls    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Category&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;ORDER&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hits&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       Interruptions &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Interrupts&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; x&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                        WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       Business      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateType&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; x&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                        JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairFlag&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                        WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                        GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateType&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairFlag&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; f &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Interventions &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* 7. The nuclear option: every naming, and who had the floor.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      (&quot;I name the hon. Member for ...&quot; - then a vote to suspend.)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      Check each one by eye: the pattern can catch &quot;I name names&quot;. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeakerName&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Chair, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TargetName&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TargetParty&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DebateType&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speech&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ChairFlag&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; f &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpeechId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Category&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;NAME&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SittingDate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* 8. Each party, under each Speaker: interventions per 1,000 of their speeches.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      Needs hc.usp_MatchOrder (or the full source) - depends on who had the floor. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Party&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MemberSpeeches&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateInterventions&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateFloor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; r &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speaker&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GroupingId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 21&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;   -- Reign x Party&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MemberSpeeches&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2000&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ReignId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateInterventions&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* 9. &quot;Be brief&quot;: which Speaker nagged most about time? */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hurry&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RateHurry&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CubeCell&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; hc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; r &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Speaker&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Reign&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GroupingId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 23&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ReignId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;the-ones-the-chair-had-to-reinin&quot;&gt;The ones the Chair had to rein in&lt;/h2&gt;
&lt;p&gt;The House got more forgiving over time. Personal rebukes ran at about 1.6 per 1,000 speeches in the late 1980s and about 0.4 in the 2010s. So I measured everyone against the years they actually sat. A score of 1 means normal for your era, and 10 means ten times the norm. Minimum 500 speeches:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Ron Brown: 21 times&lt;/strong&gt; his era’s rate, and named three times. Yes, the mace man.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ian Blackford: 19 times.&lt;/strong&gt; Hold that thought.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Andrew Faulds: 13 times.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;David Shaw: 12 times&lt;/strong&gt;, a rare Conservative near the top.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;George Galloway: 11 times.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The rest of the list is mostly the Labour awkward squad of the 1980s: Eric Heffer, Dick Douglas, Norman Buchan, Allan Rogers. That’s the old Opposition gap again, seen from the other end. Tam Dalyell holds the record for being named, four times.&lt;/p&gt;
&lt;p&gt;And Dennis Skinner? Named three times, and more than 10,000 speeches over 40 years. But measured against his era he scores 6, not even top 25. The Beast of Bolsover’s reputation is bigger than his record. He was just there, every day, for a very long time.&lt;/p&gt;
&lt;h2 id=&quot;the-ones-the-house-wouldnt-letspeak&quot;&gt;The ones the House wouldn’t let speak&lt;/h2&gt;
&lt;p&gt;Now rank by &lt;em&gt;[Interruption]&lt;/em&gt;, adjusted the same way, and a completely different cast appears. Party leaders, and especially Opposition leaders.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;David Owen: 5.0 times&lt;/strong&gt; the House’s norm. That’s what the two big parties thought of the SDP.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Neil Kinnock: 5.0.&lt;/strong&gt; Thatcher, across 16,000 speeches, was well below him.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ed Miliband: 4.7.&lt;/strong&gt; He’s also the leader the Chair most often stepped in to protect.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Keir Starmer: 4.5.&lt;/strong&gt; Boris Johnson: 2.9.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It’s the same pattern every time. The Prime Minister gets the protection of the despatch box and the Leader of the Opposition gets the noise.&lt;/p&gt;
&lt;p&gt;The House as a whole got noisier too. Hansard recorded 9 interruptions per 1,000 speeches in 1979 and 33 in 1989, and it has mostly stayed in the twenties since. So these figures are era-adjusted. A leader in 2019 doesn’t get credit just for living in loud times.&lt;/p&gt;
&lt;h2 id=&quot;the-man-in-bothlists&quot;&gt;The man in both lists&lt;/h2&gt;
&lt;p&gt;One name sits at the top of both tables. &lt;strong&gt;Ian Blackford&lt;/strong&gt;, SNP leader at Westminster from 2017, was interrupted at &lt;strong&gt;6.6 times&lt;/strong&gt; the norm for his era. That’s 155 per 1,000 speeches, the highest of anyone since 1979, Prime Ministers and Opposition leaders included. He’s also second on the personal list, at 19 times his era’s rate, behind only Ron Brown. And on 13 June 2018 Bercow ordered him out of the chamber during Prime Minister’s Questions, and the SNP walked out behind him.&lt;/p&gt;
&lt;p&gt;The House shouted him down more than anyone, and the Chair pulled him up more than almost anyone. Nobody else comes close on both counts.&lt;/p&gt;
&lt;p&gt;The database found him twice, from two different directions. I like it when that happens.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_LL304wcpGVelYYgBjXoQbA.jpeg&quot; alt=&quot;Blackford (Me) actually being escorted out of the commons. The entire SNP benches (All me) following.&quot;&gt;
&lt;em&gt;Blackford (Me) actually being escorted out of the commons. The entire SNP benches (All me) following.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;did-the-cameras-change-anything&quot;&gt;Did the cameras change anything?&lt;/h2&gt;
&lt;p&gt;The Commons was first televised on 21 November 1989, halfway through Weatherill’s time. So there’s a neat experiment sitting in the data: same Speaker, same Parliament, with and without an audience.&lt;/p&gt;
&lt;p&gt;In the three years before, the Chair intervened 40.6 times per 1,000 speeches. Afterwards it was 38.4. Interruptions fell from 31.8 to 25.4. So MPs behaved slightly better with the nation watching, and then, as the trend shows, got used to it.&lt;/p&gt;
&lt;h2 id=&quot;what-id-want-you-to-know-before-quoting-any-ofthis&quot;&gt;What I’d want you to know before quoting any of this&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Hansard is an edited record.&lt;/strong&gt; Not every heckle gets written down, and the habits of the people writing it have changed over 42 years.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;“Who had the floor” is a proxy.&lt;/strong&gt; “Order!” is often aimed at the benches opposite, not the person speaking. That’s why I kept &lt;em&gt;rein in&lt;/em&gt; and &lt;em&gt;drown out&lt;/em&gt; separate.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lindsay Hoyle gets no verdict here.&lt;/strong&gt; The data stops in April 2021, so his time in it is mostly the Covid hybrid Parliament. Most of his 300-odd suspensions were breaks “to allow the safe exit of hon. Members”, not disorder.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The counting is pattern matching.&lt;/strong&gt; I read hundreds of matches by eye and tuned the rules until the misfires were rare. Rare isn’t never.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;next-the-house-with-nobody-to-sayit&quot;&gt;Next: the House with nobody to say it&lt;/h2&gt;
&lt;p&gt;The House of Lords has no one to call order. The Lord Speaker can’t rule on it. The peers police themselves, calling “Order!” from the benches. That’s the control group this article was missing: a chamber left entirely to its own devices.&lt;/p&gt;
&lt;p&gt;And hundreds of MPs have made the move from one House to the other. So the next question is whether, with no seat to lose and nobody in a wig to shout at them, they behave any differently.&lt;/p&gt;
&lt;p&gt;The code is on GitHub [link to follow], and the hypercube is on my website. Go and turn it through the fourth dimension, and see if you can spot Ron Brown.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_xM6UpO-2PSh-oDoaVfef3g.jpeg&quot; alt=&quot;Being kicked upstairs — The House Of Lords&quot;&gt;
&lt;em&gt;Being kicked upstairs — The House Of Lords&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I have included parts of the code used in the article as it shows what was run to get the analysis. But all the source code is on the github page and you run the files in order to obtain the result. There is a python script which downloads from Huggingface the Hanson dataset. Takes about 15 mins.&lt;/p&gt;
&lt;p&gt;Code will be up in a few days.&lt;/p&gt;
&lt;p&gt;If you enjoyed this please give it a thunderous round of applause.&lt;/p&gt;
</content:encoded><category>House Of Commons</category><category>Data Analysis</category><category>SQL</category><category>Government</category><category>Statistics</category></item><item><title>Cracking Feynman’s Safes in SQL Server</title><link>https://sqlartist.github.io/posts/cracking-feynmans-safes-in-sql-server/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/cracking-feynmans-safes-in-sql-server/</guid><pubDate>Sat, 10 Oct 2026 20:02:05 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_iPA-dtDFR9D6HNBWqhHojA.jpeg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The puzzle, not the physics&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I build daft things in SQL Server. Doom, Elite, a Boing ball bouncing around inside a result set. The rule’s always the same: pick something that has no business living in a database, and make it live there anyway. You learn more about the engine from one silly project than from a shelf of modelling books.&lt;/p&gt;
&lt;p&gt;This one is Richard Feynman cracking safes at Los Alamos.&lt;/p&gt;
&lt;p&gt;If you’ve read &lt;em&gt;Surely You’re Joking, Mr. Feynman!&lt;/em&gt; you know the chapter “Safecracker Meets Safecracker.” Everyone remembers it as Feynman being a genius. It isn’t that. It’s Feynman being patient, and noticing that the locks were far worse than anyone assumed. He didn’t out-muscle the safes. He worked out how little he actually had to try. That’s a database problem if ever I saw one, so I pointed SQL Server 2025 at it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_qU-0gQ8X2lPiwdaHge_jww.jpeg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The thing he actually spotted&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The filing cabinets used Mosler combination locks. Three numbers, 0 to 99, left-right-left. On paper that’s a million combinations, and a million is a comfortable number to hide behind. Nobody’s trying a million of anything by hand.&lt;/p&gt;
&lt;p&gt;Feynman took his own lock apart, not to pick it, to &lt;em&gt;measure&lt;/em&gt; it. And he found the thing the manufacturer would rather you didn’t: the mechanism was sloppy. A number still opened the safe if you were off by two in either direction. So 69 would open on 67, 68, 69, 70 or 71.&lt;/p&gt;
&lt;p&gt;That sounds like a footnote. It isn’t. It means you never have to try every number, only every fifth one, 0, 5, 10, 15, and so on. Twenty values per wheel instead of a hundred.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Approach                     | Combinations                |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ---------------------------- | --------------------------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Try every number             | 100 × 100 × 100 = 1,000,000 |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Every fifth number (±2 slop) | 20 × 20 × 20 = 8,000        |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A million down to eight thousand, and he did it with arithmetic, not a drill. At the rhythm he practised to, eight thousand was a long afternoon, four hours on average, eight at the worst. Tedious, but &lt;em&gt;possible&lt;/em&gt;, which a million never was. That gap between impossible and merely tedious is the whole chapter.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;The bit that makes the story&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Here’s where it stops being arithmetic and starts being mischief, and it’s my favourite part.&lt;/p&gt;
&lt;p&gt;When someone leaves a drawer open with the dial resting on ten, the bolt is still sitting down in the slot. Which means the three wheels are still lined up, the safe is open, it just hasn’t been &lt;em&gt;disturbed&lt;/em&gt; yet. Feynman worked out that he could read the combination off a safe in that state without the owner ever knowing.&lt;/p&gt;
&lt;p&gt;He’d lean on an open filing cabinet while chatting about physics and idly wobble the dial. Step away from ten in fives; each time, back to ten. The moment the bolt won’t drop back, you’ve just nudged a wheel off its slot and the step &lt;em&gt;before&lt;/em&gt; that was the last number. Do it again the other way for the second number. Two of the three numbers, taken off a safe while its owner stood next to you, and written on a scrap of paper he hid inside his own lock.&lt;/p&gt;
&lt;p&gt;After that, “cracking it cold” later meant trying twenty first numbers while pretending to read a magazine, so it didn’t look too easy.&lt;/p&gt;
&lt;p&gt;That’s the part I most wanted to see move, so it’s the first thing I built. The database wobbles the dial exactly as he describes, logging every step:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_Z_NLpDgpa0sig5wwSvtOdg.gif&quot; alt=&quot;The dial, the three-wheel pack and the back-end probe log reading the last two numbers off Christy’s open cabinet — it settles on 35, 60&quot;&gt;
&lt;em&gt;The dial, the three-wheel pack and the back-end probe log reading the last two numbers off Christy’s open cabinet — it settles on 35, 60&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;That’s Christy’s cabinet from the book. The log on the right shows the bolt holding up at 65, which fixes the last number at 60; the second falls out as 35. “Christy, 35, 60,” which is exactly what Feynman wrote down. I didn’t plan that number; it came out of the geometry, and I’ll admit I was happy when it matched the book.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Three tricks people blur into one&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The popular version of this story mashes everything into “Feynman was good at safes.” He wasn’t, particularly. He had three separate tricks, and they’re worth keeping apart because the database treats each one differently.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;tolerance&lt;/strong&gt; trick is the maths above, the only one that’s really his.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The open drawer&lt;/strong&gt; is the cheat from the last section: read two numbers off anything left open, then finish it later in minutes.&lt;/p&gt;
&lt;p&gt;And then the &lt;strong&gt;shortcuts&lt;/strong&gt;, which are pure human nature. The safe-cracker books told owners to pick dates and constants, so Feynman tried dates and constants. De Hoffmann’s cabinets, the ones holding the actual bomb secrets, opened on 27–18–28, the first digits of &lt;em&gt;e&lt;/em&gt;. Kerst’s opened on 0–5–35, which turned out to be his daughter’s birthday, found by sweeping dates in fives. And the locksmith’s dirty secret: half the safes were never changed from the factory settings, 25–0–25 or 50–25–50.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_4rkIVMwe1W8M-mWk61m7PA.gif&quot; alt=&quot;The database opening the Captain’s safe on the factory setting 50–25–50 in two tries&quot;&gt;
&lt;em&gt;The database opening the Captain’s safe on the factory setting 50–25–50 in two tries&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The Captain had a special heavy safe hauled up to his office on jacks so everyone could see how seriously he took security. He never changed it from the factory number. Two tries in the database and it’s open, forty seconds of pretend effort. I gave each of these a strategy in the schema, so you can watch a safe fall to the cheapest trick that happens to work on it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_6Ulh1kTmuxKjFOIw3kTjNA.gif&quot; alt=&quot;The database opening Kerst’s safe cold by sweeping dates in fives — 0–5–35, a daughter’s birthday&quot;&gt;
&lt;em&gt;The database opening Kerst’s safe cold by sweeping dates in fives — 0–5–35, a daughter’s birthday&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Why I modeled the metal, not the maths&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The obvious way to do this is a nested loop. Three counters, a modulo check, done in an afternoon. It would give the right numbers and teach me nothing, and it would be lying, because the ±2 slop isn’t a rule Feynman invented, it’s a physical fact about how a notched wheel sits under a bolt. If I hard-code “tolerance = 2” I’ve thrown away the very thing the story is about.&lt;/p&gt;
&lt;p&gt;So I went the long way round and built the actual metal in SQL Server 2025’s spatial types. Every wheel, at every one of its hundred positions, is a real `geometry` disc with a gate cut into its rim. The bolt is a little bar sitting above each wheel. And then the entire physics of the lock, the whole question of whether it opens, collapses to one spatial predicate, asked once and stored:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- does the bolt clear this wheel at this dial position?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; wg &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; Clear&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; wg&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Geom&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.STIntersects(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Geom&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                          THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dial&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;WheelGeom&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; wg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dial&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Bolt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CabinetId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; wg&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CabinetId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That’s the whole trick. If the gate overlaps the bolt, the bolt’s blocked. If it doesn’t, the bolt drops. I cut the gate a touch wider than one number and the ±2 slop &lt;em&gt;falls out on its own&lt;/em&gt;: exactly five dial positions per wheel end up clear. I never typed the number two. The geometry hands it to me, the same way the real mechanism handed it to Feynman.&lt;/p&gt;
&lt;p&gt;Once every position knows whether it’s clear, cracking a safe stops being physics and becomes a plain relational search: find the first candidate whose three wheels are all clear. That’s the division of labour I was after, geometry for the mechanism, set-based SQL for the searching. It’s slower to build than a loop and I’d do it again tomorrow, because now the database &lt;em&gt;disagrees&lt;/em&gt; with you when you’re wrong about the lock, which a loop never would.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Watching the eight thousand shrink&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A number on a page doesn’t land the way watching it does. So every attempt gets logged to a table with a running clock, and each try also carves out the little patch of the search it’s just ruled out. I laid that search out as a grid I’ve been calling Feynman space, twenty panels, one per first number, each a hundred-by-hundred square of the second and third.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_KptDxyuSbiSfOIuDwsWDEw.png&quot; alt=&quot;Cracking a cabinet with no clues at all — the wheel pack on the left, Feynman space filling in blue on the right as the attempts are logged&quot;&gt;
&lt;em&gt;Cracking a cabinet with no clues at all — the wheel pack on the left, Feynman space filling in blue on the right as the attempts are logged&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;That’s a cabinet with no clues, so there’s nothing for it but the full eight thousand. The blue is what’s been eliminated; the bolt drops the instant all three gates line up. The Python front end is drawing exactly what the database computed. The shapes come across the wire as the stored geometry, so I’m not re-faking the picture, I’m showing SQL Server’s own working.&lt;/p&gt;
&lt;p&gt;And because every safe is logged the same way, you can line them all up and see the point of the whole exercise:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_6vA8526YudDWA8vJMFuVgQ.png&quot; alt=&quot;A bar chart of how long each safe took, from the Captain’s factory setting at forty seconds up to brute force running off the end of the chart&quot;&gt;
&lt;em&gt;A bar chart of how long each safe took, from the Captain’s factory setting at forty seconds up to brute force running off the end of the chart&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The Captain’s factory safe: forty seconds. De Hoffmann’s bomb secrets, on the digits of &lt;em&gt;e&lt;/em&gt;: two minutes. Brute force with the tolerance trick thrown away: off the end of the chart, where a million always was. It’s the methods doing the work, not the muscle, which is the thing people always get backwards about Feynman.&lt;/p&gt;
&lt;p&gt;There’s a live mode too: kick the crack off with a small delay and watch the rows appear one at a time, the back-end running in front of you instead of after the fact.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;The lock that came after&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Feynman learned to pick ordinary pin-tumbler locks from a chap called Leo Lavatelli, and the way he describes it is pure “slop leaks information” again. A real lock isn’t made perfectly, so one pin holds more of the load than the rest. Lift &lt;em&gt;that&lt;/em&gt; one to the right height, the plug gives a hair, the pin catches on the edge. Now the load moves to the next pin. Push too far and the springs drop everything back with a &lt;em&gt;tic-tic-tic&lt;/em&gt;. He called it Sisyphus. Anyone who’s picked a lock knows the feeling.&lt;/p&gt;
&lt;p&gt;So the second half of the lab is a see-through practice lock, the kind sold as a clear teaching kit, built the same way, entirely from geometry. A key’s cuts are a profile; each pin rides along it; the plug turns only if every gap lands on the shear line.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_t1ujJ70ddxD1tjzn5nsURg.gif&quot; alt=&quot;The transparent lock with a near-miss key inserted — four pins reach the shear line, the fifth is cut one step too deep and blocks the plug&quot;&gt;
&lt;em&gt;The transparent lock with a near-miss key inserted — four pins reach the shear line, the fifth is cut one step too deep and blocks the plug&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;That’s next door’s key tried in the wrong lock. Four pins sit right on the red shear line; pin four is cut one step too deep, so its driver crosses the line and the plug won’t turn. The database decides that with the same `STIntersects` it used on the bolt, chamber by chamber, is anything straddling the line.&lt;/p&gt;
&lt;p&gt;Picking is the interesting one to watch, over sets and all:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_9pNE20boDv6WtVXhyJYSqg.gif&quot; alt=&quot;Single-pin picking the transparent lock — the pick lifting a binding pin while the others wait&quot;&gt;
&lt;em&gt;Single-pin picking the transparent lock — the pick lifting a binding pin while the others wait&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Tension on, find the binding pin, lift until it sets with a click, move to the next. Overshoot at the shear line and it over sets, tension off, every pin drops, start again. I built the overshoot in on purpose, because a picker that never fumbles isn’t telling the truth about the job.&lt;/p&gt;
&lt;p&gt;And then the payoff, which is the pin-tumbler cousin of taking the last two numbers off: because the pick records how high each pin had to go, the database can read the biting straight back off a successful pick and cut a working key.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_J4wH1Go_qtwsJxx7hxX26Q.gif&quot; alt=&quot;The lock opening on a key the database cut from its own successful pick&quot;&gt;
&lt;em&gt;The lock opening on a key the database cut from its own successful pick&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;What it’s really about&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Strip away the filing cabinets and the fun of it, and both halves of this say the same thing: a real mechanism has slop, and slop leaks information. The combination wasn’t a million-to-one secret, it was a few hundred once you measured the tolerance. The lock wasn’t picked by force, it was read one binding pin at a time. Feynman didn’t beat the security; he noticed it was never really there.&lt;/p&gt;
&lt;p&gt;That’s why it sits so naturally in a database. A spatial predicate isn’t pretending the metal exists, it &lt;em&gt;is&lt;/em&gt; the metal’s one honest question, asked eight thousand times a second. Build the mechanism properly and the cracking is almost an afterthought, which is exactly the shape of the original story.&lt;/p&gt;
&lt;p&gt;One caveat, since I’d want one if I were reading this. The spatial code is written for SQL Server 2025, convert it to other databases if you can. I built and checked the whole thing against a Python model of the same geometry, which reproduces every number in the book, de Hoffmann’s &lt;em&gt;e&lt;/em&gt; and Kerst’s birthday included.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;whats-in-thepackage&quot;&gt;What’s in the package&lt;/h2&gt;
&lt;p&gt;Four T-SQL scripts build the whole thing on a SQL Server 2025 instance; a Python front end draws it, either from the live database (geometry crosses the wire as WKT and is drawn exactly as the database computed it) or from a built-in simulator that reproduces every episode, so the visuals run with no server at all.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;sql/01_schema · 02_geometry · 03_dial · 04_pin_tumbler · 05_demo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;python/dial_viz.py · pin_viz.py · feynman_lab/ (geometry mirror, simulators, SQL driver)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;out/pre-rendered animations + the scoreboard&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run &lt;code&gt;05_demo.sql&lt;/code&gt; in SSMS with the &lt;em&gt;Spatial results&lt;/em&gt; tab on to see the wheel pack, Feynman space and the see-through lock; or &lt;code&gt;python dial_viz.py --source sql --live&lt;/code&gt; to watch &lt;code&gt;dial.usp_Crack&lt;/code&gt; write rows in real time.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Source: “Safecracker Meets Safecracker,” from Surely You’re Joking, Mr. Feynman! (1985). The combinations shown — de Hoffmann’s 27–18–28, Kerst’s 0–5–35, the factory 25–0–25 / 50–25–50, Christy’s 35–60 — are the ones Feynman records. First-number values and a few cabinets are invented to fill out the set; the mechanics are his.&lt;/p&gt;
&lt;p&gt;I hope you enjoyed this, I think it might be my favourite Feynman story in the whole of his book. If you did like it please give it some claps.&lt;/p&gt;
</content:encoded><category>SQL</category><category>Safecracker</category><category>Physics</category><category>World War Ii</category><category>Mathematics</category></item><item><title>SQL Server 2025, an RTX 5090, and the slow death of “Will the hon. Gentleman give way?”</title><link>https://sqlartist.github.io/posts/two-graphics-cards-and-1-7-million-speeches-to-prove-a-negative/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/two-graphics-cards-and-1-7-million-speeches-to-prove-a-negative/</guid><description>Two Graphics Cards and 1.7 Million Speeches to Prove a Negative</description><pubDate>Thu, 08 Oct 2026 13:52:27 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_q3O8bPHn_LoOiOrU0BWLiA.jpeg&quot; alt=&quot;Why do I do this to myself?&quot;&gt;
&lt;em&gt;Why do I do this to myself?&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-question&quot;&gt;The question&lt;/h3&gt;
&lt;p&gt;Do MPs ever change each other’s minds?&lt;/p&gt;
&lt;p&gt;Not “do they vote differently” — the whips settle that. I mean something narrower and more interesting: does an argument made from the opposition benches ever end up coming out of a minister’s mouth? Somebody stands up in 1987, says a thing nobody has said before, and four years later the government is saying it back. That happens, surely. Parliament would be a very expensive piece of theatre if it never happened.&lt;/p&gt;
&lt;p&gt;I had 1.7 million speeches, a database that can do vector search, and two graphics cards sitting in a machine under my desk doing nothing. It seemed like a fair question to put to them.&lt;/p&gt;
&lt;p&gt;The answer, for about a month, was no.&lt;/p&gt;
&lt;p&gt;I want to be clear that I did not want the answer to be no. I wanted a lovely little chart with a bump in it. What I got was two independent methods, built weeks apart on entirely different principles, both saying no, for entirely different reasons. Which is — and I have had to talk myself round to this — a much better result than a bump would have been. One method saying yes is a finding. Two methods saying no, where you can explain exactly *why* each one couldn’t see what you hoped it would see, is an actual piece of work.&lt;/p&gt;
&lt;p&gt;It also means that everything genuinely interesting here was found by accident while I was failing at the main thing. The House of Commons has quietly stopped using its own interruption protocol. Being a minister makes you *more* likely to be shouted at, not less. Eighty-five per cent of every six words ever spoken in the Commons since 1979 was spoken exactly once and never again.&lt;/p&gt;
&lt;p&gt;And at one point I had a query that proved every single Member of Parliament is funny one hundred per cent of the time. More on that later, because it is the single stupidest bug I have written in thirty years and I am oddly proud of it.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-only-appreciating-asset-i-have-everowned&quot;&gt;The only appreciating asset I have ever owned&lt;/h3&gt;
&lt;p&gt;I have been buying computer hardware since the mid-1990s. Tandem systems, AS/400s, a succession of PCs, every category of storage that has ever been invented and several that were quietly withdrawn. In thirty years, every single piece of it started depreciating the moment I got the box open. Some of it was worth less than the box.&lt;/p&gt;
&lt;p&gt;Then I bought two RTX 5090s, about a week before the price went up.&lt;/p&gt;
&lt;p&gt;They are now worth more than I paid for them. Not notionally, not “if you account for inflation” — actually, demonstrably, go and look, more money than I handed over. I have owned a house, several cars I never learned to drive, and roughly four hundred hard disks, and the only thing in thirty years that has gone *up* is a pair of graphics cards I bought to mess about with.&lt;/p&gt;
&lt;p&gt;So there was a certain obligation to use them for something.&lt;/p&gt;
&lt;p&gt;And here is the thing that nobody writing about GPUs seems to want to say out loud: the interesting work is not the GPU. It is the handover. A 5090 is phenomenally good at a small number of things and completely useless at everything else. SQL Server is phenomenally good at a different small number of things and would take a fortnight to do what the 5090 does in ninety seconds. Put them in the same room and make each one do only what it is good at, and you can answer questions that neither of them can answer alone.&lt;/p&gt;
&lt;p&gt;That is the actual article. The parliamentary stuff is just the excuse.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;why-hansard&quot;&gt;Why Hansard&lt;/h3&gt;
&lt;p&gt;Everyone building a vector search demo uses the same three datasets. Wikipedia, because it is there. Product reviews, because somebody once wrote a tutorial. Movie plots, because the results are funny in screenshots. You end up with a demo that proves your index works and tells you nothing at all about the world.&lt;/p&gt;
&lt;p&gt;Hansard is the official report of everything said in the House of Commons. The version I used covers 1979 onwards — 2,694,375 speeches, of which 1,700,647 are longer than forty words and attached to a real debate heading. That filter matters: below forty words you are mostly collecting “I beg to move”, “The Question is”, and men saying “no” at each other.&lt;/p&gt;
&lt;p&gt;I went for post-1979 deliberately. The Victorian material is wonderful and completely irrelevant to anyone alive. If I am going to find something out, I would like it to be about a Parliament people remember.&lt;/p&gt;
&lt;p&gt;What makes it a good corpus is not the size — 1.7 million rows is nothing, it fits in memory on a decent laptop. It is that every row is *attributed*. Speaker, party, date, debate, and whether they held office. You do not get that with Wikipedia. It means every question you can ask about the text, you can also ask about who said it, when, and from which side of the room.&lt;/p&gt;
&lt;p&gt;It is also, bluntly, the best-documented argument in the English-speaking world, conducted continuously for four decades by people who were paid to be persuasive. If there is a signal anywhere for “did somebody change somebody else’s mind”, it is in here.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-division-oflabour&quot;&gt;The division of labour&lt;/h3&gt;
&lt;p&gt;This is the bit I actually want you to take away, so I am going to be unusually clear about it.&lt;/p&gt;
&lt;p&gt;SQL Server 2025 has a `VECTOR` type and `VECTOR_DISTANCE`. It can do similarity search. What it cannot do — what no database can do at any sensible speed — is the thing you need *before* similarity search is useful: look at 1.7 million 384-dimensional vectors all at once and work out where the clusters are.&lt;/p&gt;
&lt;p&gt;That is k-means. It is forty iterations of a 1.7-million-by-41,730 matrix multiply. On a CPU that is a long lunch. On a 5090 it is ninety seconds, because it is exactly the shape of arithmetic a GPU exists to do: the same operation, on every element, with no branching and no conditionals.&lt;/p&gt;
&lt;h3 id=&quot;what-the-gpudoes&quot;&gt;What the GPU does&lt;/h3&gt;
&lt;p&gt;Plain PyTorch, no libraries beyond torch. Chunked because 1.7M × 41,730 does not fit in 32 GB all at once.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# Assignment step: every speech to its nearest centroid.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# X is (1.7M, 384) L2-normalised, C is (nlist, 384) normalised.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# With both normalised, cosine similarity IS the dot product,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# so the whole thing collapses to one matmul.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;assign &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; torch.empty(N, &lt;/span&gt;&lt;span style=&quot;color:#F69D50&quot;&gt;dtype&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;torch.int32, &lt;/span&gt;&lt;span style=&quot;color:#F69D50&quot;&gt;device&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&quot;cuda&quot;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; lo &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; range&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, N, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CHUNK&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    hi &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; min&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(lo &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CHUNK&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, N)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    sims &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; X[lo:hi] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; C.T          &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;# (chunk, nlist)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    assign[lo:hi] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; sims.argmax(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# Update step: new centroid = mean of its members.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# index_add_ is the scatter-gather that makes this O(N)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# instead of O(N * nlist).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;C.zero_()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;C.index_add_(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, assign, X)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;counts &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; torch.bincount(assign, &lt;/span&gt;&lt;span style=&quot;color:#F69D50&quot;&gt;minlength&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NLIST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;).clamp(&lt;/span&gt;&lt;span style=&quot;color:#F69D50&quot;&gt;min&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;C &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; counts.unsqueeze(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;C &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; torch.nn.functional.normalize(C, &lt;/span&gt;&lt;span style=&quot;color:#F69D50&quot;&gt;dim&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That is the whole algorithm. Forty of those, and 1.7 million speeches have been sorted into 41,730 topical neighbourhoods. The GPU then hands the database two things: a cluster id per speech, and a 384-bit binary signature per speech — one bit per dimension, sign only.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# 384 floats -&amp;gt; 384 bits -&amp;gt; 6 BIGINTs.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# Throws away the magnitude and keeps the direction.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# 1,536 bytes becomes 48. That is the 32x.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;bits &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (X &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;).to(torch.uint8)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;packed &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; np.packbits(bits.cpu().numpy(), &lt;/span&gt;&lt;span style=&quot;color:#F69D50&quot;&gt;axis&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;# (N, 48)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sig &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; packed.view(np.int64).byteswap()             &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;# (N, 6)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then the GPU is done. It has no further part in this. It cannot store anything, it cannot be queried, it does not know what a Conservative is.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;what-the-databasedoes&quot;&gt;What the database does&lt;/h3&gt;
&lt;p&gt;SQL Server’s job is everything the GPU cannot touch: persisting it, indexing it so that only the relevant slice is ever read, and — the part everybody forgets — joining it to who said it.&lt;/p&gt;
&lt;p&gt;The cluster ids are the whole trick. Order the columnstore by cluster id and put it on a partition scheme, and a query for one neighbourhood touches one partition instead of the table.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*  64 partitions over the cluster id space. The boundaries are&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    not arbitrary - they come from a second k-means the GPU ran&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    over the centroids themselves, so that clusters which are&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    NEAR each other get ADJACENT ids and land in the same&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    partition. Spatial locality, written into the physical&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    layout of the table.                                        */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FUNCTION&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; pf_cluster (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; RANGE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; LEFT &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FOR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;652&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1304&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1956&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* ... */&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 41078&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PARTITION&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SCHEME ps_cluster&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PARTITION&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; pf_cluster ALL &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ([PRIMARY]);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*  Declare the table ON the scheme FIRST. SELECT INTO will not&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    do this and the index will not be partition-aligned if you&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    try to bolt it on afterwards. I found that out the hard way. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.speech_sig (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    speech_id  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    cluster_id &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    sig0 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BIGINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, sig1 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BIGINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, sig2 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BIGINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    sig3 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BIGINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, sig4 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BIGINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, sig5 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BIGINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ps_cluster (cluster_id);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CLUSTERED&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; COLUMNSTORE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; INDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ccix_speech_sig&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_sig&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ORDER (cluster_id)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ps_cluster (cluster_id);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then the search. This is the part that made me laugh when it worked, because it is a *vector similarity search* implemented with an XOR and a population count — an instruction that has been in CPUs since the 1960s and in T-SQL since 2022.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*  Hamming distance on the binary signatures. BIT_COUNT(a ^ b)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    per 64-bit lane, summed. Six XORs and six POPCNTs per row,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    all of it integer work the CPU does at absurd speed, and all&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    of it in the columnstore batch-mode engine.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    @probe0..5 are the query&apos;s own signature.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    @clusters is the nprobe nearest neighbourhoods, which is&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    what makes the partition elimination happen.               */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       hamming &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; BIT_COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sig0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ^ @probe0) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; BIT_COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sig1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ^ @probe1)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;               +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; BIT_COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sig2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ^ @probe2) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; BIT_COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sig3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ^ @probe3)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;               +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; BIT_COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sig4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ^ @probe4) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; BIT_COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sig5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ^ @probe5)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_sig&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;cluster_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; cluster_id &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @clusters)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; hamming;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Neither half can do the other’s job. The GPU cannot hold the data, cannot join it to a party affiliation, and cannot answer a question six months later without being handed everything again. The database cannot do the matrix arithmetic that works out where the neighbourhoods are in the first place.&lt;/p&gt;
&lt;p&gt;The GPU builds the map. The database reads it. That is the entire architecture and it took me three attempts to see it that plainly.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-same-thing-explained-to-a-dachshund&quot;&gt;The same thing, explained to a dachshund&lt;/h3&gt;
&lt;p&gt;My technical review process is a black-and-tan dachshund called Brian who has been in the house about a week.&lt;/p&gt;
&lt;p&gt;Brian has two settings. In the first he is asleep, in a shape no animal with a spine should be able to achieve. In the second he has heard me draw breath to speak, and is therefore already airborne. He has never once let me finish a sentence. He has no opinion on partition elimination. He has strong opinions on my shoelaces.&lt;/p&gt;
&lt;p&gt;He is, in other words, the perfect sounding board, because the entire value of explaining something out loud has nothing to do with whether the other party understands a word of it.&lt;/p&gt;
&lt;p&gt;So. Imagine a library.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;7 million books. No shelves. Just books, in a heap.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| What I built            | What it is in the library                                        |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ----------------------- | ---------------------------------------------------------------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| The embedding           | Reading each book and writing down what it&apos;s *about* on a card   |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| k-means on the GPU      | Sorting all the cards into 41,730 piles of similar books         |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| The cluster id          | Writing a shelf number on every book                             |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| The ordered columnstore | Actually putting the books on the shelves, in shelf order        |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| The partitions          | Grouping the shelves into 64 rooms                               |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| The binary signature    | A tiny sticker on the spine — 48 bytes instead of the whole book |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| nprobe                  | &quot;Only look in the three nearest rooms&quot;                           |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Hamming distance        | Comparing stickers instead of reading books                      |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I got as far as &lt;strong&gt;”and then you only search the three nearest rooms”&lt;/strong&gt; before I stopped, because I had heard it.&lt;/p&gt;
&lt;p&gt;How do you know which rooms are nearest?&lt;/p&gt;
&lt;p&gt;You don’t. Not in the version I had built. k-means numbers its clusters in whatever order it happens to produce them, so cluster 4 and cluster 39,000 could be about exactly the same thing and sit at opposite ends of the building. I had sorted the books onto shelves and then arranged the shelves at random. Every “nearby room” I was searching was nearby in numbering and nowhere near in meaning.&lt;/p&gt;
&lt;p&gt;The fix was a second, much smaller k-means — over the 41,730 centroids themselves this time — grouping them into 64 super-clusters and renumbering so that topically adjacent piles get adjacent numbers. Spatial locality written into the physical layout of the table. It is the best idea in the project and it took ninety seconds to run.&lt;/p&gt;
&lt;p&gt;Brian, during all of this, was attempting to kill a sock.&lt;/p&gt;
&lt;p&gt;I want to be clear that he contributed nothing. He does not know what a vector is. He is a long, low, deeply stupid animal bred to go down holes after badgers, and the badgers were armed. But the obligation to say a thing out loud, in order, to something that is definitely not going to help, is the cheapest code review available and I have yet to find a better one.&lt;/p&gt;
&lt;p&gt;If you take one engineering practice from this article, take the dog.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;attempt-one-embeddings-verdictno&quot;&gt;Attempt one: embeddings. Verdict, no.&lt;/h3&gt;
&lt;p&gt;The idea was obvious enough that I am slightly embarrassed by how long I believed in it.&lt;/p&gt;
&lt;p&gt;If a minister adopts an opposition argument, the minister’s later speech should sit &lt;em&gt;closer in vector space&lt;/em&gt; to that earlier opposition speech than you would otherwise expect. So: take every cross-party pair of speeches on the same subject, measure the cosine distance, bucket by how many months apart they are, and look for the gap closing.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*  Mean cross-party distance against mean same-party distance,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    bucketed by lag. If opposition arguments get adopted, the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    cross-party line should fall relative to the same-party one&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    as lag increases.                                          */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; lag_months &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; DATEDIFF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_date&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_date&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 6&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       cross_party &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;party&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;party&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                        THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; VECTOR_DISTANCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;cosine&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;av&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;embedding&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;bv&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;embedding&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       same_party  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;party&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;party&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                        THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; VECTOR_DISTANCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;cosine&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;av&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;embedding&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;bv&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;embedding&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #pairs p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_role&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_role&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; b  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_vec&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; av  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; av&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_vec&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; bv  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; bv&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; DATEDIFF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_date&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_date&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 6&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 6&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The gap did not close. It &lt;strong&gt;widened&lt;/strong&gt;, from +0.0124 to +0.0244, consistently, in every bucket. Cross-party pairs were further apart the longer you waited.&lt;/p&gt;
&lt;p&gt;I assumed I had a bug. I did have several, but not that one. So I did the thing I should have done first, which was print the actual speeches and read them.&lt;/p&gt;
&lt;p&gt;The closest cross-party pair in the entire corpus, at a cosine distance of 0.079, was David Heathcoat-Amory arguing &lt;strong&gt;against&lt;/strong&gt; the fuel duty escalator, and Dawn Primarolo, eleven weeks later, defending it.&lt;/p&gt;
&lt;p&gt;There it is. That is the whole failure in one row.&lt;/p&gt;
&lt;p&gt;An embedding encodes what a document is &lt;em&gt;&lt;strong&gt;about&lt;/strong&gt;&lt;/em&gt;. It has no opinion about whether the author approved. Two people on opposite sides of the same question, using the same vocabulary, citing the same figures, are &lt;strong&gt;near-identical&lt;/strong&gt; in vector space — and the more fiercely they disagree about something specific, the closer they get, because disagreement is topically narrow and agreement is vague.&lt;/p&gt;
&lt;p&gt;So the method was never going to work, and no amount of tuning would have fixed it. I was asking a tool that measures subject matter to measure stance. It is like trying to find out who won a boxing match by weighing the boxers.&lt;/p&gt;
&lt;p&gt;I could have discovered this on day one by reading six rows. I discovered it on day nine, after building a very fast index. Make of that what you will.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;attempt-two-phrases-verdict-alsono&quot;&gt;Attempt two: phrases. Verdict, also no&lt;/h3&gt;
&lt;p&gt;If embeddings cannot see stance, stop asking them to. Use words instead.&lt;/p&gt;
&lt;p&gt;The logic is nicer than the embedding version. If a backbencher coins a distinctive six-word formulation in 1987, and a minister uses &lt;em&gt;the same six words&lt;/em&gt; four years later, that is evidence — regardless of whether either of them approved of anything. You do not need a stance model. You need only to notice that the words moved.&lt;/p&gt;
&lt;p&gt;So: hash every six-word window in all 1.7 million speeches, count them, and keep the rare-but-repeated ones.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# FNV-1a over the joined n-gram, pure Python, which is quite&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# slow and completely fine at this scale.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; hash_ngrams&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(tokens, n):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    out &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; []&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    for&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; i &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; range&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(tokens) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; 0x&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;cbf29ce484222325&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        for&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; tokens[i:i &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n]:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            for&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w.encode():&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;^=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; b&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; 0x&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100000001b3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; 0x&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FFFFFFFFFFFFFFFF&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;^=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; 0x&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;                       # the space between words&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; 0x&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100000001b3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; 0x&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FFFFFFFFFFFFFFFF&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        out.append(h)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; out&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That produced &lt;em&gt;&lt;strong&gt;375,802,591 six-grams, of which 319,572,719 were distinct.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Stop and look at that for a second, because it is the best statistic in this article and I found it by accident. &lt;em&gt;&lt;strong&gt;Eighty-five per cent of every six consecutive words ever spoken in the House of Commons since 1979 was spoken exactly once and never again.&lt;/strong&gt;&lt;/em&gt; For an institution with a reputation for saying the same thing over and over, that is a remarkable amount of novelty. Four decades of people, in a room, mostly not repeating each other.&lt;/p&gt;
&lt;p&gt;Only 3,813,616 fell in the useful band — said between four and three hundred times. Rare enough to be distinctive, common enough that reuse is not a coincidence.&lt;/p&gt;
&lt;h2 id=&quot;the-burstiness-filter-which-is-the-only-clever-thinghere&quot;&gt;The burstiness filter, which is the only clever thing here&lt;/h2&gt;
&lt;p&gt;Most of those 3.8 million are procedural furniture. “I beg to move that the Bill” appears constantly and means nothing. The thing that separates a &lt;em&gt;coined&lt;/em&gt; phrase from a &lt;em&gt;recurring&lt;/em&gt; one is its shape in time: boilerplate spreads evenly across forty years, a coinage arrives, spikes, and fades.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# Biggest share of a phrase&apos;s uses falling in any single year.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;# Boilerplate scores low. A coinage scores high.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;_, year_counts &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; np.unique(years[ids], &lt;/span&gt;&lt;span style=&quot;color:#F69D50&quot;&gt;return_counts&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;True&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;burst &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; year_counts.max() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; total_uses&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; burst &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0.35&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    continue&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That took 3.8 million down to 1,086,386, of which 735,073 had a different speaker at each end.&lt;/p&gt;
&lt;h2 id=&quot;and-theanswer&quot;&gt;And the answer&lt;/h2&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*  The control arm is the whole point. Without it, &quot;2.23% of&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    opposition coinages reach a minister&quot; sounds like a finding.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    With it, you can see what it is.                           */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; coined &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; coiner_side, phrases &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;phrase_attr&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; coiner_side&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;crossed &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; coiner_side, to_minister &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;phrase_attr&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; later_role &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;minister&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; lag_days &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 30&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; coiner_side&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;coiner_side&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, coined &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;phrases&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       reached_a_minister &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;to_minister&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       pct &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;to_minister&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;phrases&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DECIMAL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; coined c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; crossed x &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;coiner_side&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;coiner_side&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Coined by  | Coinages | Reached a minister | Rate      |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ---------- | -------- | ------------------ | --------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Opposition | 345,948  | 7,705              | 2.23%     |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Government | 389,125  | 14,907             | 3.83%     |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ministers are &lt;em&gt;&lt;strong&gt;1.7 times more likely&lt;/strong&gt;&lt;/em&gt; to pick up language coined on their own side.&lt;/p&gt;
&lt;p&gt;So language does diffuse through the House — but it diffuses downhill, from the frontbench outwards, not across the floor. The opposition is not shaping government vocabulary. The government is shaping its own.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;how-much-of-this-should-youbelieve&quot;&gt;How much of this should you believe&lt;/h3&gt;
&lt;p&gt;Less than I would like, and I want to say so before somebody checks.&lt;/p&gt;
&lt;p&gt;I pulled a random thirty from the cleaned candidate set and read them. About a third are genuine rhetorical constructions — &lt;em&gt;”it has shone a spotlight on”, ”in the dying days of his”, ”warm words at the beginning of”, ”we have little to show for”.&lt;/em&gt; People choosing words.&lt;/p&gt;
&lt;p&gt;The other two thirds are still furniture: &lt;em&gt;”copy is being placed in the”&lt;/em&gt;, &lt;em&gt;”meeting with the financial secretary to”, ”health and safety executive for a”&lt;/em&gt;. Procedural language that survived four filters because it happens to burst in a particular year for reasons that have nothing to do with anybody coining anything.&lt;/p&gt;
&lt;p&gt;So: a third signal, two thirds noise. That is enough for a candidate list a human reads and judges, which is what I built it for. It is nowhere near enough to say “this particular MP coined this particular phrase” in print.&lt;/p&gt;
&lt;p&gt;The 2.23% against 3.83% survives that, because the noise is symmetric — procedural junk is distributed across both sides of the House in roughly equal measure, so it cancels in a ratio even while it ruins the individual rows. A comparison can be sound while every single line of its input is rubbish. That is a property of comparisons that I think more people should find reassuring than do.&lt;/p&gt;
&lt;p&gt;Two methods. Two no’s. One blind to stance, one able to see exactly which words moved. Same answer.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;a-parade-of-my-own-stupidity&quot;&gt;A parade of my own stupidity&lt;/h2&gt;
&lt;p&gt;I promised you the hundred-per-cent-funny bug. Here it is, along with its friends, roughly in order of how long I stared at each one before the penny dropped.&lt;/p&gt;
&lt;h3 id=&quot;1-every-mp-in-britain-is-funny-all-of-thetime&quot;&gt;1. Every MP in Britain is funny all of the time&lt;/h3&gt;
&lt;p&gt;Hansard marks audience reaction inline: `[Laughter.]`, `[Interruption.]`, `[Hon. Members: “Rubbish!”]`. Lovely. Let us count them.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- This returns 1,700,647. Every speech in the corpus.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; body &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;LIKE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;%[Interruption.]%&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Square brackets are LIKE wildcards. `’%[Interruption.]%’` does not ask for that string. It asks for *any single character from the set* `{I, n, t, e, r, u, p, o, .}`, with anything either side.&lt;/p&gt;
&lt;p&gt;Every speech in Hansard contains the letter “e”.&lt;/p&gt;
&lt;p&gt;So I produced a leaderboard showing that every single Member of Parliament makes the House laugh in 100.00% of their speeches, and — this is the part I enjoy — I very nearly believed it for a moment, because the House of Commons is exactly the sort of institution where that might be true.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- CHARINDEX does no pattern matching. 39,163 speeches.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CHARINDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;[Interruption.]&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, body) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thirty years of writing SQL. Beaten by a bracket.&lt;/p&gt;
&lt;h3 id=&quot;2-tony-banks-conservative&quot;&gt;2. Tony Banks, Conservative&lt;/h3&gt;
&lt;p&gt;Every leaderboard grouped by speaker and took `MIN(party)` to label them, because a speaker has one party and `MIN` of one value is that value. Except the dataset has the odd mislabelled row, and `MIN` on a string is &lt;em&gt;alphabetical&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;`’Conservative’ &amp;lt; ‘Labour’`.&lt;/p&gt;
&lt;p&gt;So one bad row anywhere in a career flips the whole career. Tony Banks — Labour member for Newham North West, one of the funniest men ever to stand up in that chamber — came out of my analysis as a Conservative. So did Mr. Smith. So did Mr. Brown. I had accidentally built a swingometer that only swings one way.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*  Modal party, not minimum. Should have been obvious.  */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; pc &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; speaker_name, party,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           rn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; speaker_name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                   ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, party)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_role&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;chair&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; party &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS NOT NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; speaker_name, party&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; speaker_name, main_party &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; party &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; pc &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;3. A filter that rewarded phrases for containing their own date&lt;/p&gt;
&lt;p&gt;The burstiness filter scores how concentrated a phrase’s uses are in a single year. Beautiful idea. It put this at the top:&lt;/p&gt;
&lt;p&gt;&amp;gt; &lt;em&gt;&lt;strong&gt;order 1995 which was laid before&lt;/strong&gt;&lt;/em&gt; — burstiness 0.870&lt;/p&gt;
&lt;p&gt;Of course it did. The year is &lt;em&gt;inside the phrase&lt;/em&gt;. Statutory instrument boilerplate scores perfectly on a time-concentration metric because the text contains the time. I built a filter that rewarded phrases for being self-dating and then congratulated myself on the elegance of the method.&lt;/p&gt;
&lt;p&gt;One line fixes it:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;phrase&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;%19[0-9][0-9]%&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;phrase&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LIKE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;%20[0-9][0-9]%&apos;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(Note the square brackets. Here they &lt;strong&gt;are&lt;/strong&gt; the wildcards I want. Consistency is not SQL’s strong suit.)&lt;/p&gt;
&lt;h3 id=&quot;4-peter-bone-the-most-prolific-phrase-coiner-in-parliamentary-history&quot;&gt;4. Peter Bone, the most prolific phrase-coiner in parliamentary history&lt;/h3&gt;
&lt;p&gt;The top forty “most concentrated coinages” contained eighteen entries from one man on one day in 2009:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;the recommendations of the badman report about the recommendations of the badman recommendations of the badman report which of the badman report which suggests badman report which suggests closer monitoring&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Peter Bone read a petition about home education into the record. The same petition. 144 times. A six-word window sliding along one piece of text produces dozens of overlapping “phrases”, every one of which bursts identically.&lt;/p&gt;
&lt;p&gt;I had not discovered a coinage. I had discovered a man with a very long petition and discovered it eighteen times.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*  All shingles of one source share both endpoints. One row&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    per (first_speech, last_speech) collapses the petition back&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    to the single event it always was.                         */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, deshingled &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, rn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                   PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; first_speech, last_speech&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                   ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; uses &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, burstiness &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; filtered&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; INTO&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;phrase_clean&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; deshingled &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;5-theresa-may-influencer-ofnobody&quot;&gt;5. Theresa May, influencer of nobody&lt;/h3&gt;
&lt;p&gt;The coiner leaderboard showed Theresa May with 2,808 phrases coined and &lt;strong&gt;zero&lt;/strong&gt; reaching a minister. David Cameron, 2,357 and zero. A striking finding about the hollowness of modern political language, I thought, for about four minutes.&lt;/p&gt;
&lt;p&gt;The corpus ends in 2021. They coined late. Nobody had time to pick anything up.&lt;/p&gt;
&lt;p&gt;If your metric has a boundary, somebody is standing on it.&lt;/p&gt;
&lt;p&gt;And there is somebody standing on the other edge too, which took me a further day to see.&lt;/p&gt;
&lt;p&gt;The per-party coinage table had the Liberals at 2,718 phrases per million words against the Conservatives’ 1,524. Nearly twice as inventive. A lovely little story about the creativity of third parties, which I was composing in my head when I thought to sort the whole column by something other than the number.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Party            | Per million words | Years active in the corpus |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ---------------- | ----------------- | -------------------------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Liberal          | 2,718             | 1979–1988 only             |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Ulster Unionist  | 1,895             | heavily early              |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Labour           | 1,561             | throughout                 |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Conservative     | 1,524             | throughout                 |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Plaid Cymru      | 1,411             | throughout                 |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| DUP              | 1,069             | throughout                 |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Liberal Democrat | 979               | post-1988                  |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| SNP              | 825               | mostly post-2015           |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That is not a ranking of linguistic invention. It is a ranking of &lt;em&gt;&lt;strong&gt;who got here first.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;“First use” in my data means first use &lt;strong&gt;in the corpus&lt;/strong&gt;, and the corpus starts in 1979. Every phrase already in circulation before then — which is to say most of the English language — gets credited to whoever happens to say it earliest inside my window. The Liberal Party label stops existing at the 1988 merger, so every Liberal in this dataset is standing at the front of the queue being handed the collected works of several centuries of parliamentary cliche.&lt;/p&gt;
&lt;p&gt;So I had built a metric with a boundary at each end. Arrive early and you are credited with inventing everything that was already there. Arrive late and you are recorded as having influenced nobody. Neither has anything to do with the MPs.&lt;/p&gt;
&lt;p&gt;If your data has edges — and all data has edges — go and look at who is standing on them before you write a word.&lt;/p&gt;
&lt;h3 id=&quot;6-forty-two-rows-asecond&quot;&gt;6. Forty-two rows a second&lt;/h3&gt;
&lt;p&gt;The loader wrote data files at 42 rows per second. Eleven hours for a job that should take two minutes. I confidently diagnosed f-string formatting of numpy scalars. Wrong. I then confidently diagnosed memory pressure. Also wrong — Task Manager showed 58 GB free and the disk at 1%.&lt;/p&gt;
&lt;p&gt;It was two things, neither of which I had considered:&lt;/p&gt;
&lt;p&gt;`num_proc=8` on a HuggingFace dataset op. On Linux that forks. &lt;strong&gt;On Windows there is no fork&lt;/strong&gt;, so Python respawns the whole interpreter per worker, per batch.&lt;/p&gt;
&lt;p&gt;`shuffle()` leaves an indices map behind, so every subsequent read is a random seek into an Arrow file instead of a sequential scan.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;ds &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ds.filter(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;lambda&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; r: &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;# NO num_proc. Not on Windows.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;ds &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ds.shuffle(&lt;/span&gt;&lt;span style=&quot;color:#F69D50&quot;&gt;seed&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SEED&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;ds &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ds.flatten_indices()       &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;# random seeks -&amp;gt; sequential scan&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Two lines. &lt;strong&gt;The job went from eleven hours to 78 seconds.&lt;/strong&gt; The text pass hit 165,000 rows per second. That is roughly four thousand times faster, achieved by deleting one argument and adding one call.&lt;/p&gt;
&lt;p&gt;I had spent the previous hour profiling string formatting.&lt;/p&gt;
&lt;h3 id=&quot;7-select-into-three-separatetimes&quot;&gt;7. `SELECT INTO`, three separate times&lt;/h3&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Msg &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8111&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;: Cannot define &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; constraint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; on&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; nullable column&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`SELECT … INTO` discards nullability from the source column &lt;strong&gt;even when the source is `NOT NULL`&lt;/strong&gt;. Every table you intend to key has to be declared explicitly. I know this. I have known this for twenty years. I did it three times in one project and was surprised on each occasion.&lt;/p&gt;
&lt;p&gt;The fix I settled on is to stop using primary keys for things that are only ever unique lookups:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNIQUE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CLUSTERED&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; INDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ix_speaker_party&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speaker_party&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (speaker_name);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;8-the-leaderboard-that-was-measuring-itself&quot;&gt;8. The leaderboard that was measuring itself&lt;/h3&gt;
&lt;p&gt;This one is the most instructive, so I will give it room.&lt;/p&gt;
&lt;p&gt;I wanted to find MPs who sound more like the other side than their own. Score each member against a random sample of 400 Conservative and 400 Labour speeches, subtract, sort.&lt;/p&gt;
&lt;p&gt;The output was perfect. All thirty at the top were Labour. All thirty at the bottom were Conservative. Beautifully clean separation.&lt;/p&gt;
&lt;p&gt;Too clean. `to_con` was lower than `to_lab` for &lt;strong&gt;every single speaker in the House, including all the Labour ones.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There were 851,967 Conservative speeches in the corpus and 553,250 Labour ones, and the Conservatives spent more of the period in government, which means more subjects covered. The Conservative reference sample is simply &lt;strong&gt;topically broader&lt;/strong&gt;, so everybody sits marginally nearer it. My score was `to_con — to_lab`, which therefore flips sign purely on party membership. I had not produced sixty findings about individual MPs. I had produced one property of my own sample, printed twice, in opposite orders.&lt;/p&gt;
&lt;p&gt;The fix is to stop comparing against zero and start comparing against your own colleagues:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*  z = how far this MP&apos;s gap sits from their OWN party&apos;s mean,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    in party standard deviations. Sign flipped for Labour so a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    high score means the same thing on both sides: further from&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    my own lot than my colleagues are.                         */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; stats&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; own_party, m &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(to_con &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; to_lab),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                      sd &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; STDEV&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(to_con &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; to_lab)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #gap &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; own_party&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speaker_name&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;own_party&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       off_message_sd &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;own_party&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Conservative&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ((&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;to_con&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;to_lab&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;st&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sd&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #gap g &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; stats&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; st &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;own_party&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;own_party&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; off_message_sd &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If your results are suspiciously tidy, you are probably measuring your instrument.&lt;/p&gt;
&lt;h3 id=&quot;what-i-found-while-failing-at-the-thing-i-meant-todo&quot;&gt;What I found while failing at the thing I meant to do&lt;/h3&gt;
&lt;p&gt;Once the brackets were fixed, the reaction markers turned out to be real and plentiful: `[Interruption.]` in 39,163 speeches, “Interruption” in any form in 47,030, “Laughter” in 8,833. There is a genuine record of how the Commons behaves, sitting in the text, and as far as I can tell nobody has counted it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Office does not protect you. It makes you a target.&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; role&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, speeches &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       pct_laughter  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(laughter)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DECIMAL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       pct_interrupt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(interrupt) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DECIMAL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #reaction &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; role&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Role       | Speeches  | Laughed at | Interrupted |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ---------- | --------- | ---------- | ----------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Backbencher| 1,565,532 | 0.530%     | 2.738%      |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Minister   | 47,537    | 0.684%     | 4.222%      |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A minister at the despatch box is interrupted &lt;strong&gt;54% more often&lt;/strong&gt; than a backbencher, and laughed at 29% more. I had assumed the dignity of office bought a bit of quiet. It buys the opposite. The red box is a target, not a shield.&lt;/p&gt;
&lt;h3 id=&quot;the-house-has-stopped-givingway&quot;&gt;The House has stopped giving way&lt;/h3&gt;
&lt;p&gt;This is the one I would lead with if I were a journalist.&lt;/p&gt;
&lt;p&gt;“Will the hon. Gentleman give way?” is the Commons’ interrupt protocol — the formal, courteous mechanism by which one member takes the floor from another mid-speech. It is the single most recognisable thing about British parliamentary debate.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Decade | Interrupted | Gave way | Laughter | &quot;Hear, hear&quot; |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ------ | ----------- | -------- | -------- | ------------ |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 1979   | 1.315%      | 1.270%   | 0.316%   | 0.136%       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 1980s  | 2.692%      | 1.734%   | 0.385%   | 0.152%       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 1990s  | 2.867%      | 1.801%   | 0.784%   | 0.175%       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 2000s  | 3.342%      | 1.189%   | 0.619%   | 0.105%       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 2010s  | 2.667%      | 0.919%   | 0.447%   | 0.091%       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 2020s  | 1.851%      | 0.362%   | 0.367%   | 0.079%       |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Giving way peaked at 1.80% of speeches in the 1990s and now runs at 0.36%. &lt;strong&gt;A five-fold collapse.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The obvious explanation is the pandemic — you cannot intervene on somebody appearing by video link. But look at the 2010s: already at 0.919%, half the 1990s rate, years before anyone had heard of hybrid proceedings. Covid finished it off. It did not start it.&lt;/p&gt;
&lt;p&gt;“Hear, hear” has halved over the same period. Interruption, meanwhile, peaked in the 2000s and is still running at roughly the 1980s rate.&lt;/p&gt;
&lt;p&gt;So the picture is a chamber that still gets shouted at but has stopped *negotiating* interruption. The formal exchange is dying while the informal noise carries on. Speeches written for the clip rather than the room, by people who have no intention of letting anyone in.&lt;/p&gt;
&lt;h3 id=&quot;being-interrupted-is-a-measure-of-importance&quot;&gt;Being interrupted is a measure of importance&lt;/h3&gt;
&lt;p&gt;I built the “most interrupted MPs” leaderboard expecting to find the chamber’s most irritating people. Here is the top of it:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Member          | Party        | Speeches | Interrupted |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| --------------- | ------------ | -------- | ----------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Neil Kinnock    | Labour       | 226      | 12.83%      |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Ian Blackford   | SNP          | 1,125    | 12.53%      |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Peter Dowd      | Labour       | 415      | 10.84%      |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Rhodes Boyson   | Conservative | 222      | 10.36%      |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Edward Miliband | Labour       | 1,822    | 9.88%       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| George Osborne  | Conservative | 3,319    | 9.34%       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Tony Blair      | Labour       | 2,233    | 9.05%       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Keir Starmer    | Labour       | 984      | 8.54%       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Jeremy Corbyn   | Independent  | 2,646    | 8.31%       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Tony Benn       | Labour       | 569      | 8.26%       |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That is not an irritation ranking. It is a prominence ranking. Leaders of the opposition, chancellors, prime ministers, the people at the despatch box in prime time with the whole other side watching. &lt;strong&gt;Being interrupted a lot means you were worth interrupting.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Which, if you are an MP reading this, is probably the nicest thing a database has ever said about you.&lt;/p&gt;
&lt;h3 id=&quot;tony-blair-does-not-sound-like-a-labourmp&quot;&gt;Tony Blair does not sound like a Labour MP&lt;/h3&gt;
&lt;p&gt;Remember the broken leaderboard from the last section, the one where all the Labour members were at one end and all the Conservatives at the other, because I was measuring my own reference sample. Here is what came out once I centred it properly.&lt;/p&gt;
&lt;p&gt;First, the thing the artefact was hiding:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Own party    | MPs   | Mean gap | SD      |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ------------ | ----- | -------- | ------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Labour       | 1,001 | +0.00522 | 0.00204 |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Conservative | 1,226 | +0.00345 | 0.00203 |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The two parties &lt;strong&gt;are&lt;/strong&gt; separated by 0.87 standard deviations, which in any other field would be called a decent medium effect. An embedding model that has never been told what a political party is can tell Labour from Conservative purely from how they talk.&lt;/p&gt;
&lt;p&gt;But the global offset I was accidentally measuring was +0.00425, which is &lt;strong&gt;two and a half times larger than the real party difference.&lt;/strong&gt; The signal was there the whole time. It was buried under an artefact of my own sampling, and the broken version of the query was reporting the artefact with complete confidence and perfect internal consistency.&lt;/p&gt;
&lt;p&gt;That is the lesson of this entire project in one table.&lt;/p&gt;
&lt;p&gt;And now the fun part. The corrected list of MPs who sound &lt;em&gt;&lt;strong&gt;less&lt;/strong&gt;&lt;/em&gt; like their own side than their colleagues do:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Member          | Party         | Off message (SD) |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| --------------- | ------------- | ---------------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Hywel Francis   | Labour        | 4.07             |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Ann Keen        | Labour        | 3.97             |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Patricia Hewitt | Labour        | 2.60             |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Dr. Liam Fox    | Conservative  | 2.41             |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Tony Blair      | Labour        | 2.32             |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| David Willetts  | Conservative  | 2.32             |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Eric Forth      | Conservative  | 2.33             |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Theresa May     | Conservative  | 2.15             |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Tony Blair, 2.32 standard deviations off message.&lt;/strong&gt; The most famously triangulating Labour leader in modern British history, identified as sounding less like Labour than his own backbenchers, by a method that has never heard of triangulation, New Labour, or the Third Way. It just noticed that the subjects he talked about and the way he framed them sat closer to the other lot than his colleagues’ did.&lt;/p&gt;
&lt;p&gt;Patricia Hewitt came to Parliament from the IPPR and ran Trade and Industry. David Willetts is the Conservative who wrote a book arguing that his own generation had robbed the next one. Eric Forth spent his career being a nuisance to his own whips. The list is not random.&lt;/p&gt;
&lt;h3 id=&quot;the-other-end-is-a-cohort-not-a-character-trait&quot;&gt;The other end is a cohort, not a character trait&lt;/h3&gt;
&lt;p&gt;The most &lt;em&gt;&lt;strong&gt;on message&lt;/strong&gt;&lt;/em&gt; MPs in forty years of Hansard:&lt;/p&gt;
&lt;p&gt;Alan Mak. Nigel Huddleston. Amanda Solloway. Ben Howlett. Andy Carter. Mims Davies. Richard Holden. Greg Smith. Anthony Mangnall. Julia Lopez. Andrea Jenkyns. Wendy Morton. Craig Tracey. Amanda Milling. Edward Argar.&lt;/p&gt;
&lt;p&gt;That is not a list of unusually loyal individuals. &lt;strong&gt;That is the 2015, 2017 and 2019 Conservative intakes, almost without exception.&lt;/strong&gt; The handful of non-Conservatives who break it up — Frank Allaun, Michael Meacher, Roy Hattersley, Margaret Beckett — are old Labour’s most doctrinally reliable voices, which is its own kind of confirmation.&lt;/p&gt;
&lt;p&gt;So the measure is tracking &lt;em&gt;when you arrived&lt;/em&gt;, not what you are like.&lt;/p&gt;
&lt;p&gt;There are two explanations and they make identical predictions. Either message discipline has genuinely professionalised and recent intakes really do sound more alike — which would be a finding worth having — or it is a sampling artefact, because thirty speeches from a four-year career cover a far narrower range of subjects than thirty from a thirty-year one.&lt;/p&gt;
&lt;p&gt;Might do more of this digging in the next article.&lt;/p&gt;
&lt;h3 id=&quot;where-is-margaret-thatcher&quot;&gt;Where is Margaret Thatcher?&lt;/h3&gt;
&lt;p&gt;I went looking for her about halfway through, expecting her to be everywhere. I could not find her, which turned out to be the answer.&lt;/p&gt;
&lt;p&gt;She appears &lt;strong&gt;once&lt;/strong&gt; in everything I ran — second place in the broken crossover leaderboard, the one that was measuring my own sampling. Fix the query and she vanishes entirely. Not in the most interrupted. Not in the funniest. Not in the most repetitive. The dominant parliamentary figure of the period, absent from every list.&lt;/p&gt;
&lt;p&gt;Then I looked at the coiner table again:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Coiner                 | Party        | Phrases   |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ---------------------- | ------------ | --------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Unknown                | —            | 18,422    |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| The Prime Minister     | Conservative | 6,149     |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Mr. Clarke             | Conservative | 3,175     |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Second biggest coiner in four decades of Hansard, and it is not a person. It is a &lt;strong&gt;job&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The official report records who was speaking &lt;em&gt;as what&lt;/em&gt;. When the Prime Minister answers at the despatch box, Hansard writes “The Prime Minister”, and for most of the 1980s it does not bother adding the name in brackets. Later convention does — you get `The Prime Minister (Mr. Tony Blair)` — but Thatcher largely predates that.&lt;/p&gt;
&lt;p&gt;So eleven years of the most consequential speaker in modern British politics are filed under a job title, and every analysis in this article that groups by `speaker_name` has been quietly ignoring her. So, I would bet, has every other analysis anyone has published on this dataset, because the omission is completely invisible unless somebody asks you a question you cannot answer.&lt;/p&gt;
&lt;p&gt;One `CASE` expression on the date fixes it, and opens a question nobody has been able to put to the record: &lt;strong&gt;which Prime Minister did the House shout at most?&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;holder &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; speech_date &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;1990-11-28&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Thatcher&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; speech_date &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;1997-05-02&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Major&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; speech_date &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;2007-06-27&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Blair&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; speech_date &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;2010-05-11&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Brown&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; speech_date &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;2016-07-13&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Cameron&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; speech_date &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;2019-07-24&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;May&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ELSE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Johnson&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So I ran it.&lt;/p&gt;
&lt;h3 id=&quot;nine-margaret-thatchers-one-of-themmale&quot;&gt;Nine Margaret Thatchers, one of them male&lt;/h3&gt;
&lt;p&gt;First, the names. Here is every form the official report uses for the same woman:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;The Prime Minister (Mrs. Marga...     372&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Mrs. Thatcher                          32&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Mrs. Margaret Thatcher                  3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;The]&apos;rime Minister (Mrs. Marga...       1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;The. Prime Minister (Mrs. Marg...       1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;The Prime Minister (Mr. Margar...       1     &amp;lt;--&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;The Prime Minister Mrs. Margar...       1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;The Prime Minister (Mrs Margar...       1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;The Prime Minister, (Mrs. Marg...       1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nine spellings, most of them differing by a stray apostrophe, a misplaced full stop or a missing bracket. And on &lt;strong&gt;16 January 1986&lt;/strong&gt;, the official report of the United Kingdom Parliament recorded the Prime Minister as &lt;strong&gt;Mr.&lt;/strong&gt; Margaret Thatcher.&lt;/p&gt;
&lt;p&gt;That typo has been sitting in the public record for forty years. I found it at eleven o’clock at night because I went looking for a woman who was not where she should have been.&lt;/p&gt;
&lt;h3 id=&quot;twenty-four-times-a-job-title-once-aperson&quot;&gt;Twenty-four times a job title, once a person&lt;/h3&gt;
&lt;p&gt;Across 1979 to 2001 there are roughly &lt;strong&gt;18,046&lt;/strong&gt; speeches filed under the bare string “The Prime Minister”, against &lt;strong&gt;410&lt;/strong&gt; under any version of Thatcher’s own name.&lt;/p&gt;
&lt;p&gt;And it is not a convention peculiar to her. The bare form runs at 700 to 900 a year straight through Major and into Blair — and then &lt;strong&gt;stops dead in 2001&lt;/strong&gt;, after which Hansard records prime ministers by name like everybody else. So any comparison between prime ministers using this data covers 1979 to 2001 only, and Blair’s share of it is his first term.&lt;/p&gt;
&lt;p&gt;I am spelling that out because it is exactly the sort of caveat that gets dropped when a number is interesting.&lt;/p&gt;
&lt;h3 id=&quot;nobody-laughed-at-margaretthatcher&quot;&gt;Nobody laughed at Margaret Thatcher&lt;/h3&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Prime Minister    | Speeches | Interrupted | Laughter   | Avg words |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ----------------- | -------- | ----------- | ---------- | --------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Blair (1997–2001) | 3,547    | 7.75%       | 1.015%     | 147.1     |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Thatcher          | 9,782    | 6.35%       | 0.174%     | 104.2     |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Major             | 5,303    | 5.98%       | 0.811%     | 120.8     |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Raw, she draws a fifth of Blair’s laughter. But the House laughed more in the 1990s than the 1980s generally, so against the decade baselines:&lt;/p&gt;
&lt;p&gt;- &lt;strong&gt;Thatcher: 0.45× her era’s laughter rate&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;- Major: 1.03×. Exactly average.&lt;/p&gt;
&lt;p&gt;- &lt;strong&gt;Blair: 1.29× his&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Even after correcting for the period, the Commons laughed at Thatcher &lt;strong&gt;less than half as much&lt;/strong&gt; as it laughed at everyone else at the time — while interrupting her more than it interrupted Major. Shouted at, not laughed at. And she said it in short bursts: 104 words a speech against Blair’s 147.&lt;/p&gt;
&lt;p&gt;I have no idea whether that is a fact about her or a fact about the House, and I am not sure the distinction survives contact with eleven years of her being Prime Minister.&lt;/p&gt;
&lt;h3 id=&quot;the-orderpaper&quot;&gt;The order paper&lt;/h3&gt;
&lt;p&gt;There is a story that belongs here, and it is my favourite thing anybody has ever written about her.&lt;/p&gt;
&lt;p&gt;Christopher Hitchens — a man of the left who had been publicly and expensively rude about her in print — met Thatcher at a reception in the late seventies, when she was still Leader of the Opposition. They got into an argument about Rhodesia. He lost it. Having lost it, he bowed to her.&lt;/p&gt;
&lt;p&gt;She told him that was not low enough. He bowed again, properly this time. And as she swept past she caught him across the backside with a rolled-up parliamentary order paper and said, &lt;strong&gt;”Naughty boy.”&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Hitchens then wrote, in print, about the frankly confusing effect this had on him. Which, for a man of his politics, took a kind of nerve that I am not sure I would have managed.&lt;/p&gt;
&lt;p&gt;I mention it because of what happens when you put it next to the number above. The House laughed at her less than half as much as it laughed at anybody else of her era — and the most quoted personal anecdote about her is one where she makes a hostile left-wing journalist look ridiculous, physically, with a procedural document, in under ten seconds.&lt;/p&gt;
&lt;p&gt;Those two facts are the same fact.&lt;/p&gt;
&lt;p&gt;And there is a pleasing loop in it for this project: the argument Hitchens lost was about Rhodesia, the Lancaster House conference ran from September to December 1979, and the corpus starts in May. So whatever she said to him at that party, I can go and read what she was telling the House about it the same autumn.&lt;/p&gt;
&lt;p&gt;The very first row of the very first query I ran in this entire project — the broken one, the one that was measuring my own sampling — was Frank Dobson, 25 July 1979, in a debate headed `SOUTHERN AFRICA`.&lt;/p&gt;
&lt;h3 id=&quot;and-then-the-best-row-in-theproject&quot;&gt;And then the best row in the project&lt;/h3&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;at the end of the transition&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  132 uses  ·  burstiness 0.697&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  coined 1979-06-26, EUROPEAN COMMUNITY COUNCIL (STRASBOURG)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  last used by Robert Courts (Con), 41.7 years later&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Margaret Thatcher said &lt;strong&gt;”at the end of the transition”&lt;/strong&gt; in June 1979, about Britain’s transitional arrangements on &lt;strong&gt;joining&lt;/strong&gt; the European Community.&lt;/p&gt;
&lt;p&gt;The same five words, forty-one years and eight months later, about Britain &lt;strong&gt;leaving&lt;/strong&gt; it.&lt;/p&gt;
&lt;p&gt;The burstiness of 0.697 means seven in ten of its 132 uses fall inside a single year, and that year is 2020. The phrase sat nearly dormant for four decades and then detonated.&lt;/p&gt;
&lt;p&gt;She is not alone in the pattern. &lt;em&gt;”we will get a good deal”&lt;/em&gt; — 1984, picked up in 2019. &lt;em&gt;”the principles of democracy and…”&lt;/em&gt; — the Falklands, 1982, picked up in 2019. &lt;em&gt;”left to us by the labour…”&lt;/em&gt; — 1982, picked up by Theresa May in 2019. Her European vocabulary came back thirty-five years later in the mouths of people making the opposite argument.&lt;/p&gt;
&lt;p&gt;The left-censoring caveat applies — she spoke early, so she collects first-mover credit on anything already in circulation. But that one is hers, the dates are in the record, and you can go and check it.&lt;/p&gt;
&lt;p&gt;I spent a month trying to measure whether MPs change each other’s minds, and the most interesting thing the whole apparatus produced was a five-word phrase that outlived the argument it was coined for, turned round, and came back pointing the other way.&lt;/p&gt;
&lt;h3 id=&quot;the-best-test-in-the-project-came-from-an-idlethought&quot;&gt;The best test in the project came from an idle thought&lt;/h3&gt;
&lt;p&gt;Somewhere around the fourth failed query I stopped building things and thought about the problem instead, and the question that came out of that is better shaped than anything the apparatus produced.&lt;/p&gt;
&lt;p&gt;In the News at Ten era, a minister needed &lt;strong&gt;one line&lt;/strong&gt;. One crafted sentence that would survive the cut and go out at ten o’clock. So you would expect them to find that line and repeat it. In a rolling news cycle you need constant fresh material instead, so repetition should fall.&lt;/p&gt;
&lt;p&gt;And there is a dated event sitting in the middle of this corpus to test it against. &lt;strong&gt;Television cameras entered the House of Commons in November 1989&lt;/strong&gt;. Radio had been there since 1978, but the chamber was not filmed until then — ten years into a forty-two year dataset.&lt;/p&gt;
&lt;p&gt;That sets up the only within-subject design in this entire project. Take every MP with at least fifteen substantive speeches on &lt;strong&gt;each&lt;/strong&gt; side of November 1989–790 of them — and measure each one’s self-similarity against themselves, before and after. Same people. Same metric. One event in between.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Era     | MPs | Pairs  | Self-distance |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ------- | --- | ------ | ------------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Pre-TV  | 790 | 86,537 | 0.2600        |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Post-TV | 790 | 86,766 | 0.2623        |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;MPs became &lt;em&gt;marginally more varied&lt;/em&gt; after the cameras arrived — the opposite direction to the prediction, and by an amount that looks small.&lt;/p&gt;
&lt;p&gt;For scale: individual MPs in this corpus run from 0.2006 (Ralph Howell, the most repetitive man in forty years of Hansard) to 0.3398. That is a spread of 0.139, and the camera effect is 1.6% of it.&lt;/p&gt;
&lt;p&gt;I could have published that as “no meaningful effect” and moved on, and it would have been true. Instead I did the thing I have spent this whole article telling you to do, and ran a placebo.&lt;/p&gt;
&lt;h3 id=&quot;the-placebo-which-was-the-point-allalong&quot;&gt;The placebo, which was the point all along&lt;/h3&gt;
&lt;p&gt;Same test, same code, break date moved to a year with nothing behind it. If an arbitrary Tuesday produces the same gap, the cameras are irrelevant.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Break date              | Pre-window length | Pre    | Post   | Gap         |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ----------------------- | ----------------- | ------ | ------ | ----------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 1984 — nothing happened | 5 years           | 0.2544 | 0.2618 | +0.0074     |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 1989 — the cameras      | 10.5 years        | 0.2600 | 0.2623 | +0.0023     |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 1994 — nothing happened | 15 years          | 0.2622 | 0.2628 | +0.0006     |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;A meaningless date produced three times the effect of the real one.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;And then the actual answer, which is sitting in the pre-window column if you read it downwards:&lt;/p&gt;
&lt;p&gt;- 5-year window → 0.2544&lt;/p&gt;
&lt;p&gt;- 10.5-year window → 0.2600&lt;/p&gt;
&lt;p&gt;- 15-year window → 0.2622&lt;/p&gt;
&lt;p&gt;Monotonic. Self-distance rises &lt;strong&gt;with the length of time you watch somebody&lt;/strong&gt;, and then flattens off. Which is obvious the moment you see it — observe an MP for five years and you catch them on fewer subjects than if you observe them for fifteen. All three post-TV figures cluster around 0.262 because every one of them is a long window sitting on the flat part of that curve, and the gap shrinks to nothing at 1994 precisely because that is where the two windows are closest to equal length.&lt;/p&gt;
&lt;p&gt;There was no camera effect. There was no career-drift effect either. &lt;strong&gt;I had measured how long I was looking.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This is my favourite result in the article, and it is a null that nearly got away.&lt;/p&gt;
&lt;p&gt;Every other test here compared different people to different people, which leaves all of them exposed to the thing that wrecked the crossover leaderboard — a property of the groups masquerading as a property of the members. This one compared 790 individuals to &lt;em&gt;themselves&lt;/em&gt;, either side of a dated event. Best design in the project, large sample, clean execution.&lt;/p&gt;
&lt;p&gt;And it still produced a number that meant nothing, and I would have believed it if I had not spent twenty minutes testing a date on which nothing happened.&lt;/p&gt;
&lt;p&gt;That is the whole lesson. Not “check your work” — everybody says that and nobody means it. &lt;strong&gt;Run your analysis against a thing you know to be nothing, and see what it tells you&lt;/strong&gt;. If it tells you something, your method is generating findings out of its own shape, and every result you have is suspect including the ones you like.&lt;/p&gt;
&lt;p&gt;Mine was. Twice before this, and I only caught those by accident.&lt;/p&gt;
&lt;h3 id=&quot;the-honestnumbers&quot;&gt;The honest numbers&lt;/h3&gt;
&lt;p&gt;The index works. 1,700,647 speeches, 41,730 clusters, 64 partitions, and a signature table of &lt;strong&gt;87.9 MB&lt;/strong&gt; standing in for 2.6 GB of raw vectors.&lt;/p&gt;
&lt;p&gt;Recall at 10 against brute-force ground truth: &lt;strong&gt;0.920&lt;/strong&gt;. Bytes read: &lt;strong&gt;681× fewer&lt;/strong&gt; than the full scan.&lt;/p&gt;
&lt;p&gt;That 681× is the number I would put on a slide. It is also the number I want to pull apart, because the breakdown is more useful than the headline and nobody ever publishes it.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Where the saving comes from               | Factor  |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ----------------------------------------- | ------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Binary quantisation (1,536 bytes → 48)    | 32×     |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Columnstore compression on the signatures | \~12×   |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Rowgroup and partition elimination        | 1.8×    |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The clever bit — the ordered columnstore, the super-cluster renumbering, the partition scheme, the thing I spent most of the project on — contributes &lt;strong&gt;1.8×.&lt;/strong&gt; The boring bit, throwing away everything except the sign of each dimension, contributes 32×.&lt;/p&gt;
&lt;p&gt;I am telling you this because the industry does not. Every vector index post you will read quotes an aggregate speedup and lets you assume it came from the architecture. Usually it came from the quantisation, which you could have had in an afternoon.&lt;/p&gt;
&lt;h3 id=&quot;the-experiment-where-i-made-itworse&quot;&gt;The experiment where I made it worse&lt;/h3&gt;
&lt;p&gt;I thought 64 partitions was too coarse, so I rebuilt at 512. More partitions, tighter elimination, fewer rows read. Obviously better.&lt;/p&gt;
&lt;p&gt;Rows read fell from 845,000 to 351,000 — a 2.4× improvement, exactly as predicted.&lt;/p&gt;
&lt;p&gt;LOB reads went &lt;strong&gt;up&lt;/strong&gt;, from 968 to 1,048.&lt;/p&gt;
&lt;p&gt;Small rowgroups carry fixed per-segment overhead. I had created four times as many segments, each one too small to amortise its own dictionary and header. I read fewer rows and more bytes. The query plan looked better and the disk worked harder.&lt;/p&gt;
&lt;p&gt;I reverted to 64 and wrote it on a sticky note: &lt;strong&gt;measure bytes, not rows&lt;/strong&gt;. The row count is what the plan shows you. The byte count is what you pay for.&lt;/p&gt;
&lt;h3 id=&quot;why-none-of-this-works-in-a-vectordatabase&quot;&gt;Why none of this works in a vector database&lt;/h3&gt;
&lt;p&gt;Here is the constraint that started the whole design, and it is the sort of thing you only find by trying.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;SQL Server 2025 will not let you put a columnstore index on a table carrying a vector index, or a vector index on a table with a columnstore.&lt;/strong&gt; They are mutually exclusive. You get fast vector search, or you get the compression and batch-mode scan, and you do not get both on the same table.&lt;/p&gt;
&lt;p&gt;My first reaction was that this was a product gap. My second, after a day of being annoyed once again with a feature that should be there but isn’t (I have met the people at Microsoft developing SQL Server and Microsoft Research and I can honestly say there wasn’t a better, more dedicated group of people I have worked with so if something isn’t in the product there is a good reason for it — having said that they have all mostly left so who knows what teasm is developing it these days ? ), was that it forced the only interesting architecture in the project.&lt;/p&gt;
&lt;p&gt;Because I could not have both, I had to split them. The full-precision vectors live in one table with a vector index for the exact work. The 48-byte signatures live in a &lt;em&gt;separate&lt;/em&gt; table, ordered and partitioned by cluster id, with a columnstore. The search is a funnel: scan the cheap table with integer arithmetic to get a few hundred candidates, then do exact `VECTOR_DISTANCE` on only those.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*  Stage 1: the cheap table. Integer XOR + POPCNT, batch mode,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    one partition. Narrows 1.7 million to 500.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    Stage 2: exact cosine on 500 rows. Costs nothing.         */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; candidates &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 500&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; BIT_COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sig0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ^ @p0) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; BIT_COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sig1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ^ @p1)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;             +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; BIT_COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sig2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ^ @p2) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; BIT_COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sig3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ^ @p3)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;             +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; BIT_COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sig4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ^ @p4) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; BIT_COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sig5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ^ @p5)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_sig&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;cluster_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; cluster_id &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @probe)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; h&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 10&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speaker_name&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;party&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_date&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;       d &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; VECTOR_DISTANCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;cosine&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;embedding&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @query)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; candidates c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_vec&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_role&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; r &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;speech_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;party&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Labour&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;role&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;minister&apos;&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;   -- try this in Pinecone&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; d;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Look at that `WHERE` clause on the last line, because it is the argument for the whole approach.&lt;/p&gt;
&lt;p&gt;A dedicated vector database gives you an approximate nearest-neighbour search and, if you are lucky, metadata filtering that was bolted on afterwards and falls over when the filter is selective. What it does not give you is the ability to say “nearest neighbours, but only Labour ministers, joined to the division lists, grouped by decade, with a window function over the result” — and have the optimiser work out that it should apply the party filter first.&lt;/p&gt;
&lt;p&gt;I did not want a vector database. I wanted a &lt;strong&gt;database&lt;/strong&gt;, that happens to do vectors, so that the interesting half of every question — who, when, which side, how often — is a join rather than a second system.&lt;/p&gt;
&lt;p&gt;The restriction I resented for a day turned out to be the design.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;and-then-i-went-looking-for-tonybenn&quot;&gt;And then I went looking for Tony Benn&lt;/h3&gt;
&lt;p&gt;I had the index built, the pipeline run, two negative results written up and the article mostly drafted. And then I went back to a question I had been carrying around since before any of this started, for no better reason than that I have always admired the man: &lt;strong&gt;what does the data say about Tony Benn?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First problem: nothing, because he was split across three names. The leaderboards had “Mr. Tony Benn” at 569 speeches. Resolve the forms properly and he is at &lt;strong&gt;4,814 speeches, 1.4 million words, roughly 180 hours at the despatch box&lt;/strong&gt;. The interruption rate I had already put in a table was drawn from a tenth of him.&lt;/p&gt;
&lt;p&gt;So I tested the reputation properly.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;|              | Benn   | The House, 1979–2001 |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ------------ | ------ | -------------------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Interrupted  | 2.825% | 2.664%               |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Laughed at   | 0.457% | 0.571%               |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| &quot;Hear, hear&quot; | 0.125% | 0.151%               |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Gave way     | 2.804% | 1.652%               |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Interrupted at almost exactly the House average. Laughed at rather less. And &lt;strong&gt;he gave way seventy per cent more often than anybody else&lt;/strong&gt; — far and away the largest deviation in the table.&lt;/p&gt;
&lt;p&gt;That is the reputation, and it does not show up as being shouted at. It shows up as letting people in. In a chamber that spent thirty years quietly abandoning the practice, he did more of it than almost anyone.&lt;/p&gt;
&lt;p&gt;I had also predicted he would be a broken record — the man with four themes and forty years. Wrong. Self-distance 0.2695 against a Labour average of 0.2684. Completely ordinary range.&lt;/p&gt;
&lt;h3 id=&quot;the-five-questions&quot;&gt;The five questions&lt;/h3&gt;
&lt;p&gt;Benn’s five questions are the most famous formulation any backbencher produced in the period. He put them to the House repeatedly across eleven years:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;”What power have you got? Where did you get it from? In whose interests do you exercise it? To whom are you accountable? And how can we get rid of you?”&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So I searched for them, mostly as a sanity check on the pipeline. Easiest possible case. I knew the answer in advance.&lt;/p&gt;
&lt;p&gt;They are in the corpus. And so is this:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Lee Rowley (CONSERVATIVE), 14 October 2019, DEBATE ON THE ADDRESS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  &quot;What power have you got? Where did you get it from? In whose&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;   interests do you exercise it? To whom are you accountable?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;   And how can we get rid of you?&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;   - [Official Report, 22 March 2001; Vol. 365, c. 510.]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  &quot;I hope we remember that in the days ahead.&quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A Conservative MP. In the Queen’s Speech debate. At the height of the Brexit crisis. Reading a hard-left Labour backbencher’s words into the record with the column reference, citing a speech Benn gave eighteen years earlier on the election of a Speaker. Rowley sits for North East Derbyshire, which wraps around Benn’s Chesterfield.&lt;/p&gt;
&lt;p&gt;He is not alone. Clive Lewis used the full structure against academy trusts in 2015 — not quoting it, &lt;strong&gt;wielding&lt;/strong&gt; it. Toby Perkins, the sitting member for Chesterfield, read them out on 20 March 2014, six days after Benn died.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;That is a formulation coined on the opposition benches, crossing the floor, and arriving in the mouth of a government MP eighteen years later.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It is precisely, exactly the thing I built a GPU index to find. The index failed to find it twice. I found it by typing a man’s name into a search box because I admired him.&lt;/p&gt;
&lt;h3 id=&quot;why-375-million-six-grams-could-not-seeit&quot;&gt;Why 375 million six-grams could not see it&lt;/h3&gt;
&lt;p&gt;This is the part that should worry anyone doing this kind of work. Here is how Benn opened the questions on each occasion:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| Year | Opening                                                   |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ---- | --------------------------------------------------------- |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 1990 | &quot;What power have you got? Where did you get it?&quot;          |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 1991 | &quot;What power do you have? Where did you get it?&quot;           |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 1998 | &quot;what power do you have; where did you get it&quot;            |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| 2001 | &quot;What power have you got? Where did you get it from?&quot;     |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;He never said it the same way twice.&lt;/strong&gt; Not once in eleven years.&lt;/p&gt;
&lt;p&gt;A six-gram hash requires an exact match. Every variant appears once or twice, below my floor of four, so each was discarded as noise before it ever reached the burstiness filter. The single most quotable thing anybody said in that chamber in forty years was invisible to a method that processed 375,802,591 six-word sequences on a graphics card.&lt;/p&gt;
&lt;p&gt;And that explains the junk. It explains all of it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The only language said identically enough to survive exact n-gram counting is language nobody is choosing their words for.&lt;/strong&gt; Statutory instrument boilerplate. Petitions read verbatim. Procedural furniture. My candidate list was two-thirds rubbish not because my filters were weak, but because furniture is the only thing that holds still long enough to be counted.&lt;/p&gt;
&lt;p&gt;Real rhetoric mutates. That is what makes it rhetoric. My method was, by construction, a detector for the absence of rhetoric, and I ran it for forty minutes on a 5090 to discover that.&lt;/p&gt;
&lt;h3 id=&quot;footpaths&quot;&gt;Footpaths&lt;/h3&gt;
&lt;p&gt;One last thing from the Benn data, because it is the funniest result in the project and it is also, I think, the truest.&lt;/p&gt;
&lt;p&gt;His most distinctive vocabulary, measured against the House:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;footpath   177x    stockport   399 uses    promoters  265 uses&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;tameside   170x    footpaths   225 uses    carry-over  86 uses&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;walkers     99x    ramblers     93 uses    prerogative 164 uses&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Stockport, 399 times. Footpaths, 225. Ramblers, 93.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The man remembered for the royal prerogative and the sovereignty of Parliament spent an enormous share of his career on Private Bills — Stockport Corporation, Tameside, Felixstowe Dock, Milford Haven, Pembrokeshire — objecting, forcing divisions, grinding through “promoters” and “carry-over” motions about rights of way in Greater Manchester.&lt;/p&gt;
&lt;p&gt;Because that is where the constitutional principle actually bit. The grand questions about power got asked in committee rooms, about footpaths.&lt;/p&gt;
&lt;p&gt;His nearest neighbours in vector space are not the Labour left. They are Hugh D. Brown, Cowans, Barry Porter, Eleanor Laing — obscure procedural specialists of both parties. The other people who spent their lives on Private Bills. The embeddings cannot see what anybody believed, but they put him in exactly the right room.&lt;/p&gt;
&lt;h3 id=&quot;what-i-would-tell-you-before-you-trythis&quot;&gt;What I would tell you before you try this&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Read the rows before you build the index.&lt;/strong&gt; I spent nine days building a very fast way to get a wrong answer. Six printed speeches would have told me on day one that embeddings cannot see stance. Print the data. Print it early. Print it when you think you already know what it says.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Always build the control arm.&lt;/strong&gt; “2.23% of opposition coinages reach a minister” is a finding, a headline, and a plausible story about the health of parliamentary democracy. Next to 3.83% for the government side, it is the opposite story. The comparison is not a nice-to-have, it is the entire analysis. If you cannot think of a control, you do not yet have a question.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Then run it against a date on which nothing happened.&lt;/strong&gt; This is the control arm’s harder older brother and it is the single most useful thing in this article. Take your analysis, point it at something you know to be meaningless, and look at what comes back. When I tested whether television changed how MPs speak, the real date gave me a result — and an arbitrary year five years earlier gave me &lt;em&gt;three times&lt;/em&gt; as much of it. The method was manufacturing findings out of its own shape, and nothing short of a placebo would have shown me that. If a nothing produces a something, every result you own is suspect, including the ones you are fond of.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Measure bytes, not rows.&lt;/strong&gt; The query plan shows you rows because rows are easy to count. You pay in bytes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Suspiciously tidy output is a bug.&lt;/strong&gt; Clean separation, round numbers, every member of one group above every member of another — that is almost never nature. It is usually your instrument.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;If your metric has an edge, somebody is standing on it.&lt;/strong&gt; Theresa May did not fail to influence anyone. The data stopped.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Check what your string functions actually mean.&lt;/strong&gt; `LIKE` is a pattern language, not a search. Thirty years in and a square bracket still had me.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;On Windows, `num_proc` is a trap.&lt;/strong&gt; No fork means respawning the interpreter. The default is almost always faster.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Get the whole thing into the database before you get clever.&lt;/strong&gt; Every analysis in this article is a join away from speaker, party, date and office. That is only true because loading it properly was the first thing I did and not the last.&lt;/p&gt;
&lt;h3 id=&quot;the-code&quot;&gt;The code&lt;/h3&gt;
&lt;p&gt;All of it — the loader, the GPU clustering, the renumbering, the partition scheme, the phrase pipeline, and every query in this article including the broken versions will be here:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;(link to follow)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I have left the bugs in, in their own files, with comments explaining what each one did. The square bracket one especially. If you are going to learn anything from this it will be from those rather than from the version that works.&lt;/p&gt;
&lt;p&gt;You will need SQL Server 2025 for `VECTOR_DISTANCE`, SQL Server 2022 or later for `BIT_COUNT`, and a CUDA card for the clustering. It does not have to be a 5090. It just has to not be a CPU.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;one-lastthing&quot;&gt;One last thing&lt;/h3&gt;
&lt;p&gt;I set out to prove that parliamentary debate changes minds.&lt;/p&gt;
&lt;p&gt;The embeddings said no, because they cannot see stance. The phrases said no, and then it turned out they could only ever have said no, because exact six-grams detect the absence of rhetoric rather than its presence. The one experiment with a decent design — the same 790 MPs, before and after the cameras — said no, and the placebo proved that even that no was a measurement of my own window length.&lt;/p&gt;
&lt;p&gt;Three methods. Four hundred lines of SQL. Three hundred and seventy-five million six-word sequences. Two graphics cards that are somehow worth more than I paid for them. All of it, no.&lt;/p&gt;
&lt;p&gt;And then I went looking for Tony Benn, because I admire the man and always have, and a Conservative MP turned out to have read his five questions into the Queen’s Speech debate of 2019 with the Hansard column reference attached.&lt;/p&gt;
&lt;p&gt;I want to be careful about the moral here, because the obvious one is wrong. The obvious one is “the computer failed and a human succeeded”, and that is not what happened. Nobody reads 1.7 million speeches. The reason I could check Benn’s five questions in about ninety seconds, resolve him across three name forms, measure his giving-way rate against the whole House and find his nearest neighbours in vector space, is that a month of GPU work and columnstore design had already put the corpus in a state where a question like that costs nothing to ask.&lt;/p&gt;
&lt;p&gt;The index did not find the answer. The index made the answer &lt;strong&gt;cheap to look for&lt;/strong&gt;, so that an idle question cost nothing and I went ahead and asked it. Those are different jobs, and I had quietly assumed they were the same one.&lt;/p&gt;
&lt;p&gt;So here is what I actually learned, and it is not about Parliament.&lt;/p&gt;
&lt;p&gt;Build the thing properly. Load it all, index it where needed, join it to everything you know about who said it and when. Then stop expecting the apparatus to produce the question. It will not. It will sit there, extremely fast, waiting. The question comes from somewhere else entirely — in my case from a man I have admired since long before I owned a graphics card.&lt;/p&gt;
&lt;p&gt;The graphics cards are still worth more than I paid for them. Thirty years of hardware, and the only appreciating asset I have ever owned spent a fortnight sorting 1.7 million speeches into neighbourhoods so that one evening in October I could put an idle question to it about a politician I admire and have the answer inside a minute.&lt;/p&gt;
&lt;p&gt;That is a fair trade. And nobody on the News at Ten would have had the faintest idea what I was talking about, which Brian, in fairness, worked out on his first afternoon.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_kEiyAaam9iF0qsU1612NLA.jpeg&quot; alt=&quot;Brian — My sounding board&quot;&gt;
&lt;em&gt;Brian — My sounding board&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If you enjoyed what must have been an ordeal but hopefully you got this far please give it as many claps as you would if you were in the House of Commons.&lt;/p&gt;
</content:encoded><category>SQL Server</category><category>AI &amp; Data Science</category></item><item><title>I’m 53, She is 33 And Wants A Baby, So, Meet Brian The Sausage Dog. (SQL Animation is a bonus)</title><link>https://sqlartist.github.io/posts/im-53-she-is-33-and-wants-a-baby-so-meet-brian-the-sausage-dog-sql-animation-is-a-bonus/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/im-53-she-is-33-and-wants-a-baby-so-meet-brian-the-sausage-dog-sql-animation-is-a-bonus/</guid><description>This has it all, including the ransom note. SQL is fun, Have fun or the dog gets it..</description><pubDate>Sat, 03 Oct 2026 22:52:50 GMT</pubDate><content:encoded>&lt;p&gt;I struggle where to start with this one but I think I can make it readable, enjoyable and a template for anyone else with a younger partner and of course some never seen before SQL techniques.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_JcMZZ-vg1k-Fekek3kmdRQ.gif&quot; alt=&quot;Brian, the Dachshund, Created using SQL Server Spatial&quot;&gt;
&lt;em&gt;Brian, the Dachshund, Created using SQL Server Spatial&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I wont beat around the bush, she wants a baby (33), I’m 53 and a dead man walking, so we compromised. We got a dachshund and named him Brian.&lt;/p&gt;
&lt;p&gt;Brian is evil reincarnated but is also the cutest little sausage dog you can imagine. We literally get stopped everywhere with people asking about him. When I’m walking him, well I say walking it really is me carrying him to the various green areas near us because he already has a list of things he does and doesn’t like. This is after 4 days.&lt;/p&gt;
&lt;p&gt;Rule 1 — he doesn’t come into my office&lt;/p&gt;
&lt;p&gt;&lt;em&gt;We (Brian and me) sat watching Sausage Dog videos for 2 hours yesterday in my office.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Rule 2 — he doesn’t sleep on the bed or even go near the bed&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_EdtBrUk5h6fTYpQyZsoVbw.jpeg&quot; alt=&quot;Just look at his eyes — he knows what he is up to. Yes this is my side of the bed.&quot;&gt;
&lt;em&gt;Just look at his eyes — he knows what he is up to. Yes this is my side of the bed.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Rule 3 — he has to be trained properly&lt;/p&gt;
&lt;p&gt;&lt;em&gt;As you can imagine when you have two languages spoken in the house that should be one language spoken to the dog. Sit, Come, Stay etc…. but no its all sorts of Polish, mixed with English (I think) and never just the one word, multiple words to describe the thing he is meant to understand, spoken in Polish very fast. His training is not going well.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;moving-on&quot;&gt;Moving on&lt;/h2&gt;
&lt;p&gt;I wanted to write a SQL Server spatial story today and I did, but the end of the spatial stuff I thought to myself, this is all very important, looks actually useful and business relatable. I simply cannot leave the demo code and application just like that, I have to put a swing on it.&lt;/p&gt;
&lt;p&gt;So I did what any respectable SQL developer would do when he realised he couldn’t end the weekend doing this:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;RETURN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; geometry&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;::STGeomFromText(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;JitterWkt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@g.AsTextZM(), @amp, @seed), @g.STSrid)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I wrote a cartoon called “The Dachshund” starring Brian, using SQL Server 2025 Spatial and the Geometry datatype. Now you might be thinking, yes we have seen Christmas Trees rendered in SQL, we have seen Trevor’s head rendered in SQL, we even have Doom running inside SQL Server. But this will be a full animated cartoon coming straight from the SQL Engine.&lt;/p&gt;
&lt;p&gt;Here is the code:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* ==========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Spatial Studio - 07 Toon: cut-out animation inside SQL Server&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Characters are puppets made of geometry parts. Each part hangs off a parent&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   at a pivot, like the card cut-outs of 1970s children&apos;s TV. Keyframes are&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   rows; toon.Render interpolates them, composes the affine transforms down the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   puppet with a recursive CTE, applies them with sx.Affine and adds a felt-tip&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   &quot;boil&quot; with sx.Jitter. Starring Brian, a black-and-tan dachshund.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   ========================================================================== */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;USE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SpatialStudio;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SCHEMA_ID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;toon&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXEC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CREATE SCHEMA toon AUTHORIZATION dbo;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* ---- tables ---- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DROP&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IF&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, toon.[Key], &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Casting&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Scene&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Scene&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Scene  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_ToonScene &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Title  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Frames &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Fps    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DEFAULT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 12&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Part&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Part      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Parent    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,           &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- hangs off this part of the same character&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PivotX    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,       &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- the drawing pin: rotations happen about this point&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PivotY    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Z         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,       &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- drawing order, low first&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Color     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Shape     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GEOMETRY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,       &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- rest pose, in the character&apos;s own coordinates&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    OscPeriod &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DEFAULT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- frames per cycle for the &apos;osc&apos; (swing) and &apos;bob&apos; channels&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    OscPhase  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DEFAULT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- degrees&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Boil      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DEFAULT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- multiplier on the felt-tip wobble&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Label     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    FontSize  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    LineWidth &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_ToonPart &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Part)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Casting&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Scene     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_ToonCasting &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Scene, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* Channels: angle (degrees, anticlockwise), dx, dy (move), sx (1 = as drawn, -1 = flipped),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   osc (swing amplitude in degrees, cycling with OscPeriod), bob (hop height), vis (1 shown, 0 hidden).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Ease on a key says how we arrive at it: smooth, linear or step.                                 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.[Key]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Scene     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Part      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Channel   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CHECK&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Channel &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;sx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Frame     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Ease      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DEFAULT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CHECK&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Ease &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;linear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_ToonKey &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Scene, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Part, Channel, Frame)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Frame&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Scene     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Frame     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Part      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Z         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Shape     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GEOMETRY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Color     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Label     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    FontSize  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    LineWidth &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_ToonFrame &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Scene, Frame, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Part)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* ---- the boil: nudge every vertex by a hash of its own coordinates ----&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   The same input point always gets the same nudge, so closed rings stay closed. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FUNCTION&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;JitterWkt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@wkt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX), @amp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @seed &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;RETURNS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @out &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @out &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; STRING_AGG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Piece&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX)), &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;,&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITHIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GROUP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ordinal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; STRING_SPLIT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@wkt, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;,&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; L &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; DATALENGTH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, lp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CHARINDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;(&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;REVERSE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Prefix &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lp&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LEFT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lp&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; b&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Rest &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DATALENGTH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Prefix&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CHARINDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;)&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Rest&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; d&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Coord  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;rp&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Rest&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LEFT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Rest&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;rp&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        Suffix &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;rp&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Rest&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;rp&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Lead &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LEFT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Coord&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        Ct   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LTRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RTRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Coord&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; f&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; sp1 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CHARINDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Ct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; g&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Xs     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sp1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LEFT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Ct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sp1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        AfterX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sp1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Ct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sp1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; h&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; sp2 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CHARINDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AfterX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; i&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Ys    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sp2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LEFT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AfterX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sp2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AfterX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        Extra &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sp2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AfterX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sp2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; j&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; X &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; TRY_CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Xs&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; TRY_CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Ys&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; k&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; NX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hash01&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), @seed) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @amp,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        NY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hash01&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), @seed &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 17&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @amp) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; m&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Piece &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                     ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Prefix&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Lead&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FormatNum&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FormatNum&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Extra&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Suffix&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    RETURN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @out;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FUNCTION&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Jitter&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@g &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GEOMETRY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @amp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @seed &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;RETURNS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; GEOMETRY&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @g &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @amp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @amp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @g.STIsEmpty() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; RETURN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @g;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    RETURN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; geometry&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;::STGeomFromText(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;JitterWkt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@g.AsTextZM(), @amp, @seed), @g.STSrid);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* ---- the renderer ---- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PROCEDURE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Render&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @Scene     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @FromFrame &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @ToFrame   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   =&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @Boil      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,     &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- felt-tip wobble in drawing units; 0 for a clean line&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @Store     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BIT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;        -- 1: write toon.Frame; 0: return the rows&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOCOUNT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t0 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DATETIME2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SYSDATETIME&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ToFrame &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ToFrame &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Frames &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Scene&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Scene &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Scene;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ToFrame &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THROW&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 50001&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Unknown scene - add it to toon.Scene first.&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DROP&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IF&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #f, #ch, #loc, #world;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Frame &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #f &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GENERATE_SERIES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@FromFrame, @ToFrame);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- 1. every keyed channel, interpolated for every frame&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Channel&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                        WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                        ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;k1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                             CASE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Ease&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;linear&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; u&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;u&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; u&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;u&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; u&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;u&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; u&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;u&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #ch&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #f &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; f&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT DISTINCT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Part, Channel &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; toon.[Key] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Scene &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Scene) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    OUTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; toon.[Key] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; k&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                 WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Scene&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Scene &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Channel&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Channel&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                 ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; k0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    OUTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Ease&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; toon.[Key] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; k&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                 WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Scene&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Scene &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Channel&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Channel&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                 ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; k1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; u &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                 ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;k1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; u;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CLUSTERED&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; INDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; cx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #ch (Frame, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Part);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- 2. each part&apos;s local affine matrix: move, then flip and rotate about its pivot&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Parent&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           la &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, lb &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, lc &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PivotX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;tx&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PivotX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PivotY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           ld &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, le &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, lf &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PivotY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ty&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PivotX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PivotY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           vis &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vis&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #loc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #f &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; f&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Casting&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; cs &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; cs&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Scene&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Scene&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; cs&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    OUTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; angle &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Channel&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        dx    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Channel&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        dy    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Channel&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        sx    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Channel&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;sx&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        osc   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Channel&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        bob   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Channel&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        vis   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Channel&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                 FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #ch &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; th  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; RADIANS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;angle&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;osc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; PI&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;OscPeriod&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; RADIANS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;OscPhase&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        tx  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        ty  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dy&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;bob&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PI&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;OscPeriod&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        s   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                        vis &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vis&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;th&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;th&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), d &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;th&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), e &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;th&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; m;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- 3. compose down the puppet: world = parent world x local (a recursive CTE per frame)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, a &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;la&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lb&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, d &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ld&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, e &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;le&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, ff &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lf&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, vis &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vis&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #loc &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; l &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Parent&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;la&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ld&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lb&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;le&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lc&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lf&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;la&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ld&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lb&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;le&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lc&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lf&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ff&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vis&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vis&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #loc &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; l &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Parent&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #world &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OPTION&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (MAXRECURSION &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- 4. draw: move every visible part, then boil it (the boil changes every other frame, four drawings, like felt-tip on cel)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Store &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        DELETE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Scene &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Scene &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Frame &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BETWEEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @FromFrame &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ToFrame;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Scene, Frame, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Part, Z, Shape, Color, Label, FontSize, LineWidth)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Scene, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Jitter&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ff&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Shape&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                              ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Affine&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Shape&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ff&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                         @Boil &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Boil&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) % &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Color&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Label&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FontSize&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LineWidth&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #world &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vis&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; scene &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Scene, frames &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ToFrame &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @FromFrame &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, [shapes drawn] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @@ROWCOUNT,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               [render ms] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; DATEDIFF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;MILLISECOND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @t0, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SYSDATETIME&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;());&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ELSE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; frame &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, shape &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Jitter&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Affine&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Shape&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ff&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), @Boil &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Boil&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) % &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;               color &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Color&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, label &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Label&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, fontsize &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FontSize&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, linewidth &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LineWidth&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, opacity &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, part &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CONCAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;.&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), z &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #world &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vis&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Frame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;the-castlist&quot;&gt;The Cast List&lt;/h2&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* ---- the cast ---- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Part, Parent, PivotX, PivotY, Z, Color, Shape, OscPeriod, OscPhase, Boil, Label, FontSize, LineWidth) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Sky&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#bfe6f7&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;POLYGON ((0 0, 1000 0, 1000 450, 0 450, 0 0))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Rays&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;130&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;380&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffe082&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;MULTIPOLYGON (((173.56 373.80, 196.00 380.00, 173.56 386.20, 173.56 373.80)), ((168.89 400.59, 183.40 418.79, 161.60 410.62, 168.89 400.59)), ((149.36 419.51, 150.40 442.77, 137.56 423.34, 149.36 419.51)), ((122.44 423.34, 109.60 442.77, 110.64 419.51, 122.44 423.34)), ((98.40 410.62, 76.60 418.79, 91.11 400.59, 98.40 410.62)), ((86.44 386.20, 64.00 380.00, 86.44 373.80, 86.44 386.20)), ((91.11 359.41, 76.60 341.21, 98.40 349.38, 91.11 359.41)), ((110.64 340.49, 109.60 317.23, 122.44 336.66, 110.64 340.49)), ((137.56 336.66, 150.40 317.23, 149.36 340.49, 137.56 336.66)), ((161.60 349.38, 183.40 341.21, 168.89 359.41, 161.60 349.38)))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Sun&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;130&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;380&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffd54f&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (96 380, 130 414, 164 380, 130 346, 96 380))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Hills&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#a5d6a7&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 120, 250 230, 520 140), CIRCULARSTRING (520 140, 760 215, 1000 130), (1000 130, 1000 60, 0 60, 0 120)))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Grass&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#7cb342&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;POLYGON ((0 0, 1000 0, 1000 75, 0 75, 0 0))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Trunk&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#795548&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;POLYGON ((860 70, 886 70, 880 195, 866 195, 860 70))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Leaves1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#558b2f&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (802 215, 842 255, 882 215, 842 175, 802 215))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Leaves2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#689f38&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (853 226, 898 271, 943 226, 898 181, 853 226))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Leaves3&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#7cb342&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (828 262, 868 302, 908 262, 868 222, 828 262))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Flower1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#f06292&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (65 40, 70 45, 75 40, 70 35, 65 40))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Flower2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#fff176&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (325 22, 330 27, 335 22, 330 17, 325 22))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Flower3&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#f06292&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (465 50, 470 55, 475 50, 470 45, 465 50))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Flower4&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ba68c8&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (605 18, 610 23, 615 18, 610 13, 605 18))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Flower5&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#fff176&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (945 35, 950 40, 955 35, 950 30, 945 35))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Cloud1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Puff1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffffff&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (-22 0, 0 22, 22 0, 0 -22, -22 0))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Cloud1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Puff2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Puff1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffffff&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (7 -4, 24 13, 41 -4, 24 -21, 7 -4))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Cloud1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Puff3&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Puff1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffffff&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (-37 -6, -22 9, -7 -6, -22 -21, -37 -6))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Cloud2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Puff1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffffff&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (-22 0, 0 22, 22 0, 0 -22, -22 0))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Cloud2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Puff2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Puff1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffffff&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (7 -4, 24 13, 41 -4, 24 -21, 7 -4))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Cloud2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Puff3&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Puff1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffffff&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (-37 -6, -22 9, -7 -6, -22 -21, -37 -6))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;LegBackFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;57&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;45&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#1a110c&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (COMPOUNDCURVE ((-63 48, -63 7.5), CIRCULARSTRING (-63 7.5, -54.75 -0.75, -46.5 7.5), (-46.5 7.5, -51 48, -63 48)))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;LegFrontFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;63&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;45&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#1a110c&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (COMPOUNDCURVE ((57 48, 57 7.5), CIRCULARSTRING (57 7.5, 65.25 -0.75, 73.5 7.5), (73.5 7.5, 69 48, 57 48)))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;180&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;84&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;70&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#2b1d16&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (-84 75, -108 85.5, -126 109.5), (-126 109.5, -130.5 106.5), CIRCULARSTRING (-130.5 106.5, -111 78, -84 66), (-84 66, -84 75)))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#2b1d16&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (COMPOUNDCURVE ((-67.5 37.5, 67.5 37.5), CIRCULARSTRING (67.5 37.5, 90 60, 67.5 82.5), (67.5 82.5, -67.5 82.5), CIRCULARSTRING (-67.5 82.5, -90 60, -67.5 37.5)))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Belly&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;21&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#c47a3a&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;POLYGON ((-45 39, 60 39, 70.5 46.5, 60 54, -45 49.5, -54 43.5, -45 39))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Collar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;78&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;78&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;22&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#d32f2f&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;POLYGON ((72 60, 82.5 57, 93 90, 82.5 93, 72 60))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Tag&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Collar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;82&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;23&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffca28&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (78.6 53.25, 82.5 57.15, 86.4 53.25, 82.5 49.35, 78.6 53.25))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;LegBackNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;48&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;45&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#2b1d16&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (COMPOUNDCURVE ((-54 48, -54 7.5), CIRCULARSTRING (-54 7.5, -45.75 -0.75, -37.5 7.5), (-37.5 7.5, -42 48, -54 48)))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;180&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;LegFrontNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;72&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;45&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;26&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#2b1d16&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (COMPOUNDCURVE ((66 48, 66 7.5), CIRCULARSTRING (66 7.5, 74.25 -0.75, 82.5 7.5), (82.5 7.5, 78 48, 66 48)))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;PawBackNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;LegBackNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;48&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;45&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;27&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#c47a3a&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (-51 4.5, -45 10.5, -39 4.5, -45 -1.5, -51 4.5))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;PawFrontNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;LegFrontNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;72&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;45&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;27&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#c47a3a&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (69 4.5, 75 10.5, 81 4.5, 75 -1.5, 69 4.5))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;84&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;84&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#2b1d16&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (81 93, 102 114, 123 93, 102 72, 81 93))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Snout&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;117&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;90&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;31&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#2b1d16&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (COMPOUNDCURVE ((114 102, 150 90), CIRCULARSTRING (150 90, 157.5 82.5, 150 75), (150 75, 114 75, 114 102)))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Muzzle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Snout&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;117&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;90&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#c47a3a&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;POLYGON ((117 75, 150 75, 153.75 79.5, 120 83.25, 117 75))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Nose&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Snout&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;117&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;90&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;33&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#0d0d0d&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (149.55 87, 153.75 91.2, 157.95 87, 153.75 82.8, 149.55 87))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Eye&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;112&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;99&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;34&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffffff&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (108.3 99, 112.5 103.2, 116.7 99, 112.5 94.8, 108.3 99))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Pupil&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Eye&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;112&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;99&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;35&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#0d0d0d&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (111.45 99, 113.85 101.4, 116.25 99, 113.85 96.6, 111.45 99))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brow&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;111&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;106&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;36&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#c47a3a&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (108.15 107.25, 111 110.1, 113.85 107.25, 111 104.4, 108.15 107.25))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;96&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;108&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;37&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#1f140f&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (COMPOUNDCURVE ((93 111, 105 108), CIRCULARSTRING (105 108, 103.5 87, 93 69), CIRCULARSTRING (93 69, 84 78, 85.5 96), (85.5 96, 93 111)))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;13&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#e53935&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (-13.5 13.5, 0 27, 13.5 13.5, 0 0, -13.5 13.5))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Stripe&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;13&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;41&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffffff&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;POLYGON ((-12.75 11.4, 12.75 11.4, 12.75 15.6, -12.75 15.6, -12.75 11.4))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Bang&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffffff&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (-22 0, 0 18, 22 0, 0 -18, -22 0))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;!&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;28&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Bang&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;49&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffffff&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;POLYGON ((-6 -14, 6 -14, -10 -32, -6 -14))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Woof&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffffff&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;CURVEPOLYGON (CIRCULARSTRING (-46 0, 0 26, 46 0, 0 -26, -46 0))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;WOOF!&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Woof&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;49&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#ffffff&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;POLYGON ((10 -20, 22 -18, 34 -44, 10 -20))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Title&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Card&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#fff8e1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;POLYGON ((-215 -40, -200 -58, 200 -58, 215 -40, 215 40, 200 58, -200 58, -215 40, -215 -40))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;BRIAN  in  &quot;The Ball&quot;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;34&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;End&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Card&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;#fff8e1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;POLYGON ((-215 -40, -200 -58, 200 -58, 215 -40, 215 40, 200 58, -200 58, -215 40, -215 -40))&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;THE END&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;the-final-scenebrian-and-theball&quot;&gt;The Final Scene — “Brian and The Ball”&lt;/h2&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* ---- episode one: Brian and the Ball (20 seconds at 12 fps) ---- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Scene&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Scene, Title, Frames, Fps) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Brian in &quot;The Ball&quot;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;241&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; toon&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Casting&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Scene, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Cloud1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Cloud2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bang&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Woof&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Title&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;End&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; toon.[Key] (Scene, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Character&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Part, Channel, Frame, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Ease) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Rays&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Park&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Rays&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;90&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;linear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Cloud1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Puff1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;280&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Cloud1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Puff1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;520&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;linear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Cloud1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Puff1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;350&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Cloud2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Puff1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;640&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Cloud2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Puff1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;820&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;linear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Cloud2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Puff1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;200&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;200&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;150&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;615&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;175&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;615&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;225&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;250&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;linear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;250&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;65&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;sx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;sx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;174&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;sx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;175&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;68&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;142&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;150&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;178&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;184&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;218&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;225&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;150&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;158&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Body&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;168&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;45&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;52&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;150&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;157&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;168&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;175&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;226&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;230&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Head&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;53&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;70&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;55&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;145&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;55&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;152&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;180&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;35&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;220&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;35&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;226&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;70&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;145&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;152&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;62&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;70&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;146&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;152&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;53&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;35&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;62&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;150&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;22&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;226&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;22&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;230&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tail&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;38&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;146&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;38&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;150&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;176&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;180&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;26&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;222&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;26&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;225&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;38&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;146&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;38&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;150&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;176&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;180&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;26&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;222&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;26&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontFar&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;225&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;38&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;146&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;38&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;150&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;176&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;180&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;26&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;222&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;26&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegBackNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;225&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;38&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;146&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;38&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;150&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;176&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;180&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;26&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;222&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;26&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;LegFrontNear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;225&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tag&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tag&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tag&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tag&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;146&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tag&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;150&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tag&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;176&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tag&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;180&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tag&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;222&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Tag&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;osc&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;225&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Eye&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Eye&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Eye&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;26&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Eye&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;110&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Eye&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;112&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Eye&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;196&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Brian&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Eye&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;198&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1080&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1080&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;62&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;780&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;168&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;780&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;171&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;765&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;174&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;765&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;175&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;465&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;225&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;linear&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;65&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;168&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;65&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;171&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;129&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;226&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;129&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;232&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;65&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;150&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;bob&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;62&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Ball&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;angle&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;62&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1273&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bang&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;305&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bang&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;220&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bang&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bang&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;52&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bang&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Woof&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;105&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Woof&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Woof&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Woof&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Bubble&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;229&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Title&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Card&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;500&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Title&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Card&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;280&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Title&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Card&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Title&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Card&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;36&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;End&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Card&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dx&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;500&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;End&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Card&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dy&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;300&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;End&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Card&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;smooth&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;BrianAndTheBall&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;End&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Card&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;vis&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;236&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;step&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;dont-panic&quot;&gt;Don’t Panic&lt;/h2&gt;
&lt;p&gt;The referenced database called “SpatialStudio” is the real demo but I will post it separately to this story. I am very pleased with both this little animation and the spatial and vector examples I have put together. I found when spatial got put into the product back in SQL 2005 (I think) I was so happy and waited for it to explode, and it just didnt really go anywhere. Now I think its got as real chance to be used.&lt;/p&gt;
&lt;p&gt;IN SQL Server 2025 we now have Vector indexes which are based on the &lt;a href=&quot;https://www.microsoft.com/en-us/research/publication/diskann-fast-accurate-billion-point-nearest-neighbor-search-on-a-single-node&quot;&gt;DiskANN&lt;/a&gt; algorithm. DiskANN relies on creating a graph to navigate quickly through all the indexed vectors to find the closest match to a given vector. DiskANN is a graph-based system for indexing and searching large sets of vector data. Take a look at the paper linked for a deep dive into DiskANN. The code I will publish tomorrow uses Vector indexes in the final part of the application.&lt;/p&gt;
&lt;p&gt;Hope you enjoyed this little detour from the heavy on the SQL stories to look at puppies but I needed to animate him.&lt;/p&gt;
&lt;p&gt;If you enjoyed please Clap as its this single metric that makes me lie awake all night wondering if the whole world will have seen my writing, and thinking if everyone clapped multiple times I could be rich beyond my wildest dreams and then I check and see 0 claps. Maybe a different tactic is in order….&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_m7TTx28mugahXnyxhRLmqQ.jpeg&quot; alt=&quot;Right Brian is being held hostage….&quot;&gt;
&lt;em&gt;Right Brian is being held hostage….&lt;/em&gt;&lt;/p&gt;
</content:encoded><category>SQL Server</category><category>Life</category></item><item><title>Twenty Years Later, I Built the Headache Machine Again</title><link>https://sqlartist.github.io/posts/twenty-years-later-i-built-the-headache-machine-again/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/twenty-years-later-i-built-the-headache-machine-again/</guid><description>The Deep Brain Stimulator that fixed my Cluster Headaches and is being used for Parkinsons’ and Tourettes</description><pubDate>Thu, 01 Oct 2026 19:20:53 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_UYWS9j6VtYFrnnbiVTxi6g.jpeg&quot; alt=&quot;Using an archive of Brain Implant data to predict correct placement of electrodes&quot;&gt;
&lt;em&gt;Using an archive of Brain Implant data to predict correct placement of electrodes&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;When your only tool is a database&lt;/p&gt;
&lt;p&gt;Some people get headaches, some people get migraines, I get Cluster Headaches.&lt;/p&gt;
&lt;p&gt;With a headache you can take a tablet and it goes, a migraine you can lie down in the dark and hope it goes and can last a week.&lt;/p&gt;
&lt;p&gt;A Cluster headache is not like that, it may last between 15 mins and an hour. At the worst point mine were lasting an hour, of level 10 pain 12 times every day. The condition used to be called Suicide Headaches and for reasons you can begin to understand. You will want to put your head through a wall. Imagine someone’s stuck a hot poker behind your eye and is slowly turning it, on a schedule, for weeks or giving birth 12 times a day. It is regarded as one of the worst pains known to mankind.&lt;/p&gt;
&lt;p&gt;Mine started as episodic which mean a few weeks of the year you have the headaches but they quickly turned chronic (less than a year), which means the exact opposite, they are relentless and for two weeks in a year they would disappear. As the seasons change was roughly the worst periods.&lt;/p&gt;
&lt;p&gt;Whenever there was a change in the weather, high pressure to low pressure weather patterns would trigger an attack, strong perfume type smells would trigger an attack, and any light would trigger an attack. Going to hospital when it got so bad you literally cannot take it anymore knowing it was going to be worse was a final resort. Only very recently enough medical staff know about Cluster Headaches and offer to turn the lights off in the hospital.&lt;/p&gt;
&lt;p&gt;They turn up at the same time of day and night. The first one of the day was always 3 mins after waking up.&lt;/p&gt;
&lt;p&gt;About twenty years ago, when they first arrived, I did what any desperate person does. I read everything. Journals, forums, the small print on trial protocols. And then I did what any desperate *database* person does. I built a system.&lt;/p&gt;
&lt;p&gt;That’s the thing about spending your life in SQL. When the world goes wrong, you don’t reach for a hammer. You reach for a schema.&lt;/p&gt;
&lt;h2 id=&quot;version-one-the-back-of-thehead&quot;&gt;Version one: the back of the head&lt;/h2&gt;
&lt;p&gt;The idea back then was occipital nerve stimulation. You put small electrodes under the skin at the back of the head, over the occipital nerves, and feed them a gentle current. The theory was that you could calm the pain pathway without anyone opening your skull.&lt;/p&gt;
&lt;p&gt;I liked that last bit a lot.&lt;/p&gt;
&lt;p&gt;It was ex-cranial, so the brain itself stayed out of it. But the question was still the same one I’m asking today: where exactly do you put the thing? A few millimetres either way seemed to decide whether it helped or just gave you a buzzing scalp. So my system tried to line up where the electrodes went with how people actually got on afterwards. Placement in, outcome out, look for the pattern.&lt;/p&gt;
&lt;p&gt;Was it any good? It was a desperate man’s database. It asked the right question with not nearly enough data. But it taught me something I’ve carried ever since. The answer isn’t in the textbook diagram. It’s in what happened to the people who went before you.&lt;/p&gt;
&lt;h2 id=&quot;twenty-years-on-roundtwo&quot;&gt;Twenty years on, round two&lt;/h2&gt;
&lt;p&gt;So why pick it up again? Partly because I’ve spent the last few months making SQL Server do silly things. Doom. Elite. A bouncing Amiga ball. A synth. At some point you ask yourself whether the same tricks could do something that matters.&lt;/p&gt;
&lt;p&gt;And partly because the tools have finally caught up with the idea. SQL Server 2025 has a native `VECTOR` type. Twenty years ago “find me the patients most like this one” meant a pile of hand-rolled maths. Now it’s a function call.&lt;/p&gt;
&lt;p&gt;This time I went inside the skull, at least on paper. Deep brain stimulation, or DBS, is a real treatment for Parkinson’s. For cluster headache it’s still very much experimental, aimed at a spot called the posterior hypothalamus. I built it to handle both, because the problem is the same shape.&lt;/p&gt;
&lt;p&gt;The first decision was the easiest one: X-ray or 3D scan? I briefly fancied X-ray because it’s cheap and everywhere. Then I remembered an X-ray of a head is mostly a very good picture of a skull. You can’t see deep brain structures on it. Real surgical planning uses a 3D MRI, and a CT afterwards to check where the lead actually landed. So that’s what I modelled. Sometimes the harder option is the right one simply because its a hard problem.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;decisions&quot;&gt;Decisions&lt;/h2&gt;
&lt;p&gt;***Brains that look alike.&lt;br&gt;
***Every brain is a slightly different shape. Surgeons stretch each one onto a standard map, but a stretched map still isn’t a person. So each scan becomes a fingerprint of 14 numbers: ventricle widths, brain size, the distance between two landmarks in the middle of the brain, age. The system then finds the 40 previous patients whose fingerprints sit closest. Think of it as a dating app for brains, with worse chat-up lines.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Let the outcomes do the teaching.&lt;/strong&gt;&lt;/em&gt; &lt;br&gt;
This is the lesson from twenty years ago. It doesn’t copy where the neighbours’ electrodes went. It asks where the electrodes went and how well it worked, then works out the spot that best explains the good results. A placement that left someone with side effects counts against that area. There’s a slider for how cautious to be, which felt like the right thing to put in a human’s hands.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Keep it in the database.&lt;/strong&gt;&lt;/em&gt; &lt;br&gt;
Obviously. The search, the scoring and the fitting all run in T-SQL. There’s a Python mirror of the same maths so the Streamlit front end still works on a laptop, but SQL Server does the thinking. Old habits.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Close the loop.&lt;/strong&gt;&lt;/em&gt; &lt;br&gt;
Every new patient’s 12-month result goes back into the library. The next person gets a slightly better answer because of the last one. That’s the bit I wanted most back then.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Simulated data.&lt;/strong&gt;&lt;/em&gt; &lt;br&gt;
I’m not going anywhere near real patient records for a hobby project. So I wrote a simulator that makes up brains, operations and outcomes. The bonus is that with made-up patients you know the right answer. With real ones you never do.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;did-itwork&quot;&gt;Did it work?&lt;/h2&gt;
&lt;p&gt;In the simulation, yes. Modestly. To test it, I hid each past patient in turn and re-planned them from everybody else. Then I compared the suggestion with the standard textbook target.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_t3to9lwF_5pbQL-9upHiKQ.png&quot; alt=&quot;Results of the simulation&quot;&gt;
&lt;em&gt;Results of the simulation&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Half a millimetre doesn’t sound like much. In this part of the brain it’s the difference between “that helped” and “why can I taste rainbows?”&lt;/p&gt;
&lt;p&gt;These are made-up patients, and I wrote the rules they follow, so of course the method can learn them. That shows the machinery works. It doesn’t show it would help a real person. The suggestions also drift a touch closer to the areas that cause side effects, which is exactly why the caution slider exists. A real version would need proper brain registration, real post-op imaging, ethics approval and a lot of people much cleverer than me. There’s already serious open-source work in this area, the Lead-DBS toolbox for one. I’m a database man having a go, not a neurosurgeon.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;neurotargetprototype-application&quot;&gt;NeuroTarget — Prototype Application&lt;/h2&gt;
&lt;p&gt;A SQL Server 2025 system that suggests deep brain stimulation (DBS) electrode placement from anatomically similar previous patients and how their operations turned out. It covers cluster headache (posterior hypothalamus) and Parkinson’s disease (subthalamic nucleus and globus pallidus internus), and has a Streamlit + Plotly front end.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;All data is simulated. This is a research/teaching prototype for exploring the idea. It is not a medical device and must not be used for clinical decisions.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;why-3d-mri-notx-ray&quot;&gt;Why 3D MRI, not X-ray&lt;/h2&gt;
&lt;p&gt;An X-ray is a flat projection and barely shows brain soft tissue, so deep targets can’t be seen on it. Real stereotactic planning is done on a 3D T1/T2 MRI, often fused with CT. After the operation, a CT (or sometimes X-ray) is used only to confirm where the lead actually ended up. The system follows the same pattern:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;typescript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Stage         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Imaging              &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Stored &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                                                             |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|---------------|----------------------|---------------------------------------------------------------------------------------|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Planning      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;D&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; T1&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MRI&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            |&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 14&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;number anatomy &lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt;fingerprint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;`VECTOR(14)`&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AC&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; landmarks, scaling to &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AC&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; space &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; After surgery &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; lead localisation &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Positions &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; the &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; contacts&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;`nt.Contact`&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)                                            &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Follow&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;up     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Clinic scores        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Active contact, efficacy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, side effects, patient rating                              &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;how-a-suggestion-is-made-ntusp_suggestplacement&quot;&gt;How a suggestion is made (nt.usp_SuggestPlacement)&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Fingerprint. At ingest, 14 features are measured from the MRI: brain extents and volume, AC-PC length, third-ventricle width and height, lateral-ventricle volume and span, Evans index, some ratios, and age. They are z-scored against the library and stored as VECTOR(14) (nt.usp_IngestScan).&lt;/li&gt;
&lt;li&gt;Find similar brains. VECTOR_DISTANCE(euclidean, …) picks the K nearest previous implants for the same target. Left and right leads are pooled by mirroring X.&lt;/li&gt;
&lt;li&gt;Fit the sweet spot. Each neighbour gives one observation: where its active contact sat, and how well it worked. A grid search finds the point that best explains those outcomes under the target’s dose–response curve. Similar neighbours count for more, via a Gaussian kernel on anatomy distance. Candidate points are penalised where similar patients reported side effects. The search runs at 1 mm, then refines at 0.25 mm; it’s a CROSS JOIN against nt.GridPoint.&lt;/li&gt;
&lt;li&gt;Map it into this patient’s scan (native mm) and log it in nt.Suggestion.&lt;/li&gt;
&lt;li&gt;Close the loop. nt.usp_RecordImplantOutcome stores the actual contacts and the 12-month outcome. From then on, that patient is evidence for everyone after them.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;does-ithelp&quot;&gt;Does it help?&lt;/h2&gt;
&lt;p&gt;Each historical implant is hidden in turn and re-planned from everyone else. Because the data is simulated, every patient’s true optimal point is known, so both the suggestion and the plain atlas target can be scored against it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_t3to9lwF_5pbQL-9upHiKQ.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Suggested points sit a little closer to side-effect structures than the atlas target does (for example, CH side-effect score 0.9 → 1.4 out of 10). The “Side-effect caution” slider sets that trade-off.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;I created a SQL Server 2025 schema and supporting code. It had to be 2025 as this supports the Vector type and gives me Vector Distance.&lt;/p&gt;
&lt;p&gt;Reference data was created&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Condition&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ConditionId     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_Condition &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Code            &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; UQ_Condition_Code &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UNIQUE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Name&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    OutcomeMeasure  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;200&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Target&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    TargetId        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_Target &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ConditionId     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_Target_Condition &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Condition&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Code            &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; UQ_Target_Code &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UNIQUE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Name&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Laterality      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,              &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Ipsilateral | Bilateral&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    AtlasX          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,              &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- right hemisphere, template mm&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    AtlasY          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    AtlasZ          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- dose-response model used by the fit: Eff = Floor + (Emax-Floor)*exp(-d^2 / 2 Sigma^2)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Emax            &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Floor           &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SigmaMm         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    NoGoName        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;200&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,                  &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- the structure that causes side effects&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    NoGo            &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;                   -- sim only: JSON offset from sweet spot&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* One row per image-derived feature. PopMean/PopStd are learned from the historical library&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   and used to z-score any new scan; Weight lets you emphasise features that matter. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.FeatureDef&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    FeatureNo       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_FeatureDef &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Code            &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; UQ_FeatureDef_Code &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UNIQUE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Description&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;200&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Unit            &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PopMean         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PopStd          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Weight&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DF_FeatureDef_Weight &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* Candidate offsets (mm) for the sweet-spot search. Pass 1 = 1 mm over +-5 mm (1331 pts),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Pass 2 = 0.25 mm over +-1 mm around the pass-1 winner (729 pts). */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.GridPoint&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    GridId  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IDENTITY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_GridPoint &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Pass    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    DX      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    DY      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    DZ      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    L1      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(DX) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(DY) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(DZ)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PERSISTED&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- tie-break: prefer closer to centre&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; INDEX&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; IX_GridPoint_Pass&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GridPoint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Pass) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INCLUDE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (DX, DY, DZ, L1);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then Patient and Scan data.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Patient&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PatientId       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_Patient &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ConditionId     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_Patient_Condition &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Condition&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Sex             &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    AgeAtScan       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PainSide        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,                  &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- cluster headache: side of attacks&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Status&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CK_Patient_Status &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHECK&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Status&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Historical&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Referral&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    IsSimulated     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BIT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DF_Patient_IsSimulated &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Scan&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ScanId          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_Scan &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PatientId       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_Scan_Patient &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Patient&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Modality        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,              &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- MRI_T1_3D&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    AcquiredOn      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    VoxelMm         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ACX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, ACY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, ACZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- landmarks, native mm&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PCX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, PCY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, PCZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    MCPX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ((ACX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PCX) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PERSISTED&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    MCPY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ((ACY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PCY) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PERSISTED&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    MCPZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ((ACZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PCZ) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PERSISTED&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ScaleX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, ScaleY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, ScaleZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,  &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- native -&amp;gt; template&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    RawFeatures     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CK_Scan_RawFeatures &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHECK&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ISJSON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(RawFeatures) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Features        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VECTOR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;               -- z-scored, weighted anatomy fingerprint&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; INDEX&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; IX_Scan_Patient&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Scan&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (PatientId);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* The image itself normally stays in PACS; for the demo the new referrals&apos; volumes live here. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.ScanVolume&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ScanId          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_ScanVolume &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                   CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_ScanVolume_Scan &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Scan&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    DimX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SMALLINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, DimY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SMALLINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, DimZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SMALLINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    OriginX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, OriginY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, OriginZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,  &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- native mm of voxel (0,0,0) corner&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Encoding&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,              &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- zlib-uint8, C order (x,y,z)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Data&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            VARBINARY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then surgery, programming and outcome data.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SEQUENCE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.seqImplant &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; START&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WITH&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1000000&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Implant&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ImplantId       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_Implant &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                  CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DF_Implant_Id &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NEXT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VALUE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FOR&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;seqImplant&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PatientId       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_Implant_Patient &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Patient&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    TargetId        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_Implant_Target &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Target&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Hemisphere      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CK_Implant_Hemi &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHECK&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Hemisphere &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;L&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;R&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ImplantedOn     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PlannedX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, PlannedY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, PlannedZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,          &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- template mm (signed X)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SuggestionId    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; UQ_Implant &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UNIQUE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (PatientId, TargetId, Hemisphere)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* Post-op CT-localised contact centres, template mm (signed X). Contact 0 = deepest. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Contact&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ImplantId       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_Contact_Implant &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Implant&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ContactNo       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    X &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Z &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_Contact &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (ImplantId, ContactNo)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Programming&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ImplantId       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_Programming &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                            CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_Programming_Implant &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Implant&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ActiveContact   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    AmplitudeMa     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DECIMAL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PulseWidthUs    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SMALLINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    FrequencyHz     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SMALLINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     NOT NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Outcome&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    OutcomeId       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IDENTITY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_Outcome &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ImplantId       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_Outcome_Implant &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Implant&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    MonthsPostOp    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    EfficacyPct     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- condition-specific, see nt.Condition.OutcomeMeasure&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SideEffectScore &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- 0 (none) .. 10 (intolerable)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PatientRating   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- 0 .. 10 patient-reported&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    NetBenefit      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (EfficacyPct &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;04&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SideEffectScore) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PERSISTED&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    RecordedAt      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DATETIME2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DF_Outcome_RecordedAt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SYSUTCDATETIME&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;())&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; INDEX&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; IX_Outcome_Implant&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Outcome&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (ImplantId, MonthsPostOp &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* Every suggestion made, so the surgeon&apos;s decision and the eventual result can be audited. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.Suggestion&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SuggestionId        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IDENTITY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_Suggestion &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ScanId              &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_Suggestion_Scan &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Scan&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    TargetId            &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_Suggestion_Target &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Target&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Hemisphere          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    K                   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SideEffectPenalty   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    TemplateX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, TemplateY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, TemplateZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    NativeX   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, NativeY   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, NativeZ   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SdX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, SdY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, SdZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    AtlasShiftMm        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    EffectiveN          &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PredictedEfficacy   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PredictedSideEffect &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    FitRmse             &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    CreatedAt           &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DATETIME2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DF_Suggestion_CreatedAt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SYSUTCDATETIME&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;()),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    AcceptedBySurgeon   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BIT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;          NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* SIMULATION ONLY: each patient&apos;s hidden true optimal point, used to score the method. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.SimTruth&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PatientId   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_SimTruth_Patient &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Patient&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    TargetId    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FK_SimTruth_Target &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Target&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Hemisphere  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    SweetX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, SweetY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, SweetZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- template mm, signed X&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_SimTruth &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (PatientId, TargetId, Hemisphere)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then the evidence.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* Evidence = every implant with a known active contact and its latest outcome.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   X is folded to the right hemisphere so left and right leads pool together. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VIEW&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.vHistoricalEvidence&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ScanId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TargetId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hemisphere&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;        ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; X, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;        o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EfficacyPct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SideEffectScore&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientRating&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NetBenefit&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;        s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Features&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Implant&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; i&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Programming&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Contact&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ContactNo&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ActiveContact&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Scan&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EfficacyPct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SideEffectScore&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientRating&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NetBenefit&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;             FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Outcome&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; o&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;             WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;             ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MonthsPostOp&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;OutcomeId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; o;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* Grid of candidate offsets */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;21&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; i&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; sys&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;all_objects&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GridPoint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Pass, DX, DY, DZ)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 5&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; x &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; z&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 10&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 10&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;25&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; x &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; z&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* =====================================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   NeuroTarget — procedures&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     nt.usp_IngestScan            z-score raw image features -&amp;gt; VECTOR(14), store scan&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     nt.usp_SuggestPlacement      nearest-anatomy neighbours -&amp;gt; fitted sweet spot&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     nt.usp_RecordImplantOutcome  close the loop: implant + contacts + programming + outcome&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;     nt.usp_EvaluateLOO           leave-one-out accuracy vs atlas (simulation ground truth)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   The maths is mirrored line-for-line in python/neurosim/engine.py.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   ===================================================================================== */&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* -------------------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Ingest: RawFeatures is the JSON object produced by the image pipeline, e.g.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   {&quot;brain_w_mm&quot;:136.2, &quot;acpc_mm&quot;:24.1, ... &quot;age&quot;:58}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   ------------------------------------------------------------------------------------- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PROCEDURE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_IngestScan&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @ScanId      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @PatientId   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @Modality    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @AcquiredOn  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @VoxelMm     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @ACX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @ACY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @ACZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @PCX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @PCY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @PCZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @ScaleX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @ScaleY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @ScaleZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @RawFeatures &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOCOUNT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; XACT_ABORT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @missing &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; STRING_AGG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Code&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;, &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FeatureDef&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; f&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; JSON_VALUE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@RawFeatures, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;$.&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Code&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @missing &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS NOT NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @msg &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;500&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;RawFeatures is missing: &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @missing;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        THROW&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 50010&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @msg, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- z-score each feature against the library population, apply its weight, and build the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- JSON array literal that SQL Server 2025 casts straight to VECTOR(n)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @vec &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;        N&apos;[&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; STRING_AGG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;                        f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Weight&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;JSON_VALUE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@RawFeatures, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;$.&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Code&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PopMean&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                        /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PopStd&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DECIMAL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))), &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;,&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                       WITHIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GROUP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FeatureNo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FeatureDef&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; f) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;]&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Scan&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (ScanId, PatientId, Modality, AcquiredOn, VoxelMm,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    ACX, ACY, ACZ, PCX, PCY, PCZ, ScaleX, ScaleY, ScaleZ, RawFeatures, Features)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@ScanId, @PatientId, @Modality, @AcquiredOn, @VoxelMm,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @ACX, @ACY, @ACZ, @PCX, @PCY, @PCZ, @ScaleX, @ScaleY, @ScaleZ, @RawFeatures,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@vec &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VECTOR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)));&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* -------------------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Suggest a placement for one scan / target / hemisphere.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   1. Find the @K implants (same target, other patients) whose scans are nearest in the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      anatomy vector space (VECTOR_DISTANCE euclidean).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   2. Weight them with a Gaussian kernel on that distance (bandwidth = mean distance).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   3. Each neighbour is one observation: active contact position -&amp;gt; efficacy, side effects.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      Grid-search the sweet spot s that best explains those outcomes under the target&apos;s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      dose-response curve, penalised by side-effect burden reported near s.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      Coarse 1 mm pass around the atlas, then a 0.25 mm pass around the winner.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   4. Map the answer into the patient&apos;s own scan (native mm) and log it.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Result set 1: the suggestion. Result set 2: the neighbours and their weights.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   ------------------------------------------------------------------------------------- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PROCEDURE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_SuggestPlacement&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @ScanId             &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @TargetId           &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @Hemisphere         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;R&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @K                  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @SideEffectPenalty  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @Save               &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BIT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @SuggestionId       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;     =&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OUTPUT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOCOUNT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; XACT_ABORT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Hemisphere &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;L&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;R&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;THROW&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 50020&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;@Hemisphere must be L or R&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @q &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VECTOR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), @PatientId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @mx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @my &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @mz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @sx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @sy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @sz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  @q &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Features&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @PatientId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @mx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MCPX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @my &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MCPY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @mz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MCPZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @sx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ScaleX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @sy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ScaleY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @sz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ScaleZ&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Scan&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ScanId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ScanId;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @PatientId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THROW&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 50021&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Unknown @ScanId&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @ay &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @az &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Floor &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Emax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Sigma &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  @ax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasX, @ay &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasY, @az &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasZ, @Floor &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Floor, @Emax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Emax, @Sigma &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SigmaMm&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Target&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TargetId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @TargetId;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THROW&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 50022&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;Unknown @TargetId&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* 1. nearest anatomy */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #nb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        Rn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, ImplantId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, PatientId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, ScanId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        Hemisphere &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, X &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Z &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        EfficacyPct &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, SideEffectScore &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, PatientRating &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        NetBenefit &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Dist &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, KernelW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, NearW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    );&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INSERT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #nb (Rn, ImplantId, PatientId, ScanId, Hemisphere, X, Y, Z,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                EfficacyPct, SideEffectScore, PatientRating, NetBenefit, Dist)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@K)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Dist&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ScanId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hemisphere&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EfficacyPct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SideEffectScore&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientRating&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NetBenefit&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Dist&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ( &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ScanId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hemisphere&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;                  e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EfficacyPct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SideEffectScore&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientRating&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NetBenefit&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;                  VECTOR_DISTANCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;euclidean&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Features&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @q) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Dist&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vHistoricalEvidence&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TargetId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @TargetId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;             AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @PatientId ) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; d&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Dist&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #nb) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;THROW&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 50023&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;No historical evidence for this target&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* 2. similarity kernel */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Dist) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #nb);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #nb &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; KernelW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Dist &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @h));&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @sumW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(KernelW) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #nb);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoS2 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Sigma &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Sigma, @twoR2 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* 3a. coarse pass around the atlas target */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @cx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @cy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @cz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) @cx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @cy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ay &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @cz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @az &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GridPoint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; g&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;KernelW&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Floor &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@Emax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Floor) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dd&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;D2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoS2) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EfficacyPct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @sumW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Fit,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;KernelW&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SideEffectScore&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dd&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;D2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoR2)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @sumW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Risk&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   #nb &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@ax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@ay &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@az &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; D2) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; dd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Pass&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Fit&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SideEffectPenalty &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Risk&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- = np.lexsort + grid order&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* 3b. fine pass around the coarse winner */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @bx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @by &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @bz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Fit &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) @bx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @cx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @by &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @cy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @bz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @cz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Fit &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Fit&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GridPoint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; g&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;KernelW&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Floor &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@Emax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Floor) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dd&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;D2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoS2) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EfficacyPct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @sumW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Fit,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;KernelW&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SideEffectScore&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dd&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;D2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoR2)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @sumW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Risk&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   #nb &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@cx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@cy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@cz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; D2) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; dd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Pass&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Fit&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SideEffectPenalty &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Risk&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* spread of good placements, and outcomes seen close to the answer */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #nb &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; NearW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; KernelW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(X &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @bx) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @by) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Z &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @bz)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoR2);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SdX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @SdY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @SdZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Neff &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @PredEff &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @PredSE &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  @SdX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(X &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @bx)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @SdY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @by)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @SdZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Z &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @bz)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @Neff &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(KernelW)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(KernelW)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @PredEff &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(NearW) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; 1e&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(NearW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; EfficacyPct) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(NearW) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @PredSE  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(NearW) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; 1e&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(NearW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SideEffectScore) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(NearW) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    #nb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; KernelW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; NetBenefit &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; NetBenefit &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; W) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; g;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* 4. into the patient&apos;s own scan */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @sgn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Hemisphere &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;L&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @tx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @sgn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @bx, @ty &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @by, @tz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @bz;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @nx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @tx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @sx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @mx, @ny &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ty &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @sy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @my, @nz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @tz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @sz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @mz;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @shift &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@bx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ax) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@by &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ay) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@bz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @az));&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Save &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Suggestion&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (ScanId, TargetId, Hemisphere, K, SideEffectPenalty,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                              TemplateX, TemplateY, TemplateZ, NativeX, NativeY, NativeZ,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                              SdX, SdY, SdZ, AtlasShiftMm, EffectiveN,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                              PredictedEfficacy, PredictedSideEffect, FitRmse)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@ScanId, @TargetId, @Hemisphere, @K, @SideEffectPenalty,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                @tx, @ty, @tz, @nx, @ny, @nz, @SdX, @SdY, @SdZ, @shift, @Neff,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                @PredEff, @PredSE, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Fit));&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SuggestionId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SCOPE_IDENTITY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  @SuggestionId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SuggestionId, @ScanId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ScanId, @TargetId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TargetId,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @Hemisphere &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Hemisphere, @K &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; K,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @tx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TemplateX, @ty &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TemplateY, @tz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TemplateZ,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @nx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; NativeX, @ny &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; NativeY, @nz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; NativeZ,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @sgn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasX, @ay &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasY, @az &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasZ,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @SdX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SdX, @SdY &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SdY, @SdZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SdZ,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @shift &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasShiftMm, @Neff &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; EffectiveN,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @PredEff &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PredictedEfficacy, @PredSE &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PredictedSideEffect,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Fit) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FitRmse, @h &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Bandwidth;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  Rn, ImplantId, PatientId, ScanId, Hemisphere, X, Y, Z,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            EfficacyPct, SideEffectScore, PatientRating, NetBenefit, Dist, KernelW, NearW&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    #nb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Rn;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* -------------------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Close the loop. @ContactsJson: [{&quot;n&quot;:0,&quot;x&quot;:..,&quot;y&quot;:..,&quot;z&quot;:..}, ...] template mm, signed X&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   (post-op CT localisation). The patient becomes part of the evidence for everyone after.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   ------------------------------------------------------------------------------------- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PROCEDURE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_RecordImplantOutcome&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @PatientId        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @TargetId         &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @Hemisphere       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @ImplantedOn      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @ContactsJson     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @ActiveContact    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @AmplitudeMa      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DECIMAL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @PulseWidthUs     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SMALLINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @FrequencyHz      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SMALLINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @MonthsPostOp     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @EfficacyPct      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @SideEffectScore  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @PatientRating    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @SuggestionId     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @ImplantId        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OUTPUT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOCOUNT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; XACT_ABORT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    BEGIN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TRAN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ImplantId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ImplantId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Implant&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PatientId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @PatientId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TargetId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @TargetId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Hemisphere &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Hemisphere;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ImplantId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ImplantId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NEXT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VALUE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FOR&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;seqImplant&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @px &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @py &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @pz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @px &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TemplateX, @py &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TemplateY, @pz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TemplateZ&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Suggestion&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SuggestionId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SuggestionId;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Implant&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (ImplantId, PatientId, TargetId, Hemisphere, ImplantedOn,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                           PlannedX, PlannedY, PlannedZ, SuggestionId)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@ImplantId, @PatientId, @TargetId, @Hemisphere, @ImplantedOn, @px, @py, @pz, @SuggestionId);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Contact&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (ImplantId, ContactNo, X, Y, Z)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ImplantId, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;z&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; OPENJSON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@ContactsJson) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;$.n&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, x &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;$.x&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;$.y&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, z &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;$.z&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; j;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SuggestionId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS NOT NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            UPDATE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Suggestion&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AcceptedBySurgeon &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SuggestionId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SuggestionId;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    MERGE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Programming&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    USING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ImplantId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ImplantId) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHEN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; MATCHED&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UPDATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ActiveContact &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ActiveContact, AmplitudeMa &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @AmplitudeMa,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                                 PulseWidthUs &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @PulseWidthUs, FrequencyHz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @FrequencyHz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHEN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; MATCHED&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; INSERT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (ImplantId, ActiveContact, AmplitudeMa, PulseWidthUs, FrequencyHz)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                          VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@ImplantId, @ActiveContact, @AmplitudeMa, @PulseWidthUs, @FrequencyHz);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INSERT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Outcome&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (ImplantId, MonthsPostOp, EfficacyPct, SideEffectScore, PatientRating)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@ImplantId, @MonthsPostOp, @EfficacyPct, @SideEffectScore, @PatientRating);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UPDATE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Patient&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; Status&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Historical&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PatientId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @PatientId;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    COMMIT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* -------------------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Leave-one-patient-out evaluation for a whole target, set-based.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   For every historical implant: rebuild its suggestion from everyone else, then score&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   suggestion and plain atlas against the simulated true sweet spot.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   Result set 1: summary. Result set 2: per implant.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   ------------------------------------------------------------------------------------- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PROCEDURE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_EvaluateLOO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @TargetId           &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TINYINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @K                  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @SideEffectPenalty  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 100&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOCOUNT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @ay &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @az &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Floor &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Emax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Sigma &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @NoGo &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  @ax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasX, @ay &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasY, @az &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasZ, @Floor &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Floor, @Emax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Emax, @Sigma &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SigmaMm, @NoGo &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; NoGo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Target&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TargetId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @TargetId;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @gx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;JSON_VALUE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@NoGo, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;$[0]&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @gy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;JSON_VALUE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@NoGo, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;$[1]&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @gz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;JSON_VALUE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@NoGo, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;$[2]&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoS2 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Sigma &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Sigma, @twoR2 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; QId, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hemisphere&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   #q&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vHistoricalEvidence&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TargetId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @TargetId;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nb&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nb&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nb&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nb&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nb&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EfficacyPct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nb&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SideEffectScore&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nb&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NetBenefit&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nb&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Dist&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; KernelW&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   #nb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   #q &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; q&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vHistoricalEvidence&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; qe &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; qe&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@K) &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EfficacyPct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SideEffectScore&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NetBenefit&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               VECTOR_DISTANCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;euclidean&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Features&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;qe&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Features&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Dist&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vHistoricalEvidence&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TargetId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @TargetId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Dist, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ImplantId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; nb;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; QId, KernelW, Dist, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Dist) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; QId) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; H &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #nb)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; KernelW &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Dist &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; H &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; H &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;));&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; QId, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(KernelW) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SumW, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(KernelW)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(KernelW)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Neff&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #nb &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; QId;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* coarse */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;KernelW&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Floor &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@Emax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Floor) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;D2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoS2) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EfficacyPct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FitW,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;KernelW&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SideEffectScore&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;D2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoR2)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; RiskW&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   #nb &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GridPoint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; g&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@ax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@ay &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@az &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; D2) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; d&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Pass&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GridId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ), r &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @ax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CX, @ay &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CY, @az &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CZ,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                  ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FitW&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SideEffectPenalty &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RiskW&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SumW&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rn&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; QId, CX, CY, CZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; r &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* fine */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FX, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FY, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FZ, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;KernelW&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Floor &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@Emax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Floor) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;D2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoS2) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EfficacyPct&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FitW,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;KernelW&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SideEffectScore&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;D2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoR2)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; RiskW&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   #nb &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   #c  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GridPoint&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; g&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; D2) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; d&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Pass&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GridId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ), r &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                  ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FitW&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SideEffectPenalty &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RiskW&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SumW&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;L1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rn&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; QId, FX, FY, FZ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; r &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    /* score against the hidden truth (simulation only) */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ImplantId, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hemisphere&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SuggestErrMm,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@ax  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@ay  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@az  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasErrMm,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ActualContactErrMm,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @Floor &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@Emax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Floor) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoS2) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SuggestEfficacy,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @Floor &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@Emax &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Floor) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@ax  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@ay  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@az  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetZ&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @twoS2) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasEfficacy,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            10&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @gx) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @gy) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @gz)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SuggestSideEffect,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            10&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@ax  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TX&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @gx) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@ay  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @gy) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@az  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetZ&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @gz)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasSideEffect,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Neff&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; EffectiveN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    #res&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    #q &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; q&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    #b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    #w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;QId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;st&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TX, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;st&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;st&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SweetZ&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                 FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SimTruth&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; st&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                 WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PatientId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TargetId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @TargetId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hemisphere&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Hemisphere&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  @TargetId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TargetId, @K &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; K, @SideEffectPenalty &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SideEffectPenalty,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Implants,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(SuggestErrMm) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; MeanSuggestErrMm, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(AtlasErrMm) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; MeanAtlasErrMm,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(ActualContactErrMm) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; MeanActualContactErrMm,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SuggestErrMm &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AtlasErrMm &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FractionCloserThanAtlas,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(SuggestEfficacy) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; MeanSuggestEfficacy, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(AtlasEfficacy) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; MeanAtlasEfficacy,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(SuggestSideEffect) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; MeanSuggestSideEffect, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(AtlasSideEffect) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; MeanAtlasSideEffect&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    #res;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #res &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ImplantId;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I then generated some test data&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_ounSzQKaKUiJogvNOqeBtA.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;and load some images.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_Vffgrmb7yAR3gRcT5B-CGA.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;The to run the app:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;simulate the cohort (≈ 1–2 min): 760 implanted patients + 20 new referrals with MRI volumes&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;cd python&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;python generate_data.py&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;2. With SQL Server 2025&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;export &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NEUROTARGET_CONN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&quot;Driver={ODBC Driver 18 for SQL Server};Server=localhost;UID=sa;PWD=…;TrustServerCertificate=yes&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;python load_sql.py &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;# creates NeuroTarget DB, runs sql/01 + sql/02, loads everything&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;streamlit run app.py &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;# choose &quot;SQL Server 2025&quot; in the sidebar&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FF938A;font-style:italic&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Useful T&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; @&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; INT&lt;/span&gt;&lt;span style=&quot;color:#FF938A;font-style:italic&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; nt.usp_SuggestPlacement &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;ScanId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1761&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;TargetId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Hemisphere &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;R&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;K &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;SuggestionId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; @&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; OUTPUT&lt;/span&gt;&lt;span style=&quot;color:#FF938A;font-style:italic&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; nt.usp_EvaluateLOO &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;TargetId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;K &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;   &lt;/span&gt;&lt;span style=&quot;color:#FF938A;font-style:italic&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; set&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;based; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;~&lt;/span&gt;&lt;span style=&quot;color:#FF938A;font-style:italic&quot;&gt;40M&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; row evaluations, allow a minute&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_WJzzCy6Hs-sgnMmmxCwFIw.png&quot; alt=&quot;Neurotarget 3D&quot;&gt;
&lt;em&gt;Neurotarget 3D&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_B00n_NdZHx4rT-wxD0Mk4g.png&quot; alt=&quot;Neurotarget — Plan&quot;&gt;
&lt;em&gt;Neurotarget — Plan&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_nnYejlxsuQLVVEO_53iI6w.png&quot; alt=&quot;Neurotarget — Validation&quot;&gt;
&lt;em&gt;Neurotarget — Validation&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;app-tabs&quot;&gt;App tabs&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Plan (MRI): axial, coronal and sagittal slices through the suggestion, showing the atlas target and the planned lead trajectory.&lt;br&gt;
- 3D: similar patients’ active contacts mapped into this brain, coloured by benefit and sized by similarity, with ventricles, lead, and a 1-SD spread ellipsoid.&lt;br&gt;
- Similar patients: the neighbours, their weights and outcomes, and how benefit falls away with distance.&lt;br&gt;
- Scan fingerprint: the 14 features and how this brain differs from the library.&lt;br&gt;
- Validation: leave-one-out against the known truth.&lt;br&gt;
- Close the loop: simulates surgery with realistic error, a 12-month outcome, and a matched atlas-aimed counterfactual, then records it.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&quot;a-note-to-the-bloke-from-twenty-yearsago&quot;&gt;A note to the bloke from twenty years ago&lt;/h2&gt;
&lt;p&gt;If I could lean over the shoulder of the version of me hunched over that first database at 2am, eye streaming, I’d tell him three things.&lt;/p&gt;
&lt;p&gt;Your question was a good one. Where the electrode goes matters, and the people who went before you hold the answer.&lt;/p&gt;
&lt;p&gt;You’ll need a lot more data than you’ve got. Be patient. The tools will come.&lt;/p&gt;
&lt;p&gt;And building something, even something that will never go near an operating theatre, is a perfectly reasonable way to feel less helpless. It worked for me then. It still does.&lt;/p&gt;
&lt;p&gt;The code, simulator and front end will be on my GitHub. Usual disclaimer, in bold because it matters: &lt;strong&gt;simulated data, not medical advice, please don’t let anyone drill holes in you because of a SQL query.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you enjoyed this please give it some Claps.&lt;/p&gt;
</content:encoded><category>Life</category><category>Health</category></item><item><title>Can a Database Rave? Making SQL Server Play Music</title><link>https://sqlartist.github.io/posts/can-a-database-rave-making-sql-server-play-music/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/can-a-database-rave-making-sql-server-play-music/</guid><description>I’ve made SQL Server draw, play games and pretend to be other computers. This time I wanted to hear it.</description><pubDate>Sun, 27 Sep 2026 22:56:33 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_wSnrAY9B6yeN5O34l6QLHg.jpeg&quot; alt=&quot;DROP THE BASE(TABLE) — I was so pleased with myself for coming up with this pun. Puns are definitely one level above a dad joke though.&quot;&gt;
&lt;em&gt;DROP THE BASE(TABLE) — I was so pleased with myself for coming up with this pun. Puns are definitely one level above a dad joke though.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I’ve spent the last few months doing daft things with SQL Server. Doom runs in it. The Amiga Boing ball bounces in it. Elite flew in it. I’ve had it pretending to be other hardware altogether. Every one of those was about pictures, or logic, or both.&lt;/p&gt;
&lt;p&gt;What I’d never done was make it *make a noise*.&lt;/p&gt;
&lt;p&gt;So that became the question. Not “can I store an MP3 in a `varbinary` column”. Obviously you can, and it’s about as exciting as a filing cabinet. The question was whether SQL Server itself could produce the sound: every sample, every drum hit, every note, worked out with set-based T-SQL, with Python doing nothing more than passing the bytes to the speakers.&lt;/p&gt;
&lt;p&gt;I also had a target in mind. The Prodigy, “Smack My Bitch Up”.&lt;/p&gt;
&lt;p&gt;I’ll come back to how that went.&lt;/p&gt;
&lt;p&gt;I’m not the first to make SQL sing, and it’s only fair to say so. Ramiro Medina built a synthesiser in PostgreSQL in 2022 that played “Twinkle Twinkle Little Star”, and the ClickHouse folks made NoiSQL. But as far as I can find, nobody had made SQL Server play Amiga MODs, or had a database chop up a breakbeat. That’s where I wanted to go.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;rule-one-sql-makes-the-sound-python-is-just-thespeaker&quot;&gt;Rule one: SQL makes the sound, Python is just the speaker&lt;/h2&gt;
&lt;p&gt;I set myself one rule and stuck to it. Python is allowed to call a stored procedure, take the “varbinary” it gets back and hand it to the sound card. That’s all. No numpy doing the mixing behind my back. No “just this one filter in Python”. If it makes a sound and wasn’t me annoyed at myself for a very stupid bug then SQL Server made it.&lt;/p&gt;
&lt;p&gt;The Python side is “pyodbc” plus “sounddevice”. It fetches two seconds of audio at a time on a background thread, so the next chunk is being rendered while the current one plays. If SQL Server can render faster than real time, you get music. If it can’t, you get silence and an embarrassing pause.&lt;/p&gt;
&lt;p&gt;No pressure, then.&lt;/p&gt;
&lt;h2 id=&quot;why-not-the-prodigythen&quot;&gt;Why not The Prodigy, then?&lt;/h2&gt;
&lt;p&gt;I wanted “Smack My Bitch Up” as the finale. I thought about it properly and decided it was the wrong target, for a couple of reasons.&lt;/p&gt;
&lt;p&gt;The first is how the record’s made. It’s built almost entirely from samples of other records: the drum break, the vocal, that riff. There’s no neat score underneath it to transcribe. To “play” it in SQL Server I’d really be replaying other people’s recordings.&lt;/p&gt;
&lt;p&gt;The second is copyright. Those recordings aren’t mine to reproduce, in SQL or anywhere else.&lt;/p&gt;
&lt;p&gt;So I went the route of all those struggling artists out there and start with creating something myself, my first step on the the music ladder. Synthesise sound from nothing. Then play proper tracker music. Then chop up a record I own and remix it.&lt;/p&gt;
&lt;p&gt;I have realised that over the course of me writing these articles I have used terms that anyone born later than 2000 would not have a clue what I meant. For that I do not apologise. A record means a Vinyl record, but its also just means a track stored as an .mp3 or as as .wav file. Forget it — here is a graphic.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_dV_WiORkT5D7JzivSFjQNQ.jpeg&quot; alt=&quot;I regard myself as young until I look around and notice no one knows what I talking about half of the time.&quot;&gt;
&lt;em&gt;I regard myself as young until I look around and notice no one knows what I talking about half of the time.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;rung-one-a-synthesiser-made-ofmaths&quot;&gt;Rung one: a synthesiser made of maths&lt;/h2&gt;
&lt;p&gt;A sound is just a list of numbers. At CD quality there are 44,100 of them every second. So the first job is a sample clock, and SQL Server 2022 onwards gives you one for free:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GENERATE_SERIES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;GREATEST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ev&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;StartS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @StartSample), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LEAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ev&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EndS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @last)) g&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Every note in the song becomes a range of sample numbers. For each of them I work out the time, the phase, and what the oscillator’s doing at that instant. Classic synth waveforms turn out to be one-liners:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ev&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Waveform&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;sine&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@twoPi &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ph&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;square&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fr&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;saw&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fr&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;triangle&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fr&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; kick: a sine whose pitch falls &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 150&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Hz &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;to&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 45&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Hz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;kick&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@twoPi &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;45&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 105&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;035&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;tt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;035&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; hat: noise minus the previous &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;sample&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;s noise&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; WHEN &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;hat&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; THEN 0.5 * (nz.w - nz1.w)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;END&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The hi-hat is my favourite line in the whole project. Real synths make hi-hats by filtering noise, and filters normally need the previous output. That’s recursion, which is exactly what set-based SQL hates. But if your noise is a pure function of the sample number (it’s an integer hash, not `RAND()`), then “noise now minus noise a moment ago” is a perfectly good high-pass filter. And you can compute it for every sample at once. No loop, no state, just a slightly smug `CROSS APPLY`.&lt;/p&gt;
&lt;p&gt;The acid bassline does things the same way. Instead of a filter sweep, it’s a `SUM` over up to 40 harmonics, with the high ones fading as each note goes on. That’s the squelch you know from the 90s, done as an aggregate.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_pYmAnqi-ZAAIe5eIYkZSFA.png&quot; alt=&quot;The nine sound shapes in rung one&quot;&gt;
&lt;em&gt;The nine sound shapes in rung one&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The shape of every sound in the synth. The top row is the classic oscillators, one formula each. Then there’s noise, and the three drums built from sines, noise and a fade. The acid bass is shown twice: sharp and buzzy as the note starts, then rounded off 0.3 s later as the high harmonics fade.&lt;/p&gt;
&lt;p&gt;Mixing is the most SQL thing imaginable:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(v) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; x &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #voice &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Every drum, every bass note, every stab, all added together per sample. One `GROUP BY`. That’s a mixing desk.&lt;/p&gt;
&lt;h2 id=&quot;getting-the-bytesout&quot;&gt;Getting the bytes out&lt;/h2&gt;
&lt;p&gt;The last hurdle was turning a table of numbers into a WAV file, and I’ll admit this bit gave me a laugh. WAV files are little-endian. SQL Server’s `CAST(int AS binary(4))` is big-endian. So every sample has to be byte-swapped. Then I needed hundreds of thousands of two-byte fragments glued together, in order, quickly.&lt;/p&gt;
&lt;p&gt;`STRING_AGG` doesn’t do binary. It does do strings, though:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @hex &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; STRING_AGG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(i &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; binary&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(i &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; binary&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; varchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(max)), &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WITHIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GROUP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; q;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Pcm &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CONVERT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;varbinary&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(max), @hex, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each sample is byte-swapped, turned into four hex characters and stitched together in sample order, and then the whole string is converted back into binary. Stick a 44-byte RIFF header on the front, also built in T-SQL, and you’ve got a WAV file. It’s the most roundabout way of writing bytes I’ve ever used, and it’s quick.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_DaPMxdOKpTCcimUKwW9ByA.png&quot; alt=&quot;A spectrogram of the first tune SQL Server synthesised&quot;&gt;
&lt;em&gt;A spectrogram of the first tune SQL Server synthesised&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;”Set-Based Breakbeat”: the first thing SQL Server ever played for me. You can see the drums come in, then the acid bass, the stabs, the break with its noise riser, and the drop.&lt;/p&gt;
&lt;p&gt;The first time it played I just sat there grinning. It’s a database. It went “boom tss”. On my machine it ran at roughly real time, which is a sentence I never expected to write about a stored procedure.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;rung-two-a-protracker-player&quot;&gt;Rung two: a ProTracker player&lt;/h2&gt;
&lt;p&gt;Synthesis is clever. But what I actually love is tracker music: Amiga MODs, four channels, 8-bit samples, patterns scrolling up the screen. So rung two was a proper ProTracker `.mod` player. And not “Python reads the file and SQL plays it”. SQL Server reads the file.&lt;/p&gt;
&lt;p&gt;Here’s a lovely surprise. The Amiga ran on a Motorola 68000, which is big-endian. MOD files are big-endian. SQL Server’s binary-to-int cast is big-endian. Thirty-odd years apart, they agree. Reading the header needs no byte-swapping at all:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Mod, O &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 22&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; int&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; HdrLen, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; sample&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; length&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; words&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Mod, O &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 25&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; tinyint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Vol,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Mod, O &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 26&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; int&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; LpStart, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; loop&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; start&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It’s WAV, on the way out, that’s the odd one out.&lt;/p&gt;
&lt;h2 id=&quot;the-one-place-i-gave-in-and-wrote-aloop&quot;&gt;The one place I gave in and wrote a loop&lt;/h2&gt;
&lt;p&gt;A MOD isn’t a flat list of notes. Effects change the speed mid-song. Commands jump to another position, or break out of a pattern early. Slides carry on from one row into the next. That’s genuinely sequential. The “conductor” walks the song one row at a time: a few thousand rows for a typical module.&lt;/p&gt;
&lt;p&gt;What I refused to do was loop over “ticks” or “channels”. Within a row, every effect has a closed form in the tick number `k`. A volume slide is just “start + k × rate, clamped”. An arpeggio is “which third of the chord are we on, `k % 3`”. So each row’s ticks, for every channel, come out of one `INSERT…SELECT`:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Effect&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Axy volume slide&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GREATEST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LEAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ch&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Volume&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; xy&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; xy&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;xy&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; …&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Effect&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Param&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;–0xy arpeggio&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; pb&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;P&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; POWER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; float&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; % &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; xy&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; xy&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.0E0)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That was the most important decision in the whole project. Be procedural only where the problem genuinely is, and set-based everywhere else.&lt;/p&gt;
&lt;p&gt;The mixer, meanwhile, is pure sets. Each tick of each channel says “play sample `s`, starting at position `p`, stepping `d` points per output sample, at volume `v`”. The position of any output sample is then just arithmetic, and a looping sample is just a modulo:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FLOOR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;tk&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PosAtStart&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tk&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;StartSample&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tk&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Step&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; bigint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; P) p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tk&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LoopLength&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;P&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tk&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LoopStart&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tk&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LoopLength&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tk&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LoopStart&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;P&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tk&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LoopStart&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) % &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;tk&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LoopLength&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;P&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tk&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LengthBytes&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;P&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; int&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Idx) m&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It uses the nearest sample point, with no smoothing between points. That isn’t laziness. It’s exactly what the Amiga’s sound chip did, and it’s where the crunch comes from.&lt;/p&gt;
&lt;h2 id=&quot;it-takes-forever-toload&quot;&gt;“It takes forever to load”&lt;/h2&gt;
&lt;p&gt;The first real module I threw at it was `lynx_-_rave_vibes.mod` from The Mod Archive. The demo module had loaded fine. This one sat there. And sat there.&lt;/p&gt;
&lt;p&gt;The culprit was the conductor. Thousands of iterations, each writing to permanent tables, each committing, each flushing to the log. On top of that, SQL Server kept recompiling the statements that touched the small temp tables inside the loop. The fix: switch the loop’s working tables to table variables, buffer everything in memory, and write it all out in one go, in one transaction. Same logic, a fraction of the time.&lt;/p&gt;
&lt;p&gt;It’s the oldest lesson in the book, and I still had to learn it again. Row-by-row isn’t what kills you. Row-by-row *commits* are.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;rung-three-thesampler&quot;&gt;Rung three: the sampler&lt;/h2&gt;
&lt;p&gt;Once MODs were playing, the obvious next wish was the records I actually wanted to hear: early-90s hardcore like Soundcorp’s “Dreamfinder” and the Q-Project’s “Champion Sound”. I went hunting for tracker versions and came up empty.&lt;/p&gt;
&lt;p&gt;Then it clicked. Those records were *made* on samplers. People chopped breakbeats into slices on an Akai and re-triggered them. So instead of finding a MOD of the record, why not have SQL Server do what the Akai did? Load a WAV of a record you own, find the beat, chop it into slices, and turn the slices into instruments in a tracker kit. Then the MOD engine I’d already built can play it, re-order it and re-mix it.&lt;/p&gt;
&lt;h2 id=&quot;finding-the-beat-with-a-self-join&quot;&gt;Finding the beat, with a self-join&lt;/h2&gt;
&lt;p&gt;Beat detection is a lovely set-based problem:&lt;/p&gt;
&lt;p&gt;1. Measure the loudness in 5-millisecond windows.&lt;br&gt;
2. Mark every sudden jump in loudness as an onset: a drum hit, near enough.&lt;br&gt;
3. Auto-correlate the onsets. In other words, join the window table to itself at every possible time offset, and see which offset lines up the most hits.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Lag&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Onset&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Onset&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; R&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #lags g&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; synth&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SamplerEnvelope&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SourceId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SourceId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; synth&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SamplerEnvelope&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SourceId&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SourceId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Win&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Win&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Lag&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Lag&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And it confidently told me my 141.7 BPM test track was 94.5 BPM.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_J5TCH_17GKdt4vttp697dA.png&quot; alt=&quot;Plain auto-correlation picks two-thirds of the tempo; the harmonic score gets it right&quot;&gt;
&lt;em&gt;Plain auto-correlation picks two-thirds of the tempo; the harmonic score gets it right&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Breakbeats are sneaky. The kick drum in a typical break lands every one-and-a-half beats, so “every 1.5 beats” lines up more hits than “every beat” does. Hence two-thirds of the real tempo. The fix is to ask a better question: does this tempo also line up at two beats and at a whole bar? A true beat does; a phantom one doesn’t. Score each candidate as `R(L) + R(2L)/2 + R(4L)/4`, and 141.7 wins clearly.&lt;/p&gt;
&lt;p&gt;Then a final brute-force pass tries 101 tempos just either side of the winner, at every possible starting offset, against every beat in the track. On paper that sounds expensive. In SQL it’s just another join. It pins the tempo to about a hundredth of a percent and tells you where the first beat falls.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_DBgmc7t6HwqoG2IBOCBzzg.png&quot; alt=&quot;Loading a track: 135.000 BPM detected, first beat at 0.000 s, 50 slices. Then a bar-by-bar loudness map, drawn with REPLICATE(‘#’, …), to choose a section, and a kit built from 48 slices.&quot;&gt;
&lt;em&gt;Loading a track: 135.000 BPM detected, first beat at 0.000 s, 50 slices. Then a bar-by-bar loudness map, drawn with `REPLICATE(‘#’, …)`, to choose a section, and a kit built from 48 slices.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The kit comes with a few patterns straight away, so you can hear what it’ll do:&lt;/p&gt;
&lt;p&gt;“Straight:” the section played back exactly as it was.&lt;br&gt;
“Stutter:” every fourth beat, the bar’s first slice is re-triggered and chopped short.&lt;br&gt;
“Chipmunk:” every slice an octave up, twice as fast. That’s *the* hardcore vocal trick of 1992.&lt;br&gt;
“Half-time:” every slice an octave down.&lt;/p&gt;
&lt;p&gt;After that it’s remix-by-”EXEC”:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; synth&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PutNote&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ModId &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Pattern &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Row &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Channel &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Sample &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Note &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;C-3&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Effect &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; 0xE, @Param &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; 0xC2;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; synth&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SetOrder&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;0,1,2,2,3&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; synth&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;BuildModTimeline&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2 id=&quot;issues-encountered&quot;&gt;Issues Encountered&lt;/h2&gt;
&lt;p&gt;Nothing this silly works first time. A few favourites:&lt;/p&gt;
&lt;p&gt;“smallint” × “tinyint” = “smallint”. The mixer multiplied each sample point by its volume. That was fine for 8-bit Amiga samples: 127 × 64 fits easily. The sampler’s 16-bit slices go up to about 32,000 × 64, and SQL Server kept the result as a “smallint”. Arithmetic overflow. The fix is a “CAST(… AS float)” in the right place. A thirty-year-old reminder about data type precedence.&lt;/p&gt;
&lt;p&gt;“The player that waited forever.” When a background render failed, the error died quietly in its thread, and the player sat there waiting for audio that was never coming. Now it tells you what went wrong and stops.&lt;/p&gt;
&lt;p&gt;“The query plan that mixed everything, for every sample.” The first version of the mixer was one big elegant CTE. With a kit of nearly half a million sample points, the optimiser settled on a plan that did far more work than it should. Splitting it into four steps, each landing in an indexed temp table, gave it real row counts to plan with. It’s a bit less elegant and an awful lot faster.&lt;/p&gt;
&lt;p&gt;“The silent sampler” My favourite. The kit built fine and the tracker scrolled along beautifully, but there wasn’t a sound. I had diagnostic queries lined up for the slice data, the tick table and the mixer, ready to take the whole thing apart. &lt;br&gt;
SQL Server was making music the whole time. It was going to my headphones, sitting on the desk, and not to the speakers. After all the byte-swapping, overflows and query plans, the last bug was in Windows Sound settings.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;a-graphic-equaliser-because-ofcourse&quot;&gt;A graphic equaliser, because of course&lt;/h2&gt;
&lt;p&gt;Once it played, I wanted to “see” it play. So the Python window became a dashboard. The tracker scrolls with the current row lit up. There’s a 20-band graphic equaliser with falling bars and peak-hold markers, and left and right level meters that show the Amiga’s hard left-right-right-left panning. Next to it sits a panel of live SQL Server statistics.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_R8SLcFzmTDTzZNiFuw24Ow.png&quot; alt=&quot;The dashboard playing the sampler kit, mid-stutter&quot;&gt;
&lt;em&gt;The dashboard playing the sampler kit, mid-stutter&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_frdSH1i7AfmDAEeE2-oeuQ.png&quot; alt=&quot;The dashboard playing the demo module&quot;&gt;
&lt;em&gt;The dashboard playing the demo module&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;My favourite detail on that panel is that it doesn’t need VIEW SERVER STATE. A session can always read its own row in `sys.dm_exec_sessions`. So after each chunk, the renderer asks SQL Server how much CPU and how many reads it has just spent making the last two seconds of music.&lt;/p&gt;
&lt;p&gt;“RenderMod” also reports its own work counts: ticks, sample points, and how many lookups it joined. Watching that realtime figure while the bars bounce is strangely gripping. Every frame is a race between the query and the sound card.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;so-can-a-databaserave&quot;&gt;So, can a database rave?&lt;/h2&gt;
&lt;p&gt;Yes. Badly, loudly and with enormous enthusiasm.&lt;/p&gt;
&lt;p&gt;What I’ll take away from it isn’t really the audio. It’s the decisions. Write the whole thing as sets, and give in to a loop only where the music is genuinely sequential. Don’t chase a record that isn’t yours to copy; build the tools to make your own. And when something’s slow, look for the commits before you blame the maths.&lt;/p&gt;
&lt;p&gt;The Prodigy will have to wait. But SQL Server can now chop up a breakbeat, pitch the vocal up an octave and play it back through a graphic equaliser. Honestly, the 1992 version of me would have been delighted.&lt;/p&gt;
&lt;p&gt;The full code, including the synth, the MOD player, the sampler and the dashboard is now available: &lt;a href=&quot;https://github.com/sqlartist/SQL-SYNTH&quot;&gt;https://github.com/sqlartist/SQL-SYNTH&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;credits&quot;&gt;Credits&lt;/h2&gt;
&lt;p&gt;“Rave Vibes” by Lynx (`lynx_-_rave_vibes.mod`), from “The Mod Archive”, [modarchive.org](&lt;a href=&quot;https://modarchive.org&quot;&gt;https://modarchive.org&lt;/a&gt;). Thank you to the Archive and the artist for keeping this music alive.&lt;/p&gt;
&lt;p&gt;“Set-Based Breakbeat”, the test module `setbased.mod` and the sampler test audio are all original, made for this project.&lt;/p&gt;
&lt;p&gt;Prior art worth a look: Ramiro Medina’s [How I built a music synthesiser using SQL](&lt;a href=&quot;https://medium.com/@ramiromedina/synthesising-music-using-only-declarative-sql-917bf528ad49&quot;&gt;https://medium.com/@ramiromedina/synthesising-music-using-only-declarative-sql-917bf528ad49&lt;/a&gt;) (PostgreSQL) and [NoiSQL](&lt;a href=&quot;https://github.com/ClickHouse/NoiSQL&quot;&gt;https://github.com/ClickHouse/NoiSQL&lt;/a&gt;) (ClickHouse).&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;If you enjoyed this audio extravaganza then please gives it a huge round of applause and hit the Clap button.&lt;/p&gt;
</content:encoded><category>SQL Server</category></item><item><title>Forget Graham, the Car Crash Man, Meet Nigel, the Data Man</title><link>https://sqlartist.github.io/posts/forget-graham-the-car-crash-man-meet-nigel-the-data-man/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/forget-graham-the-car-crash-man-meet-nigel-the-data-man/</guid><description>A speculative anatomy of life with the world’s knowledge under the skin</description><pubDate>Mon, 21 Sep 2026 17:25:26 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_a1nimEFmpAKLj_IGOtNQhQ.png&quot; alt=&quot;I should have gone with Unlimnited Trevor’s but even I thought that was too much&quot;&gt;
&lt;em&gt;I should have gone with Unlimnited Trevor’s but even I thought that was too much&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Graham is difficult to forget. Created for Australia’s Transport Accident Commission by artist Patricia Piccinini, working with trauma surgeon Christian Kenfield and road safety engineer David Logan, he imagines a human body better equipped to withstand a car crash. His enlarged skull, absent neck and cushioned chest make our physical vulnerability visible. Each strange feature has a purpose. &lt;a href=&quot;https://melbourne.sciencegallery.com/perfection-exhibits/graham&quot;&gt;[1]&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_Dtc1nA8XmsbsbbLudOugAA.png&quot; alt=&quot;This is Graham, a fantastic research project which can be found at www.meetgraham.com.au&quot;&gt;
&lt;em&gt;This is Graham, a fantastic research project which can be found at &lt;a href=&quot;http://www.meetgraham.com.au&quot;&gt;www.meetgraham.com.au&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I would like to introduce someone with a different set of problems. Meet Nigel, the Data Man.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_TwBXgh9kctGRaGcLy6FtWQ.png&quot; alt=&quot;No one will know its actually me, its not like I put myself into every single story.&quot;&gt;
&lt;em&gt;No one will know its actually me, its not like I put myself into every single story.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Nigel lives at a point in the future when the excitement about artificial intelligence has subsided. It has become ordinary infrastructure. People still complain about it, naturally, but mostly because an update has arrived at an inconvenient moment.&lt;/p&gt;
&lt;p&gt;Every human receives a device roughly the size of a 50p coin. It contains all publicly available human knowledge, the index needed to search it and powerful local language models to help make sense of it. New material arrives daily. Between updates, the system works independently of the network.&lt;/p&gt;
&lt;p&gt;That is the premise of our thought experiment. Nigel’s alterations are imagined engineering, rather than a prediction that natural selection will eventually produce a USB socket. His body gives us a way to examine what this future would demand of us.&lt;/p&gt;
&lt;p&gt;This is a little personal. I already live with a deep brain stimulator, implanted to help manage chronic cluster headaches after other treatments had failed. I wrote about the experience in The Six Billion Dollar Man, including the rather unusual business of having to recharge myself. &lt;a href=&quot;https://sqlartist.github.io/posts/the-six-billion-dollar-man/&quot;&gt;[6]&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;That implant is a medical treatment. Nigel’s storage, replaceable thinking modules and mental backups remain imagined technologies. But the experience of depending on something electronic inside the body is already part of my everyday life.&lt;/p&gt;
&lt;p&gt;I’m already part way there. I just need an upgrade or three.&lt;/p&gt;
&lt;p&gt;At first glance, he looks reassuringly ordinary. Then you notice the service seam above his ear, the optical connection in his wrist and the faint amber colouring spreading across his forearms. Nigel is nearly full. He has been meaning to sort out his photographs.&lt;/p&gt;
&lt;p&gt;Start with the small capsule beneath his breastbone. Inside it sits the public archive, separate from his private records. The resemblance to Douglas Adams’s The Hitchhiker’s Guide to the Galaxy is deliberate: a portable guide to an impossibly large world, available whenever its owner needs an explanation. Nigel has simply dispensed with the inconvenience of carrying the book.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_rxuSsZ82vxcfO9AoZSXk2Q.png&quot; alt=&quot;The Beginning…&quot;&gt;
&lt;em&gt;The Beginning…&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;There is real science behind the attraction of very small storage. In 2017, the DNA Fountain researchers reported successful retrieval at a density of 215 petabytes per gram of DNA, using an experiment that stored about 2.14 megabytes. The distinction matters. They demonstrated remarkable density in the storage material; they did not build a device containing 215 petabytes, a fast reader and a computer in one gram. &lt;a href=&quot;https://classpages.cselabs.umn.edu/Spring-2020/csci5980/papers/DNA-Storage/DNA%20Efficient%20Storage%20Architecture.pdf&quot;&gt;[2]&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Multiplying that density by the weight of a coin does not tell us what fits inside a working implant. Nigel also needs machinery to read and write the data, error correction, processing, working memory, power and protection from damage. “The entire public internet” would need a definition, too: a dated collection of accessible material, with decisions about duplication, changing pages and media. Public availability alone would not settle permission to redistribute it.&lt;/p&gt;
&lt;p&gt;Nigel’s coin therefore represents several breakthroughs at once. We can imagine the destination, but we cannot responsibly put a delivery date or a consumer price on it. A prediction of “twenty or thirty years” would be a guess dressed as a product roadmap.&lt;/p&gt;
&lt;p&gt;The independence is easier to recognise. Language models can already run locally on suitable computers. The ambitious leap is giving everyone vastly greater capability in a tiny, affordable device that can operate safely inside a body. &lt;a href=&quot;https://docs.ollama.com/faq&quot;&gt;[3]&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Nigel could ask a question without sending it to a remote AI service. He could work through an idea on a train with no signal, consult his archive during an outage or learn without somebody else keeping a record of every question. Local operation would help protect those conversations, although compromised software, physical access and careless sharing would still matter.&lt;/p&gt;
&lt;p&gt;His archive and his AI would have distinct jobs. A model’s learned parameters are not a faithful filing cabinet containing every source. Nigel would need the underlying documents and an index, with the model retrieving material and explaining it. Research on retrieval-augmented generation already explores this combination. &lt;a href=&quot;https://arxiv.org/abs/2005.11401&quot;&gt;[4]&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This brings us to his eyes. Nigel’s visual display can show where an answer came from, when the source was updated and whether other sources disagree. He can inspect the evidence before acting. He has access to humanity’s accumulated mistakes as well as its discoveries; enormous capacity has not relieved him of the need for judgement.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_-NgX1VJAzyI7VORqml1Z-w.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;His system also needs to say “I don’t know”. Installing the internet in a person should not mean installing the internet’s confidence.&lt;/p&gt;
&lt;p&gt;Follow his arm down to the wrist. Beneath a protective flap is a high-speed optical interface. When Nigel rests his hand on a compatible surface, it can deliver updates and, with his permission, exchange selected files. Ordinary contact with another person does not grant access. A handshake remains a handshake.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_jAtE2RGqSw5e5R-yCosqfQ.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;The port is there because storage capacity and transfer speed solve different problems. To illustrate the scale, imagine a daily update of one petabyte. At one terabyte per second, transferring it would take 16 minutes and 40 seconds. At one gigabit per second, the same transfer would take about 93 days. These calculations use decimal units and ignore overheads; the update size is an illustration, not an estimate of the internet’s daily growth.&lt;/p&gt;
&lt;p&gt;Even Nigel cannot finish Tuesday’s update if Monday’s takes three months. His system would receive changed material and revised index entries, while common updates could be distributed through shared local hubs or broadcast channels. Model upgrades could arrive separately. Adding a new document should not require retraining or replacing the entire model, and a change to model weights would not necessarily make a small download.&lt;/p&gt;
&lt;p&gt;“Offline” would mean independent between updates. Fresh information must still arrive through some connection or physical delivery. Nigel could decline it, but his guide would then need to display its age. Yesterday’s knowledge can be useful, provided nobody mistakes it for today’s.&lt;/p&gt;
&lt;p&gt;The shallow folds around his ribs and upper back are the cooling system. Reading a huge archive and running powerful models require energy, and the heat must go somewhere. Nigel has an external charging connection and a strict limit on how warm his internal components may become. For difficult work, he might still sit at a powered desk that supplies extra cooling. The coin has not abolished the rest of the computer.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_Dhegs-SqeSL9tA9LBCDL2Q.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Move up to the seam above his ear. This is where the idea becomes more unsettling: Nigel has swappable brains.&lt;/p&gt;
&lt;p&gt;Initially, these would be replaceable computing modules. He might fit one suited to mathematical work, another to language, or replace a failed processor without disturbing his private archive. The design would need to preserve his personal settings and keep unfamiliar modules away from information they had no reason to access.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_Rd0MOGtVR6YuHoug9wl0iQ.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Swapping a biological brain, or transferring the person living in it, is a much greater leap. Calling both operations an upgrade conceals the difficult part. A new processor does not establish that Nigel’s memories, character or conscious experience can be moved with it.&lt;/p&gt;
&lt;p&gt;For that possibility, look at the protected compartment near the base of his skull: the emergency backup. In our imagined future, it preserves recoverable records of Nigel’s mental life. An encrypted copy is also held somewhere physically separate. A backup stored only inside Nigel would have an obvious weakness if something happened to Nigel.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_CpkDwq23gJHU2eoW-_8VLA.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;We can already preserve someone’s writing, photographs, recorded voice and recollections. Brain mapping is also an active field of research. A complete wiring diagram of an adult female fruit-fly brain was published in 2024, containing 139,255 neurons and more than 50 million chemical synapses. The work has moved beyond the earlier milestones of worms and fly larvae. &lt;a href=&quot;https://www.nature.com/articles/s41586-024-07558-y&quot;&gt;[5]&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A wiring diagram, however, does not by itself establish how to capture and restore a person. We do not yet know everything a faithful reconstruction would have to preserve, or how to read it from a living human brain without destroying what we hope to save. A convincing digital imitation would not prove continuity of consciousness. There is no established timetable for a restorable human mind.&lt;/p&gt;
&lt;p&gt;That uncertainty belongs in Nigel’s story. It makes his backup more interesting. Suppose two restored versions remembered the same childhood and both believed they were Nigel. Their shared history would not settle which one, if either, continued the original experience. The familiar language of copying files starts to strain when the files can disagree with you.&lt;/p&gt;
&lt;p&gt;Even a less ambitious personal archive would deserve careful design. What happens to the hours since the last backup? Can a corrupted update damage every copy? Who tests recovery? Anyone who has managed important data will recognise the distinction between having a backup and knowing it can be restored. Nigel would have unusually strong reasons to care.&lt;/p&gt;
&lt;p&gt;Now return to his skin. An engineered pigment layer shows storage use, synchronisation and faults through adjustable colours and patterns, independently of his natural complexion. As space runs low, amber bands deepen across his forearms. A small display gives the exact figures. For once, “you look a bit overloaded” is a useful diagnosis.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_t6FJI2VQkaCxqEyaM6wcTA.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;The display can be hidden. A person should not have to announce a technical problem to everyone in the supermarket. The more disturbing version of the display appears when Nigel misses a payment.&lt;/p&gt;
&lt;p&gt;Imagine his wrist showing: “Your personal archive will be deleted in 72 hours. Please update your payment method.”&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_3srHP1_ojZudJUUXKy-e1g.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;This is a deliberately bleak commercial possibility. The core device might have been issued to everyone, while additional capacity, maintenance or recovery services became subscriptions. A supplier could still impose an expiry condition on locally stored data. It would not need a permanent connection if the restriction had been installed in advance.&lt;/p&gt;
&lt;p&gt;Nigel’s red warning skin would expose a failure of ownership. If missing a bill could erase a person’s memories, whoever controlled the account would hold extraordinary power over that person. Giving everyone the hardware would have achieved very little if continued access to their own life remained conditional.&lt;/p&gt;
&lt;p&gt;I would give Nigel permanent control of his personal records, with usable export formats, independent recovery and a baseline service that survives financial difficulty. Optional services could stop when a subscription ends. His own memories should remain accessible. The hardware must distinguish those cases before somebody decides that deletion is a convenient billing feature.&lt;/p&gt;
&lt;p&gt;There is one more control on his chest: a physical privacy switch. Nigel chooses what may leave the device. He can share a piece of public knowledge without sharing his reason for looking it up, and send a file without handing over his entire history. Emergency access would be limited to information he had chosen in advance, rather than treating illness as permission to inspect everything.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_xl7ku2WY0A7arN1C3-Ib1g.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;He would also need some ability to let experiences fade. A permanent archive of every conversation could burden the person carrying it and intrude on everyone they met. Nigel’s improved memory must leave room for other people’s consent, and for his own decision that some moments do not need to become records.&lt;/p&gt;
&lt;p&gt;For me, the appeal of Nigel reaches beyond convenience. Even a life lasting seventy to a hundred years can feel short when so much of it is spent earning enough to live, dealing with illness or worrying about what comes next. By the time we have accumulated experience we might use well, there may be less freedom and time to use it than we had hoped.&lt;/p&gt;
&lt;p&gt;A longer life would not automatically produce a wiser person, and a short life can have an enormous impact. Still, I find the loss of so much hard-won experience troubling. Preserving more of it could help people teach, create and contribute for longer, even if preserving the conscious person remains beyond us.&lt;/p&gt;
&lt;p&gt;Nigel would need time to use his knowledge. If an implant simply made him available for more work, more monitoring and more demands, he might know everything and have no afternoon to himself.&lt;/p&gt;
&lt;p&gt;Graham’s imagined anatomy makes us look again at the roads and vehicles around him. Nigel invites the same scrutiny of the systems we are building around information. His backup compartment, cooling folds and warning skin make their requirements visible. They also give us something concrete to challenge before those requirements become ordinary.&lt;/p&gt;
&lt;p&gt;Perhaps Nigel’s most valuable feature is the small switch on his chest. He presses it, closes the connection and goes outside. The world’s knowledge can wait until he has finished his tea.&lt;/p&gt;
&lt;h2 id=&quot;nigels-interactive-bodytour&quot;&gt;Nigel’s interactive body tour&lt;/h2&gt;
&lt;p&gt;These are imagined features, not a medical or engineering specification. Having said that the most often asked question about my own brain implant is “How do you charge it?”&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_rxuSsZ82vxcfO9AoZSXk2Q.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Breastbone / The knowledge capsule / A 50p-sized home for the public archive, search index and local models. Nigel carries the library; he still has to judge the answers.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_-NgX1VJAzyI7VORqml1Z-w.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Eyes / The evidence display / See the source, its date and any disagreement before acting. Unlimited storage does not make every answer true.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_jAtE2RGqSw5e5R-yCosqfQ.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Wrist /The high-speed interface / Receive updates or share selected files through a protected optical port. Every exchange needs permission. Handshakes remain social.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_Dhegs-SqeSL9tA9LBCDL2Q.png&quot; alt=&quot;Its a good job no one realises that I’m at actually Nigel&quot;&gt;
&lt;em&gt;Its a good job no one realises that I’m at actually Nigel&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Ribs and upper back / Power and cooling / Extra cooling surfaces manage the heat of computation. Heavy work may require a powered desk. Thinking has an energy bill.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_Rd0MOGtVR6YuHoug9wl0iQ.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Above the ear / Swappable brains / Replace specialist computing modules while protecting the private archive. Transferring a biological mind remains a much larger, unresolved idea.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_CpkDwq23gJHU2eoW-_8VLA.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Base of the skull / The emergency backup / Preserve recoverable personal records, with another copy stored elsewhere. A restored archive would not by itself prove that the person survived.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_t6FJI2VQkaCxqEyaM6wcTA.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Forearms / The capacity display / An adjustable pigment layer shows storage use and system health. Colours are paired with patterns and readable numbers. Nigel can hide the display.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_3srHP1_ojZudJUUXKy-e1g.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Inner wrist / The payment countdown / A fictional warning counts down to deletion after a missed bill. This deliberately bad design asks who really owns Nigel’s memories.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_xl7ku2WY0A7arN1C3-Ib1g.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Chest / The privacy switch / Nigel controls what leaves his device and can close the connection. Access to public knowledge does not require access to his private life.&lt;/p&gt;
&lt;h2 id=&quot;research-behind-thearticle&quot;&gt;Research behind the article&lt;/h2&gt;
&lt;p&gt;Sources support the present-day science and Graham’s background. Nigel’s anatomy, service arrangements and dialogue are speculative. No date is claimed for a practical coin-sized knowledge implant or a restorable human mind.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; &lt;a href=&quot;https://melbourne.sciencegallery.com/perfection-exhibits/graham&quot;&gt;Graham — Science Gallery Melbourne&lt;/a&gt;&lt;br&gt;
Graham’s creators, commission and imagined protective anatomy.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; &lt;a href=&quot;https://classpages.cselabs.umn.edu/Spring-2020/csci5980/papers/DNA-Storage/DNA%20Efficient%20Storage%20Architecture.pdf&quot;&gt;Erlich and Zielinski — DNA Fountain enables a robust and efficient storage architecture&lt;/a&gt;&lt;br&gt;
Science, 2017. The experiment encoded about 2.14 MB and reported a physical DNA storage density of 215 PB per gram. The density excludes a complete reader, writer and computer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; &lt;a href=&quot;https://docs.ollama.com/faq&quot;&gt;Ollama — FAQ&lt;/a&gt;&lt;br&gt;
Documents local model operation and the option to disable cloud features. Local execution is already possible; Nigel’s imagined capabilities and form factor are speculative.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4.&lt;/strong&gt; &lt;a href=&quot;https://arxiv.org/abs/2005.11401&quot;&gt;Lewis and colleagues — Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks&lt;/a&gt;&lt;br&gt;
2020. Explores combining a language model with an explicit, retrievable knowledge store.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;5.&lt;/strong&gt; &lt;a href=&quot;https://www.nature.com/articles/s41586-024-07558-y&quot;&gt;Dorkenwald and colleagues — Neuronal wiring diagram of an adult brain&lt;/a&gt;&lt;br&gt;
Nature, 2024. The adult female fruit-fly brain reconstruction contains 139,255 neurons and more than 50 million chemical synapses. It is a structural map, not a demonstrated backup of a conscious individual.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;6.&lt;/strong&gt; &lt;a href=&quot;https://sqlartist.github.io/posts/the-six-billion-dollar-man/&quot;&gt;Trevor Dwyer — The Six Billion Dollar Man&lt;/a&gt;&lt;br&gt;
Medium, 5 September 2026. The author’s account of receiving a deep brain stimulator for chronic cluster headaches and living with the implanted device.&lt;/p&gt;
&lt;p&gt;Transfer calculations use decimal units: 1 PB = 1,000 TB; 1 byte = 8 bits. At 1 TB/s, 1 PB takes 1,000 seconds. At 1 Gbit/s, it takes 8,000,000 seconds, or approximately 92.6 days. These are ideal transfer times without protocol overhead, contention or processing delays.&lt;/p&gt;
&lt;h2 id=&quot;footnote&quot;&gt;Footnote&lt;/h2&gt;
&lt;p&gt;Due to a glitch in the Brain Backup &amp;amp; Restore program and having the entire world’s information available to him…&lt;/p&gt;
&lt;p&gt;One Nigel became two. Two became a support ticket. By lunchtime, the queue for tea had reached orbit.&lt;/p&gt;
&lt;p&gt;Every Nigel insisted he was the original.&lt;/p&gt;
&lt;p&gt;Technical support recommended restoring from backup.&lt;/p&gt;
&lt;p&gt;Unfortunately, technical support was also Nigel.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_a1nimEFmpAKLj_IGOtNQhQ.png&quot; alt=&quot;Feels a bit like Rimmerworld&quot;&gt;
&lt;em&gt;Feels a bit like Rimmerworld&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If you enjoyed a little bit of Nigel naked then please give it a thunderous round of Claps, if not and you want the real thing, I’m afraid it will require hitting the Clap button as well.&lt;/p&gt;
</content:encoded><category>Life</category><category>Health</category></item><item><title>ZX Spectrum in SQL &amp; Daley Thompson’s Decathlon</title><link>https://sqlartist.github.io/posts/zx-spectrum-48k-in-sql-server-running-daley-thompsons-decathlon/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/zx-spectrum-48k-in-sql-server-running-daley-thompsons-decathlon/</guid><description>The Database is the Machine. Memory is a Table. The CPU is a Stored Procedure. The Display is a Join.</description><pubDate>Fri, 18 Sep 2026 21:54:56 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_g39pc0gqZsAk6VhUZOdtog.jpeg&quot; alt=&quot;I was not going to be writing the dis-assembler myself.&quot;&gt;
&lt;em&gt;I was not going to be writing the dis-assembler myself.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;A 48k Sinclair ZX Spectrum running inside SQL Server 2025. Then loading “Daley Thompson’s Decathlon” (Ocean, 1984) from its Original Micro-drive cartridge.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_bp6Ngz7nADmSrScULoWMnA.gif&quot; alt=&quot;It took a huge effort to get to this point&quot;&gt;
&lt;em&gt;It took a huge effort to get to this point&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This was a computer I did not own, having established in other articles I had a Commodore 16, so once again I only saw this a few times but it was the closest you could get to Konami’s Track &amp;amp; Field, a classic Joystick Waggler and always in the local Youth Centre or Chip shop.&lt;/p&gt;
&lt;p&gt;Eventually it did come out for the Commodore 16 but restricted from ten events down to six and because Decathlon literally means 10, it was renamed to “Daley Thompson’s Star Events”.&lt;/p&gt;
&lt;p&gt;One of the absolute best games ever made, it must have earned so much money for manufacturers of joysticks. More joysticks were broken by this game than I think any other.&lt;/p&gt;
&lt;p&gt;I didn’t have a joystick…&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_ZvOIL0FlBvFrfgwm_HFS_Q.jpeg&quot; alt=&quot;Sinclair 48k ZX Spectrum computer (1982) —Photo: Bill Bertram&quot;&gt;
&lt;em&gt;Sinclair 48k ZX Spectrum computer (1982) —Photo: Bill Bertram&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I started this idea wanting to emulate this game based on the Commodore 64, I very quickly changed my mind and decided to emulate the hardware for the ZX Spectrum to be run inside Microsoft SQL Server 2025. This would then allow me to load up the Copy Protection-less version of the game stored on a micro-drive.&lt;/p&gt;
&lt;p&gt;In my life and without a doubt, millions of middle aged humans and a few Chimpanzees around the world, in fact anyone that remembers this era of Computing, will know the exact sound of a Computer Game loading from a Cassette. It was similar to an old school modem.&lt;/p&gt;
&lt;p&gt;But not just that era, their parents will know that sound, and their neighbours will know that sound. It was hated except for a very specific group of people — siblings. They could hear you loading a game a mile away whilst still at school and would rush home just so they could open the front door the wrong way.&lt;/p&gt;
&lt;p&gt;Depending on your relationship with your siblings meant one of two things happened. If you got on well they would sit and watch “YOU” play for hours all the time expecting “THEIR” turn would be coming up&lt;/p&gt;
&lt;p&gt;Yes, of course you’ll be next…&lt;/p&gt;
&lt;p&gt;But if you didn’t get along as nicely as your family thought you did, well they knew the exact moment to “breathe funny” or “dance up the stairs” which caused the loading of that game to fail.&lt;/p&gt;
&lt;p&gt;By simply existing in this world, they would cause some level of Quantum Fluctuation and 100% would make the loading of that cassette fail an indescribable number of times.&lt;/p&gt;
&lt;p&gt;When I said I was bored during these years in an earlier story on Medium, it wasn’t quite the truth, I would go a step further with the 1980’s and specifically the loading of any software onto any computer back then and say mummification was closer to the feeling and these cassettes loaders did not help one bit.&lt;/p&gt;
&lt;p&gt;They would hypnotise you with their weird sounds and because of your sister deliberately flapping her arms “hoping” to cause “The Butterfly Effect” from another part of the house and making me “start all over again” for the 100th time&lt;/p&gt;
&lt;p&gt;&lt;em&gt;I̶ ̶n̶o̶w̶ ̶k̶n̶o̶w̶ ̶t̶h̶i̶s̶ ̶w̶a̶s̶ ̶i̶n̶ ̶f̶a̶c̶t̶ ̶p̶r̶e̶p̶a̶r̶a̶t̶i̶o̶n̶ ̶f̶o̶r̶ ̶b̶̶̶e̶̶̶i̶̶̶n̶̶̶g̶̶̶ ̶̶̶m̶̶̶a̶̶̶r̶̶̶r̶̶̶i̶̶̶e̶̶̶d̶̶̶.̶ ̶T̶h̶e̶ ̶e̶x̶a̶c̶t̶ ̶m̶o̶m̶e̶n̶t̶ ̶y̶o̶u̶ ̶s̶t̶a̶r̶t̶ ̶t̶o̶ ̶d̶o̶ ̶s̶o̶m̶e̶t̶h̶i̶n̶g̶ ̶f̶o̶r̶ ̶y̶o̶u̶r̶s̶e̶l̶f̶ ̶o̶r̶ ̶a̶ ̶h̶o̶b̶b̶y̶ ̶e̶v̶e̶n̶ ̶a̶n̶d̶ ̶a̶ ̶c̶u̶r̶i̶o̶u̶s̶ ̶l̶o̶v̶i̶n̶g̶ ̶p̶a̶r̶t̶n̶e̶r̶ ̶a̶s̶k̶s̶ ̶”̶W̶h̶a̶t̶ ̶y̶o̶u̶ ̶u̶p̶ ̶t̶o̶?̶”̶&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;(Which is why Men die earlier than women — they give up :))&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;But this was going to be far easier. Why?&lt;/p&gt;
&lt;p&gt;Because I am going to use a Micro-drive, not a cassette. Micro-drives were as rare as the 3” floppy disk used in an Amstrad PCW8256 machines. (The world standard was 3.5” floppy disks) but good old Sir Alan Sugar must have got hold of a job lot from the back of a van and built his genuinely incredible machine around these disks.&lt;/p&gt;
&lt;p&gt;Micro-drives do not have the brutal Copy Protection software embedded into many Game Cassette tapes from that era.&lt;/p&gt;
&lt;p&gt;Side Note: I’m 53 and never once heard of copy protection on a cassette before this project. People used to tape music all the time. But now it makes a bit more sense and perhaps it wasn’t the nightmare siblings of this world causing these load failures, perhaps it was the copy protection kicking in due to you using “a friends copy of the game”.&lt;/p&gt;
&lt;h2 id=&quot;first-the-honest-bit-aboutfirsts&quot;&gt;First, the honest bit about firsts&lt;/h2&gt;
&lt;p&gt;I nearly opened this with “nobody has ever done this.” Then I checked, which I recommend doing before you put a claim like that on the internet.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Peter Negenborn built an Intel 8080 emulator in T-SQL and ran CP/M on it.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;He emulated the Altair 8800’s processor as stored procedures, emulated the&lt;br&gt;
serial ports, ran Altair BASIC — Microsoft’s first product — and then&lt;br&gt;
emulated the floppy controller with the disk image sitting in a table so it&lt;br&gt;
could boot a real operating system.&lt;/p&gt;
&lt;p&gt;[Running an 8080 emulator (and CP/M) on SQL Server](&lt;a href=&quot;https://www.linkedin.com/pulse/running-8080-emulator-cpm-sql-server-peter-negenborn&quot;&gt;https://www.linkedin.com/pulse/running-8080-emulator-cpm-sql-server-peter-negenborn&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;That’s the same shape as what I’ve done, and the 8080 is the Z80’s direct&lt;br&gt;
ancestor. So no, not a first, and I’m glad to be in that company rather than&lt;br&gt;
alone in a field.&lt;/p&gt;
&lt;p&gt;As far as I can tell nobody’s done a ZX Spectrum this way, and nobody’s&lt;br&gt;
loaded a commercial game off its original Micro-drive cartridge into a&lt;br&gt;
database and played it. But absence of search results isn’t proof, and&lt;br&gt;
somebody probably did a 6502 in PL/SQL in 2009 and never told anyone.&lt;/p&gt;
&lt;h2 id=&quot;why-the-spectrum-matters-and-why-its-a-goodtarget&quot;&gt;Why the Spectrum matters, and why it’s a good target&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_D4lBAmr2foYPK7DiZ75E7Q.jpeg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Clive Sinclair built the world’s first slimline pocket calculator in 1972,&lt;br&gt;
then spent the early eighties making computers cheap enough that ordinary families bought them. The ZX80 was the UK’s first mass-market home computer under £100. The ZX Spectrum followed in 1982–48K of RAM, a Z80 running at 3.5MHz, and those rubber keys.&lt;/p&gt;
&lt;p&gt;It did something no spec sheet captures. It put a programmable machine into hundreds of thousands of British living rooms at a price that didn’t require a family conference, and a generation of us learned to code on it because there was nothing else to do with the thing. The British games industry came out of those bedrooms more or less directly. Sinclair was knighted in 1983 and died in 2021, aged 81.&lt;/p&gt;
&lt;p&gt;The engineering is also *frugal* in a way that makes it a lovely emulation&lt;br&gt;
target. There’s no video chip worth the name. The screen is a bitmap sitting&lt;br&gt;
in RAM at 0x4000, with a daft interleaved layout that saves a few gates at&lt;br&gt;
the cost of making programmers do sums. One interrupt, fifty times a second.&lt;/p&gt;
&lt;p&gt;That’s the machine.&lt;/p&gt;
&lt;p&gt;Which matters, because my first instinct was the Commodore 64.&lt;/p&gt;
&lt;p&gt;I got talked out of it inside about a minute, and the argument was better&lt;br&gt;
than mine. The 64 means a VIC-II with sprites and raster interrupts and&lt;br&gt;
badlines, plus CIA timers, and Ocean-era code leans on all of it. Get it&lt;br&gt;
subtly wrong and you don’t get an error — you get output that looks nearly&lt;br&gt;
right and costs you a fortnight. The Spectrum’s frugality is the whole&lt;br&gt;
point: on that machine 100% of your cost is the CPU, and a CPU is the&lt;br&gt;
boring mechanical bit you already know how to write.&lt;/p&gt;
&lt;p&gt;I’ve been at this long enough to know that changing your mind quickly on&lt;br&gt;
someone else’s better reasoning is a skill rather than a concession. There’s&lt;br&gt;
a new wrinkle when the reasoning comes from an AI, though, which is that&lt;br&gt;
it’ll argue just as confidently when it’s wrong. That came up later.&lt;/p&gt;
&lt;p&gt;The bit that was genuinely mine&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Daley Thompson’s Decathlon&lt;/strong&gt; is the game that destroyed joysticks across&lt;br&gt;
Britain. Ocean, 1984. The entire thing is how fast you can waggle, which&lt;br&gt;
makes it the worst possible fit for an emulator running at a fraction of&lt;br&gt;
real time. That appealed.&lt;/p&gt;
&lt;p&gt;The tape release is Speedlock protected, and emulating a fast loader’s&lt;br&gt;
timing games buys you nothing once the code’s in memory. The obvious dodge is to load it in a normal emulator and take a snapshot — which works, but it’s starting from someone else’s already-solved problem.&lt;/p&gt;
&lt;p&gt;I had the Micro-drive cartridge image. Micro-drive cartridges are unprotected, and it turned out this one had the whole story in it: a BASIC loader with machine code hidden inside a REM statement, jumping into itself, copying a stub into the printer buffer, restoring a saved register set popped off a fake stack it had built in the middle of a program line.&lt;/p&gt;
&lt;p&gt;There’s a moment where you decode those saved registers out of the cartridge bytes and IY comes out as `0x5C3A` — the standard Spectrum system variable pointer. That’s when you know you’ve read it correctly rather than plausibly. Nobody handed us that. It was sitting in a 137KB file that’s been on the internet for thirty years, waiting for someone curious enough to look.&lt;/p&gt;
&lt;p&gt;Knowing that file existed, and why it beat the tape, is the sort of thing&lt;br&gt;
that comes from having lived through it the first time.&lt;/p&gt;
&lt;h2 id=&quot;ten-deploys-that-didntwork&quot;&gt;Ten deploys that didn’t work&lt;/h2&gt;
&lt;p&gt;Here’s the part nobody puts in the article.&lt;/p&gt;
&lt;p&gt;The first version wouldn’t parse. Nor the second. T-SQL has a trap where&lt;br&gt;
`IF x SET &lt;a href=&quot;http://twitter.com/a&quot; title=&quot;Twitter profile for @a&quot;&gt;@a&lt;/a&gt; = 1; ELSE …` is a syntax error — the semicolon terminates the&lt;br&gt;
`IF` and orphans the `ELSE` — and the generator was emitting that pattern&lt;br&gt;
several hundred times. Fixed that, and the ROM image wouldn’t load, because a `0x` binary literal can’t contain whitespace and someone had prettily wrapped 32,768 hex digits into neat rows. Fixed that, and the error handler checking the fix was itself invalid, because `RAISERROR` won’t take a function call as an argument.&lt;/p&gt;
&lt;p&gt;Then three runs produced byte-identical results because the file on disk had changed and the copy on my server hadn’t, and neither of us could tell.&lt;/p&gt;
&lt;p&gt;My contribution through all of that was un-glamorous and, I think,&lt;br&gt;
irreplaceable: I pasted everything back verbatim. Every error, every line&lt;br&gt;
number, full register dumps, disassembly listings, screenshots when words&lt;br&gt;
wouldn’t do. No summarising, no “it didn’t work”. The exact text. The reason I didn’t try to understand the disassembly is shown in the code below.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;DAA — the hardest instruction on the Z80&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- opcode 27h&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- DAA&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@r_F &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@r_A &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 9&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@r_F &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_A &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 153&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BEGIN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 96&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@r_F &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@r_A &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @v) &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;255&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @res &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@r_F &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@r_A &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 6&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 16&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ELSE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@r_A &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @v) &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;255&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @res &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@r_A &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 9&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 16&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_A &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @nn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; f &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;z80_szp&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_A;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_F &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@r_F &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) | @c | @res | (@nn &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;236&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Decimal Adjust Accumulator. It fixes up the accumulator after BCD&lt;br&gt;
arithmetic, and its behaviour depends on the carry flag, the half-carry&lt;br&gt;
flag, the subtract flag and both nibbles of A at once. It is the instruction&lt;br&gt;
that catches out every emulator author, and here it is as T-SQL. There another 700 of these.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. The `DD`/`FD` prefix — how IX and IY get faked&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHILE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @op &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 221&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @op &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 253&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ixy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @op &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 221&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ea &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_PC;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @op &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; val &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;z80_mem&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; addr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ea;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_PC &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@r_PC &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;65535&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_R &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@r_R &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;128&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) | ((@r_R &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;127&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ts &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ts &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ixy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_H; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_H &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_IXH; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_IXH &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_L; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_L &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_IXL; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_IXL &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ixy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_H; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_H &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_IYH; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_IYH &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_L; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_L &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_IYL; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r_IYL &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @t;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The Z80’s index registers are handled by a trick: when a `DD` or `FD` prefix&lt;br&gt;
byte turns up, swap H and L with IXh and IXl, execute the next instruction&lt;br&gt;
normally, then swap back. Every `HL` operation silently becomes an `IX` one for exactly one instruction.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. The bug that halved the machine’s speed&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* EI defers interrupt acceptance by one instruction. That delay&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   has to expire here, at the end of an instruction. Clearing it at&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   the start of the next call -- after the interrupt gate has&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   already been tested -- suppresses every interrupt that follows a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;   frame ending in EI/HALT, which halves the machine&apos;s speed. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ei_pending &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ei_pending &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ei_pending &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ei_pending &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Every frame of a game loop ends `EI` / `HALT`. This flag was being cleared&lt;br&gt;
one step too late, so every other interrupt was suppressed and the machine ran at exactly half speed — from the very first boot.&lt;/p&gt;
&lt;p&gt;Two lines, in the middle of the fetch/execute loop. `EI` defers interrupt&lt;br&gt;
acceptance by one instruction, and that delay has to expire at the end of an&lt;br&gt;
instruction — not at the start of the next call, after the interrupt gate has&lt;br&gt;
already been tested.&lt;/p&gt;
&lt;p&gt;The model can’t see my instance. It has no idea what happened unless I tell&lt;br&gt;
it precisely, and paraphrasing is the fastest way to send the whole thing&lt;br&gt;
down a wrong path. Half the wins in this project came from a number I copied across without understanding it.&lt;/p&gt;
&lt;p&gt;The T-SQL Linter that which is in the code repository is a good example of how you can use the constant failures to your advantage.&lt;/p&gt;
&lt;p&gt;It can catch the structural mistakes that only surface when SQL Server parses 7,500 generated lines.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;. ORPHANED &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;;&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; between&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;statement&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; and&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; its &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; terminates&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; the &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, so the &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; has nothing &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;to&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; attach&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; to&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;IF x SET @a=1; ELSE SET @a=2;&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; is&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a syntax error;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;IF x SET @a=1 ELSE SET @a=2;&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; is&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; fine, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;and&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;IF x BEGIN SET @a=1; END ELSE …&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; is&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; better.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ELSE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; the same thing &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;block&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; body.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EMPTY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BLOCK&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BEGIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; followed only &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;by&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; comments &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;then&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;. T&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-SQL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; requires &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;at&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; least one &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;statement&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;. SPLIT LITERAL &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a 0x &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;binary&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; literal broken across lines. Literals&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; cannot contain whitespace, so wrapping 32k hex&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; digits &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; readability makes the script invalid.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;RAISERROR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ARG &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; substitution arguments must be constants &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;or&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; variables. &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;RAISERROR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;%d&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DATALENGTH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@x)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;is&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a syntax error.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;. UNBALANCED &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BEGIN/CASE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; vs &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; across the &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;file&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;the-moment-itworked&quot;&gt;The moment it worked&lt;/h2&gt;
&lt;p&gt;150 frames of ROM execution, and then I rendered the bottom of the screen as text, straight out of the database:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_02lxdu6hvfnNfacpNgYnng.png&quot; alt=&quot;Finally The Boot loader&quot;&gt;
&lt;em&gt;Finally The Boot loader&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;None of that was re-implemented. Sinclair’s own ROM, running its own memory test — which takes 640,000 instructions and eighty-two frames, something I’d completely forgotten about the Spectrum boot — and then its own character routines, setting individual bits in a table.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_SpS0w7VdN8LVzqvC6XRiZg.png&quot; alt=&quot;You will never feel the excitement of seeing this on a screen, both from back when it came out and also when it lived once again.&quot;&gt;
&lt;em&gt;You will never feel the excitement of seeing this on a screen, both from back when it came out and also when it lived once again.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Just in case you wanted to see what the code looks like for a ZX Spectrum without installing it this is the SQL code which loads it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_d2jbdkjwH2z-V3V2ar3zEg.png&quot; alt=&quot;Do not try to read this, the actual code is in the Github project. It is just showing the shape.&quot;&gt;
&lt;em&gt;Do not try to read this, the actual code is in the Github project. It is just showing the shape.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I sat and looked at that for a while and thought never again…&lt;/p&gt;
&lt;p&gt;To see the process for loading the game onto the ZX Spectrum running inside SQL Server have a look at the RUNBOOK.md&lt;/p&gt;
&lt;h2 id=&quot;where-i-earned-mykeep&quot;&gt;Where I earned my keep&lt;/h2&gt;
&lt;p&gt;Late on, the game hit a black screen and stopped responding. I was told,&lt;br&gt;
confidently, that it had probably timed out into an attract mode.&lt;/p&gt;
&lt;p&gt;I wasn’t sure. So I asked: &lt;em&gt;does this game actually go into a demo after a&lt;br&gt;
few seconds of nothing happening?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;It did, but what was actually happening this time was the input system was holding keys down permanently, and the game was sitting in a loop waiting for a key to come back &lt;em&gt;up&lt;/em&gt;. Six hundred frames with a joystick jammed on.&lt;/p&gt;
&lt;p&gt;The other thing only I could do was decide what mattered. Half real time is&lt;br&gt;
fine, because input is recorded at a true 50Hz and replayed, so emulator&lt;br&gt;
speed never affects the result. Knowing that meant not chasing performance we didn’t need.&lt;/p&gt;
&lt;h2 id=&quot;whats-left&quot;&gt;What’s left&lt;/h2&gt;
&lt;p&gt;The waggle rate is a parameter. The race result is a byte in memory. Which&lt;br&gt;
makes an event’s outcome a function of one number, and a function of one&lt;br&gt;
number can be searched — from T-SQL, on the same instance, in the same&lt;br&gt;
session.&lt;/p&gt;
&lt;p&gt;A stored procedure that hill-climbs its way to a world record in the long&lt;br&gt;
jump.&lt;/p&gt;
&lt;p&gt;That’s next, and I’m looking forward to it more than any of the above. Not&lt;br&gt;
because it’s difficult, but because it’s where the database stops being a place the game lives and becomes the thing that plays it.&lt;/p&gt;
&lt;p&gt;Forty-three years after Sinclair sold the thing for £175, it’s running inside a relational database, being played by a query. I think he’d have found that funny.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_7vSKo9pKXF3vxjHut_z3Mw.jpeg&quot; alt=&quot;10.48s&quot;&gt;
&lt;em&gt;10.48s&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Code is available on GitHub.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/sqlartist/ZXSpectrumSQL&quot;&gt;https://github.com/sqlartist/ZXSpectrumSQL&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I cannot imagine anyone will try this but genuinely when that ZX Spectrum message appears and you realise that is a piece of tin running as software inside the wrong place, and then your loading a tape into this emulation and it works, you have to smile.&lt;/p&gt;
&lt;p&gt;You’ll need your own copy of the game; the Sinclair ROM is included, as Amstrad permit redistribution for emulation. The Z80 core was written by Claude from a Python generator rather than by hand. The bugs were found by both of us, in roughly equal measure.&lt;/p&gt;
&lt;p&gt;If you got to this part of the story then to be honest I should be Clapping you but the system doesn’t work that way so Clap like you have never Clapped before.&lt;/p&gt;
</content:encoded><category>SQL Server</category><category>Retro Computing</category></item><item><title>Thirty Million Pounds of Wrong</title><link>https://sqlartist.github.io/posts/thirty-million-pounds-of-wrong/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/thirty-million-pounds-of-wrong/</guid><description>How a warehouse with the plan upside down taught me everything I know about data and why I’m rebuilding an AS/400 inside SQL Server thirty years later</description><pubDate>Tue, 15 Sep 2026 12:36:04 GMT</pubDate><content:encoded>&lt;p&gt;The warehouse moved, and the planners got the plan upside down.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_H8u5J3oKUGsI8xn2PZEs9w.jpeg&quot; alt=&quot;One can dream can’t they…&quot;&gt;
&lt;em&gt;One can dream can’t they…&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;That’s the whole story. Everything after it is consequences. Three million computer parts went into a new building back to front — the heavy, awkward stuff upstairs in bins that were never sized for it, and the small, light, valuable components downstairs by the doors. Easy to find. Easy to walk off with.&lt;/p&gt;
&lt;p&gt;Nobody did it maliciously. Someone drew a layout, someone else read it the wrong way round, and by the time anyone noticed, three million items were already in the wrong place. You can’t flip a warehouse. You live with it.&lt;/p&gt;
&lt;p&gt;Here’s the part that mattered. The brand new inventory system recorded all of it faithfully.&lt;/p&gt;
&lt;h2 id=&quot;the-gap&quot;&gt;The gap&lt;/h2&gt;
&lt;p&gt;We’d just gone live on an AS/400. It knew where every part was meant to be, and it was completely confident about it. What it didn’t know was where anything actually was.&lt;/p&gt;
&lt;p&gt;I’ve got the sort of memory that holds pictures. It’s not a skill, I didn’t earn it, it just happens to be how my head works — and in a warehouse with the plan upside down it turned out to be worth something. I could walk to a bin. I didn’t need to look it up, and more to the point I’d learnt not to trust it when I did.&lt;/p&gt;
&lt;p&gt;So for a while I was the reconciliation layer between a computer and a building. The system was the authority. I was the correction.&lt;/p&gt;
&lt;p&gt;That’s why I got promoted to Team Leader, and then put in charge of two areas. Not because I was good with computers. Because I could tell you what was true.&lt;/p&gt;
&lt;h2 id=&quot;peter&quot;&gt;Peter&lt;/h2&gt;
&lt;p&gt;I got good with the AS/400 too — and I got good at it before everyone else did, which was its own quiet advantage. When you’re the person who understands the system in a room full of people who don’t, you stop being a storeman fairly quickly.&lt;/p&gt;
&lt;p&gt;But I didn’t get there on my own, and I’m not going to pretend otherwise. Peter Kerrison was the manager of Inventory Control and he showed me everything. His knowledge seemed to have no bottom to it. Every time I thought I’d found the edge of what he knew there was more behind it, and he never once made me feel stupid for asking.&lt;/p&gt;
&lt;p&gt;I’m still grateful. Years later, when I had my first brush with cancer, it was Peter’s wife Dawn who gave me advice and what I needed to know. You don’t repay that. You just try to be the person who does it for somebody else.&lt;/p&gt;
&lt;h2 id=&quot;just-under-thirty-millionpounds&quot;&gt;Just under thirty million pounds&lt;/h2&gt;
&lt;p&gt;At twenty I was handed the job of getting the stock into shape. I ended up adjusting nearly £30 million off the stock holding.&lt;/p&gt;
&lt;p&gt;I want to be precise about that number, because the exciting version is wrong. Most of it wasn’t theft. The bulk of it was onsite balances that hadn’t carried across correctly through the changeover of the main systems; stock that the ledger insisted was ours, sitting in a location that had never really been true in the first place.&lt;/p&gt;
&lt;p&gt;Some of it had genuinely gone. High-value kit turning up in engineers’ lockers. Things left in the pocket of an anti-static coat and honestly forgotten about. That happens in any warehouse and it’s mostly absent-mindedness rather than villainy.&lt;/p&gt;
&lt;p&gt;But the headline is the boring bit, and the boring bit is the whole point: the system was confidently reporting something that had never been the case. My job wasn’t to find thirty million pounds of missing kit. It was to stop the books lying.&lt;/p&gt;
&lt;p&gt;I’ve been doing some version of that job ever since.&lt;/p&gt;
&lt;h2 id=&quot;sixteen-thousand-three-hundred-and-eighty-four&quot;&gt;Sixteen thousand, three hundred and eighty-four&lt;/h2&gt;
&lt;p&gt;Excel 5.0 would hold 16,384 rows. My extracts from the AS/400 were longer than that.&lt;/p&gt;
&lt;p&gt;That’s it. That’s why I learnt SQL Server. Not vision, not a career plan — an arbitrary limit somebody in Redmond picked because it’s two to the fourteenth, and it happened to sit exactly between what I had and what I needed. Thirty years of my working life turn on that constant.&lt;/p&gt;
&lt;p&gt;I was the first person in the company to get a 486 on my desk. I used it to build my own inventory system, deliberately air-gapped from the AS/400, to model where the losses were coming from. That air gap was a decision, not an accident. If you’re the man telling everyone the system of record is wrong, you cannot also be the man with his hands in it. I needed my numbers to be arguable on their own.&lt;/p&gt;
&lt;p&gt;Then I got round the AS/400 team.&lt;/p&gt;
&lt;p&gt;Everybody’s process at the time was to ask them for a CSV extract and wait. I connected to it directly with OLE-DB instead and pulled the data myself, overnight, automatically. Nobody had done that. It reads like a technical footnote and it wasn’t — it was a political act. I stopped requesting the data and started taking it.&lt;/p&gt;
&lt;h2 id=&quot;the-betaversion&quot;&gt;The beta version&lt;/h2&gt;
&lt;p&gt;I was also the first person in the company to be given a personal laptop: a Toshiba Tecra running Windows 3.1. Stephen McKenna — the management accountant, and the man I sat directly in front of — banned me on the spot from installing anything that so much as resembled Windows 95.&lt;/p&gt;
&lt;p&gt;He wasn’t being a dinosaur about it. Stephen loved technology as much as I did. But it was a work machine, and he was the one accountable for it, and he was right.&lt;/p&gt;
&lt;p&gt;Over one weekend, with no internet, no documentation and very nearly no idea what I was doing, I dual-booted that laptop anyway. Work image on Windows 3.1, an early Windows 95 build alongside it. I built the dashboard at night on 95 and came in each morning to a machine that would boot into the forbidden operating system in full view of the man who’d forbidden it.&lt;/p&gt;
&lt;p&gt;My habit until then had been to walk in, hit the power button and go straight for a coffee. I had to break it. Every single morning the first thing I did was stand at my own desk waiting for a boot menu, because the alternative was Windows 95 quietly appearing on a screen a few feet in front of Stephen’s face.&lt;/p&gt;
&lt;p&gt;The dashboard was an automated overnight extract from the AS/400 — every stat from the night before, laid over a map of the UK, animated. I finished it and demonstrated it, and on the same day, in the same breath, I told them the whole thing had been built on the Windows 95 they’d banned. Which by then was the biggest software launch the world had seen.&lt;/p&gt;
&lt;p&gt;I’d like to say I planned the timing. I did.&lt;/p&gt;
&lt;h2 id=&quot;where-yousit&quot;&gt;Where you sit&lt;/h2&gt;
&lt;p&gt;The demonstration went up the chain to Sean Francombe — Stephen’s boss, and the main man. What came back wasn’t a bonus or a certificate. It was a desk.&lt;/p&gt;
&lt;p&gt;I got a seat next to him.&lt;/p&gt;
&lt;p&gt;That’s a strange thing to be proud of until you’ve been a storeman. In my first proper job, in a blue uniform, in a building where the plan was upside down, the reward for being right about the data was that I got moved to sit next to the person who ran the place. I don’t think anything since has meant as much.&lt;/p&gt;
&lt;h2 id=&quot;the-car-i-neverdrove&quot;&gt;The car I never drove&lt;/h2&gt;
&lt;p&gt;Computacenter’s colours were silver and blue.&lt;/p&gt;
&lt;p&gt;A friend of mine was selling a Lotus Sunbeam — a Talbot Sunbeam with a Lotus engine in it — and it was silver and blue. So I bought it.&lt;/p&gt;
&lt;p&gt;I can’t drive. I have never learnt to drive. I did not, at any point in this process, learn to drive.&lt;/p&gt;
&lt;p&gt;It sat on my driveway for two years. I started it once.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_AB0wyDarTK9BhB8bx8l0MA.jpeg&quot; alt=&quot;Not my actual car, but this was it. Company colours.&quot;&gt;
&lt;em&gt;Not my actual car, but this was it. Company colours.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;april-1999&quot;&gt;April 1999&lt;/h2&gt;
&lt;p&gt;In April 1999 Bill Gates launched a Microsoft initiative called Shift, aimed at a UK IT skills shortage — 600,000 internet-related jobs to fill by 2002. The BBC covered it, and I was one of the case studies.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_s7yO2zjs7ZbA23EmtfgAsg.png&quot; alt=&quot;BBC News Online screenshot, “UK shifting into IT skills”, 28 April 1999&quot;&gt;
&lt;em&gt;BBC News Online screenshot, “UK shifting into IT skills”, 28 April 1999&lt;/em&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Trevor Dwyer was a warehouse storeman who transferred to Inventory Control and learned about databases. Four years later, he is one of the most experienced database designers in the country and has been commissioned to write three books on the technology.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_ze56MEjsQQIqQ-yqBLO-yQ.png&quot; alt=&quot;the printed case-study list&quot;&gt;
&lt;em&gt;the printed case-study list&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Around the same time I got a phone call from Redmond telling me I’d been given the MVP award. They’d been watching my contributions online and noticed I’d gone from asking a few questions to answering a great many.&lt;/p&gt;
&lt;p&gt;The email I kept from that week isn’t from Microsoft. It’s from Peter:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“Trevor ‘Storeman to award winning author’ Dwyer. Very good article but missing 1 key sentence.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;After one year at Computacenter, Peter Kerrision, then manager of Inventory Control, recognised that behind the blue uniform which Trevor wore with pride, was an Essex Boy suit trying to get out. The gamble paid off, Trevor ignored convention and decided against sleep for 4 years. The result was a ghostly pale appearance but proved to be the foundation on which Trevor would progress through the company…..&lt;br&gt;
It should finish.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Stephen replied to it:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I’m with Peter on this one… where are our names… after the amount of time we spent cleaning up the stores after your time in there surely the article should be about us!!!!!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Fair, honestly.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_kw-G0ycCOFF8vPHP1uhfHw.png&quot; alt=&quot;Printed from Lotus Notes in 1999. I’ve still got it.&quot;&gt;
&lt;em&gt;Printed from Lotus Notes in 1999. I’ve still got it.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Philip Hulme, who’d founded the company with Peter Ogden, took an interest after that. He’d bought a majority stake in Marcos in 1991 — the sports car outfit — apparently after remarking to Chris Marsh how nice it must be to make cars for a living. Which tells you something about him. At one point I found myself sat on a grass bank at Silverstone next to him, watching his team go round.&lt;/p&gt;
&lt;h2 id=&quot;thirty-yearson&quot;&gt;Thirty years on&lt;/h2&gt;
&lt;p&gt;I’m at [Somewhere that cannot be named] now, on a team that takes what the source systems say and works out what’s actually true before anyone downstream gets to see it.&lt;/p&gt;
&lt;p&gt;It’s the same job. It’s the warehouse. Something upstream is confidently wrong, and somebody has to sit between the system and reality and do the reconciliation.&lt;/p&gt;
&lt;p&gt;So a few weeks ago I started rebuilding the AS/400 inside SQL Server 2025.&lt;/p&gt;
&lt;h2 id=&quot;you-cant-emulate-one-so-donttry&quot;&gt;You can’t emulate one, so don’t try&lt;/h2&gt;
&lt;p&gt;A real machine is TIMI over SLIC — a technology-independent machine interface sitting on top of the Licensed Internal Code. Programs compile to a virtual instruction set and get translated underneath. To boot OS/400 objects you’d need the machine interface fully specified and the Licensed Internal Code itself. The first is only partly public. The second is IBM’s and not mine to run.&lt;/p&gt;
&lt;p&gt;So: a clean-room re-implementation from IBM’s published DDS, CL and RPG references. Which sounds like a compromise but it turned out to be the better project, because what made that machine interesting was never the instruction set.&lt;/p&gt;
&lt;h2 id=&quot;dds-has-nogrammar&quot;&gt;DDS has no grammar&lt;/h2&gt;
&lt;p&gt;Here’s the thing that stopped me.&lt;/p&gt;
&lt;p&gt;Screens and files are defined in DDS, and DDS is column-positional. Not “mostly fixed format” — the meaning of a character is decided entirely by where it sits.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_XUGKd395X6Y72tTYSAHlPg.png&quot; alt=&quot;One DDS statement. The meaning of a character is decided by where it sits.&quot;&gt;
&lt;em&gt;One DDS statement. The meaning of a character is decided by where it sits.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So the DDS parser is six `SUBSTRING` calls. There’s no tokeniser, no grammar, no error recovery. I’ve spent an embarrassing share of my career writing parsers. This one took an afternoon.&lt;/p&gt;
&lt;p&gt;It’s worth sitting with why. In 1988 you typed source into SEU on a block-mode terminal with a column ruler across the top. Columns weren’t a limitation of the format. Columns *were* the interface.&lt;/p&gt;
&lt;h2 id=&quot;a-5250-screen-is-a-projection-not-adrawing&quot;&gt;A 5250 screen is a projection, not a drawing&lt;/h2&gt;
&lt;p&gt;Every field in a display file already carries its own line and position. So rendering a screen isn’t painting, it’s a query: turn every field into a write, explode each write into characters, let later writes win where they overlap, left join onto the full 24×80 grid and aggregate each row back into a string.&lt;/p&gt;
&lt;p&gt;Nothing draws anything. No loop, no buffer, no cursor.&lt;/p&gt;
&lt;p&gt;And subfiles — the scrolling record lists that make a green screen feel like a green screen — fall straight out of it. Subfile record *n* is the same fields one line further down. The page size is a `WHERE` clause. I’d budgeted days for subfiles. They were about twenty lines.&lt;/p&gt;
&lt;p&gt;The same thing happened with record-level access. `CHAIN`, `SETLL`, `READE` aren’t a rival access method I had to bolt onto a relational engine — they’re an index-positioning API. A keyed physical file is an index. When `SETLL` runs it isn’t faking one, it’s driving the real one.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_C96ynUmGSP4nHYz_4dx7LQ.png&quot; alt=&quot;The INQ100 screen&quot;&gt;
&lt;em&gt;The INQ100 screen&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;the-same-bug-thirty-yearslater&quot;&gt;The same bug, thirty years later&lt;/h2&gt;
&lt;p&gt;Then I wrote a bug that stopped me cold, because I had encountered it before.&lt;/p&gt;
&lt;p&gt;Deleting a record left the file pointer sitting on the record it had just deleted. The next read then had nothing to compare against, so it returned nothing and reported end of file.&lt;/p&gt;
&lt;p&gt;Think about what that does. A read-and-delete loop processes its first record, deletes it, and stops. No error. No exception. Nothing in the log. It looks exactly like a loop that ran correctly and found one record to do. You would only ever catch it by counting rows afterwards, and you’d probably assume your filter was wrong.&lt;/p&gt;
&lt;p&gt;A system confidently reporting something that was never true.&lt;/p&gt;
&lt;p&gt;That is the warehouse. That is the thirty million pounds. Same failure, thirty years and one career apart, and this time I wrote it myself.&lt;/p&gt;
&lt;p&gt;I want to be honest about how it was caught, because it wasn’t by running the thing. I couldn’t run SQL Server where I was building this, so I’d written a second implementation of the same logic in another language whose only job was to disagree with the first. It disagreed. That’s the whole technique and I’d recommend it — not tests that confirm what you meant, a second opinion that doesn’t know what you meant, almost like having Peter back in the room questioning my logic.&lt;/p&gt;
&lt;h2 id=&quot;why-this-one-is-different&quot;&gt;Why this one is different&lt;/h2&gt;
&lt;p&gt;I’ve put Doom inside SQL Server. Elite. The Amiga Boing ball. Those work because SQL is the wrong tool, and the wrongness is the joke.&lt;/p&gt;
&lt;p&gt;This isn’t.&lt;/p&gt;
&lt;p&gt;In 1988 IBM shipped a database-centric operating system. Everything is a typed object in a system catalog. The database isn’t a product installed onto the OS — it’s part of it. Programs are objects. Files are objects. Commands are objects with parameter lists, which is how the machine could prompt a command you’d never seen before with F4.&lt;/p&gt;
&lt;p&gt;So modelling an object catalog as tables, or resolving a name against an ordered library list, or driving a keyed access path — none of that is translation into something foreign. It’s the design expressed in roughly the terms it was conceived in.&lt;/p&gt;
&lt;p&gt;Putting an AS/400 inside a database isn’t parody. It’s closer to restoration.&lt;/p&gt;
&lt;h2 id=&quot;the-screen-i-wanted-tosee&quot;&gt;The screen I wanted to see&lt;/h2&gt;
&lt;p&gt;I’m not finished. Logical files next — a second access path over the same data, with select and omit. Then the real one: parsing fixed-format RPG, storing an intermediate representation inside the program object, and generating a stored procedure from it. Which isn’t a shortcut, incidentally — it’s exactly what TIMI does, keeping the translatable template inside the object so the machine can re-translate it for hardware that doesn’t exist yet.&lt;/p&gt;
&lt;p&gt;But the part I actually wanted is done.&lt;/p&gt;
&lt;p&gt;You can type into it. Position to a part, roll through the file, put a 5 against a line and drop into that part’s movement history. The host sends a screen and then sits there knowing absolutely nothing while you type — it only hears from you when you press a key that matters. Thirty years on, that still strikes me as the right way round.&lt;/p&gt;
&lt;p&gt;And I knew which screen I wanted first. It wasn’t a demo.&lt;/p&gt;
&lt;p&gt;An inventory enquiry. Part number, bin location, quantity.&lt;/p&gt;
&lt;p&gt;Every field correct. Every one of them wrong.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_X2HxsdQqya4inaBVvPcB1Q.png&quot; alt=&quot;The second AS/400 Screen.&quot;&gt;
&lt;em&gt;The second AS/400 Screen.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If you enjoyed this story please give it as many Claps as you think worthy.&lt;/p&gt;
</content:encoded><category>SQL Server</category><category>Retro Computing</category><category>Life</category></item><item><title>My Potato Mountain &amp; The 46th Greatest Comedy Film Of All Time</title><link>https://sqlartist.github.io/posts/my-potato-mountain/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/my-potato-mountain/</guid><description>Rebuilding the Wagon Queen Family Truckster jump, one engine at a time.</description><pubDate>Sun, 13 Sep 2026 00:03:58 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_pSNOu8uqKT84meUuyEQ8fQ.png&quot; alt=&quot;My final version of the Truckster, with the whole family aboard.&quot;&gt;
&lt;em&gt;My final version of the Truckster, with the whole family aboard.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;There’s a scene in Close Encounters of the Third Kind where Richard Dreyfuss builds a mountain out of mashed potato because he can’t stop thinking about it. This is my potato mountain. Except mine is a station wagon, and mine is real.&lt;/p&gt;
&lt;p&gt;I came to 3D modelling late. For the last 30 years I’ve worked with SQL databases, written books, won awards and worked on some exciting projects around the world. None of it helped me with the one thing I actually wanted to do: recreate the car jump from National Lampoon’s Vacation.&lt;/p&gt;
&lt;p&gt;Worth saying up front, because it comes back later: I’ve never learnt to drive. Not once, not ever. I’m rebuilding the most famous drive in comedy cinema and I’ve never held a licence.&lt;/p&gt;
&lt;p&gt;I’ve been obsessed with this car for years. I started in the physical world — 3D printing, painting, building the Truckster at every size I could manage. That rabbit hole ended with eight 3D printers in the house and Trucksters ranging from matchbox-sized models to a two-metre-wide diorama.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_fBOeXtk_ZeceRm-DXQVZ8A.png&quot; alt=&quot;The first decent diorama.&quot;&gt;
&lt;em&gt;The first decent diorama.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;from-plastic-topixels&quot;&gt;From plastic to pixels&lt;/h2&gt;
&lt;p&gt;After some success in the physical world I thought, why not build the scene in 3D? Unreal, maybe. Or Unity. Or Blender. It started as an idea for a single 2D render. Then it became an animation. Then a game. Then a full scene. That’s how these things go.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_2VsrAfi5urgjrWYHKUs2-w.png&quot; alt=&quot;Autodesk 3ds Max render.&quot;&gt;
&lt;em&gt;Autodesk 3ds Max render.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_19vRzRIn4Y9u5_M4uVC15g.png&quot; alt=&quot;Another 3ds Max render. I found this tool so hard to learn. The tyFlow module is enormously powerful and I never got on top of it.&quot;&gt;
&lt;em&gt;Another 3ds Max render. I found this tool so hard to learn. The tyFlow module is enormously powerful and I never got on top of it.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;why-im-in-ahurry&quot;&gt;Why I’m in a hurry&lt;/h2&gt;
&lt;p&gt;I have stage 4 colon cancer. I had major surgery, which was initially successful, but the cancer is returning. So I’m finishing what I can while I can.&lt;/p&gt;
&lt;p&gt;The practical effect is smaller and more annoying than you’d think. My memory isn’t what it was. If I read how to do something and don’t apply it I end up learning all over again. Its not that bad but when you have had near ident recall for many years its a bit depressing.&lt;/p&gt;
&lt;p&gt;That one fact has shaped how I’ve built everything since.&lt;/p&gt;
&lt;h2 id=&quot;what-thirty-years-of-sql-actually-gaveme&quot;&gt;What thirty years of SQL actually gave me&lt;/h2&gt;
&lt;p&gt;For a long time I assumed my database career counted for nothing here. Wrong field, wrong brain, wrong everything. I was wrong, and it took me a while to see why.&lt;/p&gt;
&lt;p&gt;I am not as spontaneous as I once was, I can’t afford to hand-place a scene. Click a thousand objects into position, forget how you did it, and the scene is a dead end the first time something breaks. And something always breaks.&lt;/p&gt;
&lt;p&gt;So I stopped placing scenes and started writing them. Python builders that generate the mesa geometry, the procedural materials, the multi-camera setup and the particle dust. In Unreal, a Chaos vehicle pawn that detects the collision with the Road Closed sign and launches the car on proper projectile physics. Camera focal lengths computed rather than eyeballed.&lt;/p&gt;
&lt;p&gt;Underneath, a scene is just rows. Objects, parents, transforms, materials. Name them properly and you can rebuild them. My model is a hierarchy with a body parent and children named the way a schema should be — wheelFL, wheelFR, wheelRL, wheelRR — with Clark, Ellen, Rusty, Audrey and Aunt Edna as separate objects so they don’t get dragged into a vehicle export.&lt;/p&gt;
&lt;p&gt;That isn’t artistry. It’s normalisation. But it means that when I break the scene, I can regenerate it instead of mourning it. Thirty years of databases taught me one transferable thing: never keep the only copy of anything in your head.&lt;/p&gt;
&lt;h2 id=&quot;five-engines-and-a-lot-ofu-turns&quot;&gt;Five engines and a lot of u-turns&lt;/h2&gt;
&lt;p&gt;3ds Max was the first stop, and the first wall. tyFlow can do everything I needed and I couldn’t get my head into it. I’m not a fundamentals-first learner — I have an urgency to finish what I’ve started, so I try every possible angle at once and hope the best one falls out of the end. Feynman’s path integral as a working method. It doesn’t suit a tool that wants to be learned properly, so I moved on.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_ShIbvmVua-ro00P73Mjqbw.png&quot; alt=&quot;An early Blender animation.&quot;&gt;
&lt;em&gt;An early Blender animation.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_vfNTyM2su12vMgguy4FSEA.png&quot; alt=&quot;The same animation just after the car leaves the ramp — and an early version of the car.&quot;&gt;
&lt;em&gt;The same animation just after the car leaves the ramp — and an early version of the car.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Twinmotion was the opposite problem. It was the fastest route to something that looked good, and the weather and sunlight modules are genuinely excellent. But custom vehicle animation was too random. I could get a nice result; I couldn’t get the same result twice. Repeatability matters more to me than speed, so Twinmotion became a place I visit for stills rather than the place I build.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_NEBJaXC2LASRKb9IGfybrw.png&quot; alt=&quot;A Twinmotion render. I tried hard to make this one work.&quot;&gt;
&lt;em&gt;A Twinmotion render. I tried hard to make this one work.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_ssakJ1gD9PD7T7V2R1vEdg.png&quot; alt=&quot;Twinmotion render — it does look nice, though.&quot;&gt;
&lt;em&gt;Twinmotion render — it does look nice, though.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_2onnlNnQh6UGiG5VaB_gYA.png&quot; alt=&quot;Twinmotion again. The weather and sunlight modules are very good.&quot;&gt;
&lt;em&gt;Twinmotion again. The weather and sunlight modules are very good.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;BeamNG.drive was the detour I regret least and enjoyed least. The plan was sensible: use an existing LTD wagon as a physics donor and swap in my visual mesh, so I’d get real soft-body crash damage for free. What I got instead was “Loaded nil parts from 0 jbeam files”, over and over. I eliminated encoding, file paths, conflicting mod zips, flexbody mesh references and directory placement, one at a time, and never got it loading. In the end I drew a line: the crash work happens in Unreal and Blender, and nowhere else.&lt;/p&gt;
&lt;p&gt;There was a Godot version too — a playable one, with the 140-foot gap, the blockade to smash and a repair-and-cash loop. Useful for working out what the jump should feel like, and a dead end for what it should look like.&lt;/p&gt;
&lt;p&gt;Where it’s landed is Blender plus Unreal Engine 5.8. Blender for the rendered scene, Unreal for the drivable car and the cinematic. I’ve been through Unreal 4.26 up to 5.8 to get here.&lt;/p&gt;
&lt;h2 id=&quot;the-wheel-that-turned-itself-insideout&quot;&gt;The wheel that turned itself inside out&lt;/h2&gt;
&lt;p&gt;Every time the model moves between packages I end up in texture and material hell. Every piece of documentation tells you it’s an easy process. Trust me, it isn’t, and I genuinely cannot work out how designers put up with this level of incompatibility — it’s a whole article on its own. Fix one thing and another appears. The best of them was a wheel that inverted itself on import — no error, no warning, just a wheel pointing into its own arch. I never did work out why.&lt;/p&gt;
&lt;p&gt;The current one is more interesting. I have a Blender crash setup working properly — the car drives, hits a rock, rolls, the glass shatters and the metal deforms as it lands on its roof. I have the Truckster animated along its own spline from the same start point, jumping and landing. Transferring the shatter onto the Truckster’s path is the bit that isn’t right yet: the simulation fires far too early, so the glass explodes while the car is still in the air. It needs holding back until touchdown. That’s the sort of problem that sounds trivial and eats a fortnight.&lt;/p&gt;
&lt;p&gt;Camera work and raw render time have been the other two hurdles. Both are solvable with patience, which is the one resource I’m careful with.&lt;/p&gt;
&lt;h2 id=&quot;the-car-itself-and-what-i-got-wrong-aboutit&quot;&gt;The car itself, and what I got wrong about it&lt;/h2&gt;
&lt;p&gt;The Wagon Queen Family Truckster is a fictional station wagon built for the 1983 film, based on a 1979 Ford LTD Country Squire and modified into something deliberately hideous. Eight headlights in two inverted clusters. Wood panelling over most of the available surface. A grille mostly covered by bodywork. A separate oil-cooler grille with no oil cooler behind it. Crown hubcaps. A fuel filler flap in the front passenger wing, which is the joke that keeps giving — in the film Clark rips the rear number plate off looking for it. And an airbag made from a household bin liner.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_KDxA0Qw0SqqaEgVHpQT3eg.png&quot; alt=&quot;Fictional Wagon Queen Family Truckster advertisement — a fan-made parody graphic featuring a replica built by Gary Schneider, using dialogue attributed to John Hughes.&quot;&gt;
&lt;em&gt;Fictional Wagon Queen Family Truckster advertisement — a fan-made parody graphic featuring a replica built by Gary Schneider, using dialogue attributed to John Hughes.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Three things I found while researching it that I hadn’t known, and that are worth knowing if you’re building one yourself.&lt;/p&gt;
&lt;p&gt;First, the colour has a name: Metallic Pea. Ford never sold it. It exists only on this car, which means there’s no swatch and no hex code to work from — only film stills, shot on 1983 stock, in desert sun, then graded.&lt;/p&gt;
&lt;p&gt;What I ended up doing was collecting every high-quality still I could find, lining them up against the physical models I’ve built, and running an eyedropper over all of them. It’s a fool’s errand. The paint is metallic, so it changes with every angle, and every still carries its own shadows and grade — there is no single right answer in any of them. In the end I took a pea green somebody had made for GTA: #47783CAA. That’s RGBA, by the way — #47783C with an alpha of AA — so drop the last two characters if your tool wants six. Every replica builder, physical or digital, is picking their own green and calling it right. Mine is still the thing I fiddle with most.&lt;/p&gt;
&lt;p&gt;Second, George Barris probably didn’t build it. Nearly every source online credits him, including Wikipedia, and I repeated it myself. The replica community says otherwise: Gary Schneider dug into it while building his own car and concluded the Trucksters were modified by Warner Bros’ own transportation department, and that the Barris attribution is an internet myth that got copied until it looked like fact. I’m not going to settle it here. But it’s a useful reminder that a good half of what you find when you research a film car is other people’s guesses, repeated confidently.&lt;/p&gt;
&lt;p&gt;Third, five cars were built, so the crew could rotate them as the damage piled up through the film. I laughed when I read that, because it’s exactly what I’ve ended up doing in software — separate versions of the same model at different stages of destruction. And none of the five survive. They were either destroyed during filming or converted back into ordinary LTD wagons for other Warner Bros productions. Every Truckster you see today is a replica. A good one made $91,000 at Barrett-Jackson in 2019.&lt;/p&gt;
&lt;p&gt;Which is worth sitting with for a moment. Between all those 3D printers, the wasted filament that comes with the territory, the software and the time, I could probably have bought the one that came up at auction and had it shipped to the UK with change to spare. I’m glad I didn’t. I’d have had to take driving lessons, pass a test and insure the thing — and as I said at the top, I’ve never learnt to drive. I’m building the Griswolds’ road trip and I’ve never driven a car.&lt;/p&gt;
&lt;p&gt;One last detail, for anyone who’s read the fan-written brochure that does the rounds — the one promising a “huge, large block” V8 that “drinks the gas like nobody’s business”:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;“Yes, it got it all and safe too, with its large size it can run over and smash through most standard size cars and built like a tank… The Truckster eliminates that with its eight head lights that cuts through the darkness, and your only worry is that oncoming cars are blinded by all that light and might hit you head on.”&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;What was under the bonnet was a standard 130 horsepower 302 with a four-speed automatic. The most over-described car in cinema was, mechanically, a completely ordinary Ford.&lt;/p&gt;
&lt;h2 id=&quot;the-jump&quot;&gt;The jump&lt;/h2&gt;
&lt;p&gt;This is the scene I set out to build. Clark is lost on the way to the Grand Canyon, too busy arguing with Ellen to notice the road is closed, and takes the entire family off the end of it at speed — blowing the tyres, bending the axles and destroying the front end.&lt;/p&gt;
&lt;p&gt;Two things I learned about it changed how I approached mine.&lt;/p&gt;
&lt;p&gt;The stunt coordinator bet the crew he could launch the car more than 50 feet, and won. I’m targeting a 140-foot gap in Unreal, worked out with projectile maths rather than guessed at. Having a real number from the real stunt to argue with turned out to be worth more than any amount of reference footage.&lt;/p&gt;
&lt;p&gt;And the place doesn’t exist. The driving shots were filmed at Baby Rocks on US-160 east of Kayenta, Arizona. The walk through the desert with the skeleton is Great Sand Dunes in Colorado. The hotel is El Tovar at the Grand Canyon. The film cuts several states into one road. A faithful recreation is therefore impossible, and once I accepted that mine is an interpretation rather than a copy, the whole thing got easier.&lt;/p&gt;
&lt;p&gt;Which didn’t stop me trying. I spent months tracking down the real locations, pulling satellite imagery and fighting it into a form I could export as an elevation model for the Unreal and Blender scenes. For the record, the jump itself is at 36°58’02.11”N 110°04’14.82”W — about two miles south of the Utah line, whatever the tour blogs tell you.&lt;/p&gt;
&lt;p&gt;If I ever went back to the USA — which is now unlikely — I’d be Clark Griswold and I’d seek this exact spot out. Given I can’t drive, it would be a very expensive taxi ride.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_W16ZXN1ZGwU6xvEnNFutvg.png&quot; alt=&quot;The spot itself.&quot;&gt;
&lt;em&gt;The spot itself.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_CeC4m2_rHta9psAS9aVZZw.png&quot; alt=&quot;A Blender still. I like the scale on this one — it’s about the level of quality I’m aiming for.&quot;&gt;
&lt;em&gt;A Blender still. I like the scale on this one — it’s about the level of quality I’m aiming for.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;where-it-isnow&quot;&gt;Where it is now&lt;/h2&gt;
&lt;p&gt;Near-working versions in Blender, Unity and Unreal. A car model that finally renders, drives, carries its passengers and survives the trip between Blender and Unreal without falling apart. The target is a rendered scene in Blender and a drivable vehicle with a cinematic render in Unreal 5.8. It isn’t quite there. It’s very close.&lt;/p&gt;
&lt;p&gt;If I started again tomorrow I’d do three things differently: pick the target renderer first and model to it, rather than modelling and then shopping for an engine; impose the naming discipline on day one instead of retrofitting it; and write every scene as a script from the beginning, even when clicking would be quicker. The clicking is always quicker right up until the moment you need to do it twice.&lt;/p&gt;
&lt;h2 id=&quot;here-takeit&quot;&gt;Here, take it&lt;/h2&gt;
&lt;p&gt;There’s no money in any of this. It’s a hobby and a long learning exercise. I’ve always given my work away in the hope it’s useful to somebody, and I’m doing the same here — the Blender builder script, the Unreal level scripts and the model itself. Reducing over 9,416 files and 554 GB on one machine down to a few files on GitHub is its own small act of violence, but that’s the way it goes.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;[GitHub Link to Follow.]&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;There’s a reason I’d like it archived properly. Years ago I was on my way to meet Bill Gates in London. I’d just pulled up at the hotel where he was speaking when my office rang: they needed me in LA, in a meeting with the Head of Warner Bros Studio in Burbank. I never got out of the taxi. I turned round, went home, packed, and flew to Burbank for one of the strangest meetings of my career.&lt;/p&gt;
&lt;p&gt;Going into a huge boardroom with Clint Eastwood and Daffy Duck posters all round was surreal, and then you notice the actual Oscars and Emmys everywhere. For someone from Watford, England, that was something special. Then the head of Warner Bros came in and he looked just like Don Johnson out of Miami Vice. I must have said three words in the whole meeting — I was there as the technical expert, and the meeting wasn’t technical. They did take us out to dinner that evening, which must have been good because I don’t remember a single thing about it.&lt;/p&gt;
&lt;p&gt;So when the scene is finally finished and uploaded, who knows. The 45th anniversary of the film’s release comes round in 2028, and Warner Bros may want something extra for the archive. Stranger things have happened to me in Burbank.&lt;/p&gt;
&lt;p&gt;If you know tyFlow properly, or you’ve ever persuaded a Blender fracture simulation to hold off until the exact frame you wanted, I’d genuinely like to hear from you.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This is my potato mountain. I’d like to finish it.&lt;/strong&gt;&lt;br&gt;
 &lt;br&gt;
 Re — Mi — Do — Do — So&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;If you enjoyed this story, or just love the car or the movie, get in touch, but first, give it some claps. Thank you for reading.&lt;/p&gt;
</content:encoded><category>Life</category></item><item><title>Boing, Boing, Boing</title><link>https://sqlartist.github.io/posts/boing-boing-boing/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/boing-boing-boing/</guid><description>The Day My Database Learned Physics and I recreated the famous Amiga Boing Ball inside SQL Server.</description><pubDate>Mon, 07 Sep 2026 15:17:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_CIBGf4sJ9B7c7T1Liq5Yrw.gif&quot; alt=&quot;This is the Boing ball Running Inside SQL Server&quot;&gt;
&lt;em&gt;This is the Boing ball Running Inside SQL Server&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I’ve spent the last few months putting things inside SQL Server that have no business being there. Doom renders E1M1 from a database. Elite generates its galaxy, flies its ships and docks at a Coriolis station in T-SQL. Daley Thompson’s Decathlon runs on a Z80 emulator I wrote in stored procedures, loading from a real Microdrive image.&lt;/p&gt;
&lt;p&gt;So when I turned to the Amiga Boing ball, I assumed it’d be the easy one. A bouncing chequered sphere. No BSP tree, no galaxy generator, no cycle-accurate anything.&lt;/p&gt;
&lt;p&gt;It was the easy one. Right up until I added a second ball and then I wish I hadn’t started.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;the-history&quot;&gt;The History&lt;/h2&gt;
&lt;p&gt;The Amiga Boing Ball is a mythical object in the computer industry. It was created for a computer show to demonstrate the capabilities of the prototype Amiga (codename ‘Lorraine’). The demo showed a red-and-white spinning ball, bouncing up and down and casting a shadow on a wall behind it while multitasking in the background. The echoing deep ‘boing’ sound and left-right motion was added soon after the show was over.&lt;/p&gt;
&lt;p&gt;According to the legend, the Boing Ball demo was written late one night at the Winter CES show in January 1984 by RJ Mical and Dale Luck. At the time it was an amazing achievement that surpassed all current systems of the time. Because the bouncing ball animation was so fast and smooth, attendees did not believe the Amiga prototype was really doing the rendering. Suspecting a trick, they began looking around the booth for a hidden computer or VCR.&lt;/p&gt;
&lt;p&gt;The 1984 Boing Ball demo was one of the very first demos shown on the Amiga. It was specifically designed to take advantage of the Amiga’s custom graphics, achieving a level of speed and smoothness not previously seen on an affordable computer. The demo was operating in it’s own screen, allowing the higher resolution Amiga Workbench screen to be dragged down to make the Boing Ball visible from behind, bouncing up above the Workbench while the Workbench remained fully active. Since the Boing Ball used almost no CPU time (only to calculate the bounce angles — animation was handled by playfield vertical and horizontal scrolling tricks, the rotation animation was done with colour cycling in the graphics chip, and of course the sound chip handled the sound), this made a particularly impressive demonstration of multitasking at the time.&lt;/p&gt;
&lt;p&gt;If you want to see what it looked like on the Amiga take a look here: &lt;a href=&quot;https://amiga.lychesis.net/applications/AmigaBoingBall.html&quot;&gt;https://amiga.lychesis.net/applications/AmigaBoingBall.html&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;three-ways-to-doit&quot;&gt;Three ways to do it&lt;/h2&gt;
&lt;p&gt;The first decision was which version of “the Boing ball” I was actually building, because there are three, and they’re wildly different jobs.&lt;/p&gt;
&lt;p&gt;The most faithful option is to emulate a 68000 and the Amiga chipset and boot the original demo from its bootblock. Having just written a Z80 core, I knew roughly what that costs, and it’s an order of magnitude more: a much heavier instruction set, plus the Copper and the Blitter, before a single pixel appears. That is a serious commitment and after the ZX Spectrum Hardware project I don’t think I want to go down that route again.&lt;/p&gt;
&lt;p&gt;The most historically accurate option is stranger. The 1984 demo doesn’t render a 3D ball at all. Dale Luck and RJ Mical drew one static checkered sphere and made it appear to spin by cycling the colour registers. The bitmap never changes. Only the palette does.&lt;/p&gt;
&lt;p&gt;I loved that, because it’s already a database idea. Rotation isn’t animation, it’s a lookup against a different row set. They were doing a join in 1984; they just didn’t have anywhere to put it.&lt;/p&gt;
&lt;p&gt;But I picked the third option: render the thing from scratch. Not because it’s more authentic — it’s less — but because it plays to what SQL is actually good at, and I wanted to see how far that went.&lt;/p&gt;
&lt;p&gt;This is the thing about spheres. It’s a closed-form intersection. Under orthographic projection you don’t need a discriminant, you don’t need clipping, you don’t need to rasterise a polygon. You need `d² = dx² + dy²`, and if that’s inside the radius, you’ve hit it. Everything else is a normal, two rotations and a checkerboard.&lt;/p&gt;
&lt;p&gt;That’s pure maths on a grid of pixels. Which is to say: it’s a `SELECT`.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;the-bit-i-was-pleasedwith&quot;&gt;The bit I was pleased with&lt;/h2&gt;
&lt;p&gt;The ball’s motion is also closed form. Position is a function of the frame number — a triangle wave for the horizontal sweep, a parabola for the bounce, and spin proportional to how far it’s traveled, which means the spin reverses at the walls on its own without me writing any logic for it.&lt;/p&gt;
&lt;p&gt;No state. Nothing depends on the previous frame.&lt;/p&gt;
&lt;p&gt;So frames aren’t a loop. Frames are just another dimension of the cross product.&lt;/p&gt;
&lt;p&gt;The entire animation — 64 frames, 320×256, five and a bit million pixels — comes out of one `INSERT … SELECT`. No recursive CTE, no `WHILE`, no cursor, no temp table. A chain of `CROSS APPLY`s you read top to bottom like a shader.&lt;/p&gt;
&lt;p&gt;I sat looking at that for a while. It’s the most SQL-shaped thing I’ve built in this whole series. Doom needed a client and a game loop. Elite needed a flight model with state. This is one query that produces a simple moving ball.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;then-twoballs&quot;&gt;Then: Two balls&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_KIQy3q4EO9OgDTnDnHstRQ.gif&quot; alt=&quot;When I got this working I thought to myself “I have achieved everything I set out to achieve in this world I can finally retire”&quot;&gt;
&lt;em&gt;When I got this working I thought to myself “I have achieved everything I set out to achieve in this world I can finally retire”&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This is where it got interesting, I wanted to take it further and have two balls but colliding. Collision between objects has been the biggest problem I have encountered whilst developing in the 3D world. If you walk through an object it does not have collision. If you bump into an object then you have had to program collision. This may be obvious to some people but I had never heard of it before attempting to develop a scene of my own.&lt;/p&gt;
&lt;p&gt;Adding a second ball is still one query. Add *collision* between them and the whole edifice comes down.&lt;/p&gt;
&lt;p&gt;Not because the physics is hard. It’s relatively easy physics, equal masses, elastic, exchange the normal component of velocity and push them apart if they’ve overlapped. Twenty lines in any language.&lt;/p&gt;
&lt;p&gt;It comes down because collision response depends on the *previous step*. Where ball one is at frame 40 depends on whether it hit ball two at frame 39. Position is no longer a function of the frame number, and the moment that’s true, frames stop being a dimension you can join to and start being a sequence you have to walk.&lt;/p&gt;
&lt;p&gt;One collision. That’s all it took to destroy the property the entire design rested on.&lt;/p&gt;
&lt;p&gt;I found that genuinely annoying given the first part had gone rather well. It is the reason I’m writing this up rather than the bigger projects. Every SQL developer gets told “think in sets, not loops” and nobody ever shows them the “Why”. Well here is the “Why”. Closed form: one statement, five million rows, no loop. Add one dependency on prior state: nothing survives.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;embracing-the-complexity&quot;&gt;Embracing the Complexity&lt;/h2&gt;
&lt;p&gt;My first instinct was to keep everything declarative with a recursive CTE. That’s the trick, and it nearly works. But the recursive member can only reference the CTE once, and pairwise collision needs a self-join.&lt;/p&gt;
&lt;p&gt;So I split the thing along the line where the two halves genuinely differ.&lt;/p&gt;
&lt;p&gt;Simulation is sequential. It’s a `WHILE` loop. It’s also tiny — a handful of rows and a few hundred substeps — so it costs nothing. Four set-based statements per step: gravity and integration, wall reflection, then a pairwise contact resolution written as a self-join with the impulses summed per ball.&lt;/p&gt;
&lt;p&gt;Rendering stayed set-based. It’s still one statement. It just no longer works out where the balls are; it joins to where the simulator says they were.&lt;/p&gt;
&lt;p&gt;That’s the whole architecture. The worse SQL made the better system.&lt;/p&gt;
&lt;h2 id=&quot;three-balls&quot;&gt;Three Balls&lt;/h2&gt;
&lt;p&gt;Because the collision is written pairwise rather than as a special case for two, it takes any number of balls. I added a third by inserting a row. That’s it. One row in a table, and three balls bounce off each other and off the walls with correct depth ordering, because two spheres at the same depth with the same radius resolve trivially — whichever pixel is deeper into its own silhouette is the one in front.&lt;/p&gt;
&lt;p&gt;Getting that for free was the moment the design decision paid for itself.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;so-whats-it-actuallyfor&quot;&gt;So what’s it actually for?&lt;/h2&gt;
&lt;p&gt;As with most of my projects it isn’t a production technique. Nobody should render anything in a database (yet).&lt;/p&gt;
&lt;p&gt;It’s useful for three other things&lt;/p&gt;
&lt;p&gt;It’s the best teaching device for set-based thinking I’ve come across. Not the concept — everyone’s heard the concept — but the *edge* of it. Boing is a perfect mini example. Here’s a closed-form problem, and it’s one beautiful statement. Here’s the same problem with one sequential dependency, and it’s a loop. Nothing else I’ve built shows that transition so cleanly, because in a real system the two are always tangled together.&lt;/p&gt;
&lt;p&gt;It finds engine behaviour that every day work never will. The `CASE` short-circuit trap is going straight into my mental checklist. Pushing an engine into a shape it was never designed for is how you learn where its real edges are, and those edges show up later in queries that matter.&lt;/p&gt;
&lt;p&gt;And it’s a learning challenge in the oldest sense. There’s no spec, no acceptance criteria, and nobody’s asking for it. You just have to work out whether the thing is possible and then find out.&lt;/p&gt;
&lt;p&gt;There’s a wider ambition behind it too. If you can emulate a machine inside a database, you can put the games in as data — cartridge images in `varbinary`, the machine as stored procedures — and you’ve got an archive that runs what it stores. A shelf of 1980s software living inside the same engine that’s serving your reports. I don’t know yet whether that’s a good idea. I know it’s a good problem.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;where-the-limitis&quot;&gt;Where the limit is&lt;/h2&gt;
&lt;p&gt;People keep asking (I say people, but I mean me, literally no one has asked this question) whether the ceiling is Quake or a C64. I think that’s the wrong angle.&lt;/p&gt;
&lt;p&gt;The real question is the ratio of &lt;strong&gt;wide&lt;/strong&gt; work to &lt;strong&gt;deep&lt;/strong&gt; work. Wide work — per pixel, per vertex, per entity — is what SQL is extraordinary at. Deep work, where each step depends on the last, is what it’s terrible at. Everything I’ve built lands somewhere on that spectrum, and where it lands predicts how well it goes far better than what decade the game came from.&lt;/p&gt;
&lt;p&gt;By that measure Quake isn’t the wall people (I) assume. Its renderer is overwhelmingly wide work. Emulating a 68000 with a full custom chipset is almost entirely deep work, and that’s where it dies.&lt;/p&gt;
&lt;p&gt;Boing is the extreme wide case, which is why it came out as one query. And the second I introduced a single dependency on prior state, it stopped being one.&lt;/p&gt;
&lt;p&gt;Two balls taught me more than Doom did but I do think they are both pretty cool.&lt;/p&gt;
&lt;p&gt;Code is avaialbe on Github&lt;br&gt;
&lt;a href=&quot;https://github.com/sqlartist/BoingBallSQL&quot;&gt;https://github.com/sqlartist/BoingBallSQL&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you enjoyed reading this story, give it a few Claps, it helps boost someones pockets — not mine these are all given away for free. In fact I don’t think anyone benefits from a Free story, in fact its costing us money. You owe us…&lt;/p&gt;
</content:encoded><category>SQL Server</category><category>Retro Computing</category></item><item><title>Patient Number 1 in DARPA’s Super Soldier Programme</title><link>https://sqlartist.github.io/posts/the-six-billion-dollar-man/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/the-six-billion-dollar-man/</guid><description>or rather because of National Health Service (NHS) in the UK, I could be called “The Cost of a Few Prescriptions Man” but it’s not quite as pithy.</description><pubDate>Sat, 05 Sep 2026 22:29:19 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_569bjZcokFrQOhr8nR-4jA.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;WARNING: There are some images in this article which some people may find disturbing. They are all real and you really can’t see anything and because I don’t know Markup very well, I can’t hide them.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This article is a combination of events that have happened to me that are quite unusual and people start to wonder what on earth is he talking about. I can promise this is all true.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Weirdly I was interviewed by the team that were creating a show in the UK based in some castle in Scotland called “The Traitors” and one of the tests was to fool them by telling them 4 truths and a lie on a live video stream.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Slightly off topic but what would you think?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Four Truths and a Lie&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;1. I once had breakfast with the entire Liverpool Football Team.&lt;br&gt;
2. I was in the Wonder Women movie (The first one)&lt;br&gt;
3. I once got mistaken for Tom Hardy&lt;br&gt;
4. I am the 15th descendant of King Henry VIII&lt;br&gt;
5. I worked on a project which directly affected the outcome of the USA Presidential Election&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Answer at the end of the article…&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Forgive the slight silliness of this piece but it’s all horrific for me and my family, so when I do look back so I try to think of it in a positive light.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pre-Story Poll&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Before you read the story below, log your initial instinct. Your vote will be tallied against our global community data at the conclusion of the file.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_BImRw5bGVCZdkec-qayUjQ.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Due to my Chronic Cluster Headaches mentioned in the story “The Cloud Has No Mercy” &lt;a href=&quot;https://sqlartist.github.io/posts/the-cloud-has-no-mercy/&quot;&gt;The Cloud Has No Mercy&lt;/a&gt;, I was told after many years of devastating pain that I would require an operation and a device called a Deep Brain Stimulator installed as they had tried everything else open to them.&lt;/p&gt;
&lt;p&gt;Deep Brain Stimulation (DBS) is an advanced, invasive surgical option reserved for patients with chronic cluster headaches who are entirely refractory (unresponsive) to standard medical therapies.&lt;/p&gt;
&lt;p&gt;How the Procedure Works&lt;/p&gt;
&lt;p&gt;Target Areas: Surgeons implant permanent electrodes into specific deep brain structures, most commonly the posterior hypothalamus or the ventral tegmental area (VTA), which mediate pain and are involved in the Neurobiology of cluster attacks.&lt;/p&gt;
&lt;p&gt;The Device: Small holes are drilled into the skull to guide the electrodes into position. Wires connect these electrodes to a battery-powered pulse generator placed under the skin in the chest, like a heart pacemaker, which delivers regulated electrical impulses.&lt;/p&gt;
&lt;p&gt;Now this is a big one, First I was awake for 14 of the 16 hours operation, which allowed the Neurosurgeons’ to monitor if they had placed the electrodes in the correct place, if I started speaking Spanish, they would know they were not positioned correctly. But going back a bit, the day started out with a huge cage being attach to my head via screw holes they had made the night before. This is so they absolutely cannot be any movement during the insertion of the electrode(s), and yes there is redundancy built it. All good.&lt;/p&gt;
&lt;p&gt;Went into the surgery, there were at least 10 people in the operating theatre and many other watching in the gallery. All good.&lt;/p&gt;
&lt;p&gt;I had asked the nurse if someone could let me see the X-Ray afterwards, they said don’t worry about that, give that nurse your phone and we will get you pictures! Now First off, I have never heard that a patient has been allowed to take what is possible a source of bacteria and germs into an operating theatre with them, let alone have pictures taken of themselves. But they did and it’s remarkable to see.&lt;/p&gt;
&lt;p&gt;What happened next will hopefully show how bad these cluster headaches were, in the fact for the entire operation I am smiling, like I cannot wait for the pain to be over. This is Level 10 pain, 12 hours a day for 13 years — Its thought to be the world’s most painful medical condition or the equivalent to giving birth 12 times a day.&lt;/p&gt;
&lt;p&gt;They numb the top of my head with Lidocaine and get the hand drill out, yes just like the hand drill your Granddad would have used, except cleaner. They then slowly drill into my brain case until they just get through the bone. Now if you have ever drilled something and the final part is always where the drill goes slightly through until you realise and you pull out quickly, well this happened, because I could feel this is what happened.&lt;/p&gt;
&lt;p&gt;Now there was no pain because the Lidocaine had numbed the skin, and of course there are no nerves in the brain. So that scene in the Hannibal Lecter film where he cooks little bits of the characters brain whilst he is still alive is completely possible.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_DZvqYwVmtUrEdAfRPVsltQ.jpeg&quot; alt=&quot;I trusted the Science…&quot;&gt;
&lt;em&gt;I trusted the Science…&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;They then have a little discussion and tell me to brace myself. Well, I cannot move anyway so was a bit unsure what was going to happen next. I thought they would gently weave the electrodes they were implanting around the bits of my brain eventually reaching the centre and the Hypothalamus (Walnut sized mass in the centre of the brain, it controls the Body clock and Pain). Oh no, they were going to shoot it straight through the brain a reach the mass with millimetre precision.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_OMHsBqgRJ8r-Lalc8_lvZQ.jpeg&quot; alt=&quot;These are the images that you can’t see anything.&quot;&gt;
&lt;em&gt;These are the images that you can’t see anything.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Long story short, it went well, I answered all the questions asked of me (to check they had not disturbed any part of the brain that controlled anything important) having in their words “just destroyed millions of brain cells, but don’t worry you have plenty more”.&lt;/p&gt;
&lt;p&gt;To wrap this up, I was let out of hospital the day after. Major brain surgery and was in hospital 3 days.&lt;/p&gt;
&lt;p&gt;All this pain and surgery just because someone picked me up as a kid by my neck and swung me around until two bones snapped. Over the years the bone grows slightly abnormally and therefore Chronic pain.&lt;/p&gt;
&lt;p&gt;Still, every cloud, what happened next would not have happened if it weren’t for the Deep Brain Stimulator.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_FAdKjD_T8sN5aqJ65_XWGQ.jpeg&quot; alt=&quot;Two set of Electrodes for Redundancy&quot;&gt;
&lt;em&gt;Two set of Electrodes for Redundancy&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;the-study-fordarpa&quot;&gt;The Study for DARPA&lt;/h2&gt;
&lt;p&gt;I was contacted through my Neurologist if I would be part of a study for the University of [Redacted] which was funded by DARPA, the USA’s Defence Advanced Research Projects Agency. They were looking for people with my exact Deep Brain Simulator to do some testing on.&lt;/p&gt;
&lt;p&gt;I don’t really know why I said yes, but I did have some tough questions for them before I committed to anything.&lt;/p&gt;
&lt;p&gt;I asked — is it a paid study? They said no it wasn’t paid but they would cover expenses. So, I said OK. &lt;em&gt;(I would not do well in an interrogation )&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_QfEeF5eVbnGuIxxoSFIT2A.jpeg&quot; alt=&quot;Arrival Day at some University in Southern England&quot;&gt;
&lt;em&gt;Arrival Day at some University in Southern England&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Then came the day, I arrived as you can see and they booked me in as Patient Number 001. I said is this meant to be anonymous? And they said yes which is why we have used Patient Number 001. I said how many others in the program. They said just me, they couldn’t find anyone else up to that point who qualified, and they might not even get their PhD because of that reason.&lt;/p&gt;
&lt;p&gt;Then they told me what the study was meant to be for. Its part of a “Super Soldier” program where they were investigating what having one of these implants could do to a human if the settings were altered.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;W.T.A.F. !&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;They would monitor me closely over the course of two nights when I was sleeping and then awake and one of those nights, they would alter the brain implant signal and use settings not allowed via my patient programmer and not even accessible to the doctor programmer device. They would administer a series of tests during the night and when I woke up.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_7XXXpTGfTWmCZ2aZ0FmeSQ.jpeg&quot; alt=&quot;As hard as I tried I still couldn’t get Radio 1&quot;&gt;
&lt;em&gt;As hard as I tried I still couldn’t get Radio 1&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_izE2jM5J6H8MfbdFa_iQXw.jpeg&quot; alt=&quot;All ready for the first night…&quot;&gt;
&lt;em&gt;All ready for the first night…&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So, this was what I looked like each evening before I fell asleep (With 20 PhD students all watching me through one way glass) Also the kept interrupting me because the electrodes kept falling off during the night.&lt;br&gt;
 &lt;br&gt;
 Night one went OK and when I woke up I got through the testing ok, it was very boring and a bit simple I thought, I was pretty annoyed because I had planned to go and do some tennis serve practice on the courts which were 50 metres away. I could see them from my hospital room. They said I couldn’t leave, I said I was leaving, they got the big boss in, who by this time was annoyed himself as it was a Saturday and he was at home. I said I was leaving the study if I couldn’t go outside, what was the harm.&lt;/p&gt;
&lt;p&gt;So, I got to hit about 10 serves and the rain just poured down so I didn’t quite maximise the “prison break” and went back for the second night. I woke up the next day, full of happiness and joy and pleased basically because I was going home. I ran through the tests without even blinking, hard IQ type tests just answering, list 10 things we spoke about yesterday, now tell me them backwards. I would just tell them ten, backwards, forwards anyway they wanted just to get out of there.&lt;br&gt;
 Finally I was allowed to go home.&lt;/p&gt;
&lt;p&gt;Then it struck me, it was the second night, the one where they turned it onto different settings — the “Super Soldier” settings where I had ace’d through the tests like they weren’t even there and was generally invincible, or were the settings changed on the first night where the next day I was as p-ssed as any human could be and struggled with the tests? Did they change it both days? Did they leave me with the bad one or the good one? Even today life feels a bit like the Manchurian Candidate or Pelican Brief.&lt;/p&gt;
&lt;p&gt;I guess I will never know…&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;The Cyber-Vulnerability Fact&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In a terrifying twist of real-world history, the major medical manufacturers responsible for building these advanced thoracic IPG units (who also dominate the global heart pacemaker market) notoriously left glaring security holes in their systems and devices. For years, implantable devices and transmitters faced massive FDA cyber-security roll-outs because firmware lacked basic encryption. Historically, hard-coded master technician keys and default factory settings — colloquially mocked by white-hat hackers as equivalent to leaving the device password as &lt;strong&gt;“Password123”&lt;/strong&gt; — left hundreds of thousands of hearts and neurological pacemakers vulnerable to remote signal interception.&lt;/p&gt;
&lt;p&gt;Which is nice…&lt;/p&gt;
&lt;p&gt;Even when I had lunch with Tim Berners-Lee all we spoke about was getting the data off and seeing what it was doing — he was speaking on the Semantic Web 3.0 that day and unveiling a ¾ bronze statue of himself and all we spoke about was my brain.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Is it weird?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Er, yes, it’s very weird, when I turn it on I go cross-eyed the wrong way and I can take down a WiFi network in the 5 GHz range by walking into a room, other than that it reduces the pain from a 10 to a 2, and that’s all I care about. Yes, there are side effects and charging yourself up is always a bit strange, especially when people ask where do I plug myself in?&lt;br&gt;
 &lt;br&gt;
 But who cares what I look like, or if I have to suffer the embarrassment of wearing the harness they first gave me, which to be honest looked like I was going for a night out in London’s famous Torture Gardens Fetish club. But I do have a new harness now which is far better as they have upgraded the charging device itself to be a super-charger. Its still working, it’s meant to last approx. 2–3 years and mine has been going for 7 so far.&lt;/p&gt;
&lt;p&gt;It will have to be soon as it’s starting to lose its charge, trouble is I doubt they will replace it whilst I have cancer so wish me luck….&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Four Truths and a Lie&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;1. I once had breakfast with the entire Liverpool Football Team. **TRUE&lt;br&gt;
**&lt;em&gt;I did have breakfast with the Liverpool football team when I was 10 years old.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;2. I was in the Wonder Women movie (The first one) **FALSE&lt;br&gt;
**&lt;em&gt;I didn’t appear in the Wonder Women movie, but my friend Eugene Brave Rock did. He stayed with me when he was filming it.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_nvJYjRI0ZPWsYv8IVH3Rzw.jpeg&quot; alt=&quot;Gene Brave Rock &amp;amp; Gal Gadot (Filmed in Leavesden)&quot;&gt;
&lt;em&gt;Gene Brave Rock &amp;amp; Gal Gadot (Filmed in Leavesden)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;3. I once got mistaken for Tom Hardy **TRUE&lt;br&gt;
**&lt;em&gt;I did get mistaken for Tom Hardy and I have been loving this ever since.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;4. I am the 15th descendant of King Henry VIII &lt;strong&gt;TRUE&lt;/strong&gt;&lt;em&gt;At the time I did believe I was the 15th descendant to King Henry VIII but since found out that it was a mistake and actually my DNA is closely related to Beethoven and Oscar Schindler.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;5. I worked on a project which directly affected the outcome of the USA Presidential Election &lt;strong&gt;TRUE&lt;/strong&gt;&lt;em&gt;I worked on the Voter Registration system in Tallahassee, Florida in the District Attorney’s Office where Jed Bush had an office next door to ours. I was sent out to fix* the database. This is the election where George Bush became president over Al Gore.&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;When I say fix I mean “make it better”, not “alter the outcome”, that had already happened 😉&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;Hope you enjoyed this story, hit the clap button as hard and as fast as humanly possibly if you did.&lt;/p&gt;
</content:encoded><category>Life</category><category>Health</category></item><item><title>Running Elite in SQL Server</title><link>https://sqlartist.github.io/posts/elite-in-sql-server/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/elite-in-sql-server/</guid><description>“An infinite void wrapped around a core of data entry.”</description><pubDate>Fri, 04 Sep 2026 10:53:51 GMT</pubDate><content:encoded>&lt;p&gt;Doom-in-SQL is dominated by the rasteriser. 320x200 is 64,000 pixels a frame, and every one of them needs a texture lookup, a light level and a depth test. SQL Server is a set-based engine bolted to a storage layer. Asking it to fill spans pixel by pixel is asking it to do the one thing it’s worst at.&lt;/p&gt;
&lt;p&gt;Elite’s frame is a few hundred line segments. Twelve ships, twenty-odd vertices each, thirty-odd edges. Transform, cull, project, clip. That’s not a rasterisation problem, it’s a join.&lt;/p&gt;
&lt;p&gt;And it goes further than the renderer. Ship blueprints are vertex, edge and face tables with normals and bounty as columns. Face culling is a dot product in a WHERE clause. The galaxy is generated from three 16-bit numbers. The market is seventeen commodities with a base price and a gradient. Elite is a relational database that someone spent forty years pretending was an action game.&lt;/p&gt;
&lt;p&gt;Once it’s in tables you can do something no Elite player has ever been able to do. You can query it.&lt;/p&gt;
&lt;p&gt;**A quick note on licensing before anyone asks.&lt;br&gt;
**Doom is easy to port because id GPL’d the engine in 1997. Elite was never shareware and is still copyright Ian Bell and David Braben. What exists is Bell’s own sources on his site and Mark Moxon’s extraordinary annotated disassemblies of the BBC Micro, Master, Electron and NES versions. Moxon publishes those deliberately without a licence. For a personal experiment nobody minds; I’m crediting everyone loudly and I’m not shipping a playable binary of someone else’s game.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Getting the ships out&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I didn’t want to type in vertex coordinates from memory or from a fan wiki. I wrote a parser that walks Moxon’s annotated assembly directly, pulling the `VERTEX`, `EDGE` and `FACE` macro calls and the `XX21` lookup tables.&lt;/p&gt;
&lt;p&gt;The disc version scatters its roster across sixteen per-galaxy source files, so the parser merges and dedupes them. Out the other end: **31 blueprints, 474 vertices, 709 edges, 306 faces**, with the original 8-bit coordinates, face normals and per-edge visibility values intact.&lt;/p&gt;
&lt;p&gt;Two blueprints threw an exception at the parser and turned out to be genuine 1984 engineering rather than a bug. The Thargon has no edge list of its own — it borrows the cargo canister’s. The splinter borrows the escape pod’s. Somebody was 24 bytes over budget and went looking for a ship with the same number of vertices.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_DGA_bZs2t-4n4748IlVFwQ.png&quot; alt=&quot;The full ship roster, rendered from the extracted blueprint data&quot;&gt;
&lt;em&gt;The full ship roster, rendered from the extracted blueprint data&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;*Every blueprint, straight out of the parser. Coriolis with its docking slot, the Dodo, the Thargoid, and a cargo canister that is quietly doing double duty.*&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;The renderer is one view&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The whole thing is a single view. Six CTEs, no cursor, no loop:&lt;/p&gt;
&lt;p&gt;The Liang-Barsky is the bit I’m quietly pleased with. It unrolls into four rows per segment through a `VALUES` constructor and aggregates them, so a line clip becomes a `MAX` and a `MIN`. A parallel line that starts outside its boundary gets t0 = 2, which forces t0 &amp;gt; t1 and rejects it without a special case.&lt;/p&gt;
&lt;p&gt;Elite pins the player at the origin looking down +z and moves the universe instead. So `elite.Universe` coordinates are already camera space, and rotating a blueprint vertex into view is one expression:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;p_cam = x * sidev + y * roofv + z * nosev + shipPosition&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Backface culling needs a point on each face, but the blueprints only store the vertex-to-face direction. I invert that mapping once at load into `elite.ShipFaceVertex` rather than doing it every frame.&lt;/p&gt;
&lt;p&gt;Before running any of it against SQL Server I wrote the same pipeline in Python, stage for stage, and rendered a turntable. That turned out to be the single best decision in the project.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_ZWu0h9RdZDtKgR0JAx6RYg.png&quot; alt=&quot;Cobra Mk III turntable, verifying backface culling&quot;&gt;
&lt;em&gt;Cobra Mk III turntable, verifying backface culling&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;*The Cobra through 360 degrees. Edge count swings from 34 nose-away to 17 nose-on, and the engine exhausts on the rear face appear and vanish exactly when they should. A flat edge count would have meant broken culling.*&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Then I spent six files chasing a performance ghost&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This is the part I’d tell you about in the pub and bore you to tears.&lt;/p&gt;
&lt;p&gt;First benchmark: 12 ships, 53ms a frame, 18.7fps. Twenty-seven times faster than Doom, so job done? No. A few hundred rows in 53ms is about 130 microseconds per row. That’s nonsense for float arithmetic in SQL Server. Something was wrong.&lt;/p&gt;
&lt;p&gt;What followed was five wrong theories in a row.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Theory 1: fixed overhead.&lt;/strong&gt; The CTEs get re-evaluated because SQL Server inlines rather than spools them, and `elite.Setting` was CROSS JOINed four separate times, so every supposed constant was really a column reference. Plausible. I ran a scale ladder from 1 to 48 ships. It was linear. Wrong.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Theory 2: recompilation.&lt;/strong&gt; Temp tables inside a procedure carry statistics, and changing row counts between calls crosses a recompile threshold. Very plausible, classic problem. I captured the recompile counter and built a table-variable control version. Counter read zero. Table variables performed identically. Wrong.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Theory 3: parallelism.&lt;/strong&gt; A parallel plan on 700 rows is pure exchange overhead. I forced MAXDOP 1. No change. Wrong.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Theory 4: memory grants.&lt;/strong&gt; Capped the grant. No change. Wrong. (Worse than wrong — I capped the grant on the wrong statement, and made things marginally harder for myself.)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Theory 5: tempdb.&lt;/strong&gt; I pre-sized it. The wait stats came back with 4ms of I/O across an entire run. Wrong, and it saved me a service restart.&lt;/p&gt;
&lt;p&gt;Along the way I broke my own benchmark twice. My first harness reported 24 ships costing more than 48, which is impossible, and I’d been tuning against those numbers for two files. My CPU measurement read `sys.dm_exec_sessions.cpu_time`, which only updates when a request completes — so inside a long batch it reads zero forever. Both had to be fixed before any of the rest meant anything.&lt;/p&gt;
&lt;p&gt;What finally cracked it was stage timing. Instrument each statement in the pipeline separately and report medians rather than means:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;markdown&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Ships | Lines out | Stage 4    |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;|-------|-----------|------------|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| 12    | 89        | 6.0ms      |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| 24    | 257       | 44.1ms     |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| 48    | 561       | 120.5ms    |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| 96    | &lt;/span&gt;&lt;span style=&quot;color:#ADBAC7;font-weight:bold&quot;&gt;**1,130**&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; | &lt;/span&gt;&lt;span style=&quot;color:#ADBAC7;font-weight:bold&quot;&gt;**11.5ms**&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;96 ships is ten times faster than 48 while producing twice the output. That’s not a scaling problem, it’s plan instability. And the 48-ship case was burning only 13.4% CPU — it wasn’t computing, it was waiting.&lt;/p&gt;
&lt;p&gt;The session wait stats said `SLEEP_TASK` with essentially no I/O. And the query stats, once I got the database context right (`OBJECT_ID` returns NULL if you’re pointed at the wrong database, and then your filter silently matches nothing), named it exactly:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F69D50&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt; #edge … AvgMs 118.15 AvgCpuMs 9.75 GrantKB 2656 UsedKB 1632 Spills 96&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;96 spills.&lt;/strong&gt; A hash build sized off a bad estimate, repeatedly running out of workspace and re-partitioning. 108ms of the frame was spill handling. Every other statement in the pipeline was clean.&lt;/p&gt;
&lt;p&gt;And the punchline: the statement it was happening in was one &lt;em&gt;I had created&lt;/em&gt;, in file 9, while trying to optimise the thing. Six files of performance work, and the bug was introduced in the middle of them.&lt;/p&gt;
&lt;p&gt;The fix is a `LOOP JOIN` hint. At a few hundred rows, nested loops against the clustered keys is correct and a loop join has no workspace to spill. Normally I’d argue against hinting join types, but this pipeline has a fixed shape and a hard ceiling of a couple of thousand rows. There’s no scene where hashing wins.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Final numbers for a real Elite frame — twelve ships, which is all the original ever put on screen:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_DH7eLx5f0inZWshhKEmcwA.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Four hundred times faster. Not because I’m cleverer than I was last time— because vector graphics are a join and rasterisation isn’t.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;The galaxy is three numbers&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This is the part that made the whole project worth doing.&lt;/p&gt;
&lt;p&gt;Elite’s 2,048 systems are not stored anywhere. They’re generated by twisting three 16-bit seeds. The twist is four lines of 6502:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;ini&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;s2_new&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; = s0 + s1 + s2 (mod 65536), then shift the seeds down&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Four twists move you to the next system. And the four intermediate seeds are also what generate that system’s name, two letters at a time from a 64-character table. So the whole galaxy is one recursive CTE stepping the twist 1,024 times per galaxy, and then a decode that takes every fourth step as a system and the steps between as its name.&lt;/p&gt;
&lt;p&gt;Economy, government, tech level, population, productivity, radius and position all fall out of bit manipulation on the seed. Government is bits 3 to 5 of one word. Tech level is the flipped economy plus two bits plus half the government, rounded up.&lt;/p&gt;
&lt;p&gt;I checked every constant against the disassembly rather than trusting my memory, which caught two things I’d have got subtly wrong. Tech level uses `LSR` then `ADC`, so it rounds *up* for odd governments. And a name token of zero prints nothing at all rather than producing a character, which is how three-token and four-token names coexist in the same routine.&lt;/p&gt;
&lt;p&gt;The validation is unambiguous:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;yaml&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#8DDB8C&quot;&gt;Check_FirstSystem&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;Tibedied (expected Tibedied)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#8DDB8C&quot;&gt;Check_DistinctNames&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;256 (expected 256)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;Lave&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt; #7 (20,173) TL 5 Rich Agricultural Dictatorship&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; population 2.5bn productivity 7000 radius 4116km&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And the neighbour list, which is the real proof:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;lua&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Destination | Light years |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-------------|-------------|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Diso        | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3.6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;         |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Leesti      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3.8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;         |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Reorte      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4.4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;         |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Zaonce      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5.7&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;         |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Orerve      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6.8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;         |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Riedquat    | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;7.0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;         |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That’s exactly the six systems reachable from &lt;strong&gt;Lave&lt;/strong&gt; on a full tank, in the right order, with &lt;strong&gt;Riedquat&lt;/strong&gt; sitting on the absolute edge of range. Anyone who played this in 1984 knows that list by heart. It came out of three numbers and a recursive CTE.&lt;/p&gt;
&lt;p&gt;Then I ran a query nobody could have run in 1984:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;lua&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Government       | Systems | Avg tech level |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;------------------|---------|----------------|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Anarchy          | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5.0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Feudal           | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5.8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Multi&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Government | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;7.7&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Dictatorship     | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;7.7&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Communist        | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8.2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Confederacy      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8.9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Democracy        | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8.3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;| Corporate State  | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;      | &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10.2&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Exactly 32 of each.&lt;/strong&gt; Not approximately — precisely, because government is three bits and the twist distributes them perfectly over 256 systems. And average tech level climbs monotonically with government type, because the tech formula literally adds half the government value.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bell&lt;/strong&gt; and &lt;strong&gt;Braben&lt;/strong&gt; encoded the political economy of eight galaxies into three bits and an addition. You can only see that if you can aggregate the thing, which is why it took forty years and a `GROUP BY`.&lt;/p&gt;
&lt;p&gt;Trade route optimisation, incidentally, is now a query. Join Lave’s market to every market within 7 light years, match on commodity, order by profit. Forty years of graph paper and folklore, answered by a SELECT.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Flying it&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The flight model was the most fun and the most humbling.&lt;/p&gt;
&lt;p&gt;Elite ships have no yaw. Like the player, they can only roll and pitch. That’s why an Elite pirate lining up on you rolls you into its vertical plane first and *then* pitches onto you. It’s not stylistic, it’s a consequence of the control axes.&lt;/p&gt;
&lt;p&gt;The AI for every ship in the bubble is a &lt;strong&gt;single UPDATE&lt;/strong&gt;. Direction to target, projection onto each ship’s local axes, steering decision, throttle — one statement for the whole scene. The original loops over ship slots one at a time because a 6502 has no alternative. This is the one place where the SQL port is genuinely more natural than the thing it’s porting.&lt;/p&gt;
&lt;p&gt;Then I wrote three sign-convention bugs in a row.&lt;/p&gt;
&lt;p&gt;The first inverted pitch in the demo pilot, so my ship flew determinedly away from every target. The second was a naive proportional controller that stalls: roll changes x in proportion to y, so once a target is level with you there’s nothing to roll against. The third was in docking, where I controlled the &lt;strong&gt;cosine&lt;/strong&gt; of the slot angle instead of the angle — and the sign of the cosine tells you nothing about which way to roll.&lt;/p&gt;
&lt;p&gt;All three had the same shape. Maths that converges on something, just not on what I intended. Invisible from the outcome, obvious the instant you simulate the loop and look at the quantity being controlled.&lt;/p&gt;
&lt;p&gt;The fix for all three is `atan2`, which encodes the two-stage manoeuvre directly:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;roll = -k * atan2(X, Y) bring the target to twelve o&apos;clock&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;pitch = -k * atan2(Y, Z) then pull it down onto the nose&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Locks on from any starting position in 41 to 76 ticks. Frames stay orthonormal to 5.5e-17 over 400 ticks — worth noting that Elite’s famous `TIDY` routine exists because of 8-bit fixed point, and in a float port it’s almost unnecessary. I kept it. It’s cheap.&lt;/p&gt;
&lt;p&gt;First proper dogfight after adding throttle management: **47 ticks, two pirates destroyed, eleven shots fired, zero hits taken.** You have to slow down to turn inside someone, because rotation rates in Elite don’t scale with speed — velocity only widens your turn circle. The AI knew that. My demo pilot didn’t, and spent 330 ticks overshooting.&lt;/p&gt;
&lt;p&gt;Docking is four independent conditions: on the slot axis, within the opening rather than the hull beside it, rolled to match a slot that never stops turning, and slow enough that arrival is a docking rather than an impact.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Making the failures explain themselves&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The single most useful habit in this project had nothing to do with SQL.&lt;/p&gt;
&lt;p&gt;Early on I’d get an empty frame and have no idea why. A ship can be missing for four completely different reasons and a geometry view can’t tell you which. So I wrote a diagnostic view with a `Verdict` column:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;behind you&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;too far, all detail culled&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;off the edge of the screen&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;ON SCREEN&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Same for docking. When my first attempt crashed, the output read:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;AxisDot 1.000 LateralOff 0 SpeedOK 1 RollMatch 0.042&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;CRASH: not rolled to match the slot&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Textbook approach, dead centre, correct speed, rolled ninety degrees wrong. That’s a five-second diagnosis instead of an evening.&lt;/p&gt;
&lt;p&gt;Every time I skipped this step I lost hours. Every time I did it I lost minutes.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;The cockpit&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The client is Python and tkinter — standard library, no display dependencies at all. All the game logic stays in the database; the client is a screen and a keyboard.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_bQ6w86u5_pWSiW2B1sUvzw.png&quot; alt=&quot;The Elite cockpit, rendered from SQL Server&quot;&gt;
&lt;em&gt;The Elite cockpit, rendered from SQL Server&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Vector view, instrument bars, and Elite’s ellipse scanner with the vertical stalks. The scanner is just a different projection of the same `elite.Universe` rows the 3D view uses.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The one thing that makes it viable at 30fps is a single stored procedure returning three result sets — the vector frame, the instruments, and the scanner contacts. A naive client would issue a tick, then a frame query, then a status query. Three round trips a frame, ninety a second, for no reason.&lt;/p&gt;
&lt;p&gt;First time I actually flew it, I died instantly whatever I pressed. Two compounding causes, both mine. The client asks for a frame every 33ms, so the game runs at 30 ticks a second where the BBC managed about 12 — everything “per tick” happens two and a half times too fast. And I’d scaled NPC laser damage 6x earlier to make the *autopilot’s* fights resolve quickly. Together: 255 shields plus 255 energy at 12 damage a tick is 42 ticks. About 1.4 seconds.&lt;/p&gt;
&lt;p&gt;Combat constants now live in a table so they can be tuned while the game is running. It turns out “the numbers I picked to make a script’s fights interesting” and “the numbers a human can survive” are not the same numbers.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Where it got to&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;- 31 ship blueprints, parsed from annotated 6502 source&lt;br&gt;
- A renderer that does a real Elite frame in &lt;strong&gt;3.51ms&lt;/strong&gt;&lt;br&gt;
- 8 galaxies, 2,048 systems, from three 16-bit numbers&lt;br&gt;
- Flight model, set-based ship AI, combat, and docking against a rotating station&lt;br&gt;
- Trading, cargo, fuel and hyperspace&lt;br&gt;
- A Python cockpit&lt;/p&gt;
&lt;p&gt;Dock, trade, refuel, jump, repeat. The loop closes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What I’d tell you if you’re thinking of doing something like this&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Write the reference implementation first.&lt;/strong&gt; Every geometry bug in this project was caught in seconds by a Python model of the same pipeline, and every one I tried to reason about instead cost me an evening.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Make failures name themselves.&lt;/strong&gt; A boolean that says “no” is worthless. A column that says *which condition failed* is the difference between minutes and hours.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Don’t trust a benchmark you haven’t broken yet.&lt;/strong&gt; Mine reported impossible results twice. Report medians, not means. Run the same case twice and see if it agrees with itself. Check that your CPU measurement actually measures CPU.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Check the constants against the source.&lt;/strong&gt; Every value in the galaxy generator came from &lt;strong&gt;Moxon’s&lt;/strong&gt; disassembly rather than my memory, and two of them would have been subtly wrong if I’d trusted myself.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;And pick the right problem for the tool.&lt;/strong&gt; The reason this runs 400 times faster than my Doom port isn’t cleverness. It’s that vector graphics are a join and rasterisation isn’t. SQL Server was never bad at Doom’s maths. It was bad at Doom’s &lt;em&gt;shape&lt;/em&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Credits&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Elite is copyright &lt;strong&gt;Ian Bell&lt;/strong&gt; and &lt;strong&gt;David Braben&lt;/strong&gt;. It’s one of the great pieces of software engineering and it deserved better than being ported to a database.&lt;/p&gt;
&lt;p&gt;Every constant, blueprint and algorithm here was read out of &lt;strong&gt;Mark Moxon’s&lt;/strong&gt; annotated disassemblies at [bbcelite.com](&lt;a href=&quot;https://www.bbcelite.com&quot;&gt;https://www.bbcelite.com&lt;/a&gt;) — a genuinely remarkable act of software archaeology, and the reason this project took weeks rather than years.&lt;/p&gt;
&lt;p&gt;The ship blueprint data is extracted from those sources for a personal experiment. Don’t redistribute it, and go and read &lt;strong&gt;Moxon’s&lt;/strong&gt; commentary instead. It’s better than this article.&lt;/p&gt;
&lt;p&gt;Code is here and just run in the order of the files.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/sqlartist/EliteSQL&quot;&gt;https://github.com/sqlartist/EliteSQL&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I can’t imagine there will be too many people reading this that will even know what Elite is or was and what an impact it made on the history of Computer Games but if you do then please give it a clap. Thank you.&lt;/p&gt;
</content:encoded><category>SQL Server</category><category>Retro Computing</category></item><item><title>Sum Over Every Path</title><link>https://sqlartist.github.io/posts/sum-over-every-path/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/sum-over-every-path/</guid><description>A spelling corrector in pure T-SQL, and what Feynman’s postulate had to do with it</description><pubDate>Tue, 01 Sep 2026 22:25:26 GMT</pubDate><content:encoded>&lt;p&gt;I’ve spent a while building things inside SQL Server that have no business being there. This one started with a question I could not get rid off: what would it take to score a line of text data not by checking it against rules, but by considering every possible reading of it at once and letting the best one fall out?&lt;/p&gt;
&lt;p&gt;That question came from Feynman.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;1-theidea&quot;&gt;1. The idea&lt;/h2&gt;
&lt;p&gt;Feynman’s formulation of quantum mechanics rests on a move that still feels like cheating the first time you hear about it. Typically, a particle going from A to B takes one trajectory — the one that makes the action stationary. Feynman’s postulates say something different: the particle takes &lt;em&gt;every&lt;/em&gt; path. Each contributes an amplitude of equal magnitude, and the phase of that contribution is the classical action in units of ħ. Add them all up and the paths that disagree cancel; the ones near the classical trajectory reinforce. The single path you observe isn’t chosen. It’s what’s left standing once everything else has interfered itself out of existence.&lt;/p&gt;
&lt;p&gt;What grabbed me wasn’t the physics. It was the &lt;em&gt;procedural&lt;/em&gt; shape of it. Don’t decide early. Don’t prune. Enumerate everything, cost everything, and let the winner emerge from the sum.&lt;/p&gt;
&lt;p&gt;That’s a strange way to write a parser. Most text processing is a pipeline of early commitments — tokenise, then tag, then match, then correct — each stage throwing away information the next stage might have wanted. Feynman’s move is the opposite. Carry all the possibilities forward and settle at the end.&lt;/p&gt;
&lt;p&gt;Its pretty similar to the way I learn anyway, not having the interest in maths at school because they just didn’t teach it in context. Not once did a teacher say why you needed COS, TAN, SIN and why we were doing the calculations and angle measurements — not once did they say the reason for all this is because if you look at the Earth which is nearly round you can work out all this amazing stuff. The only thing that sunk in at school was Pythagoras’ theorem, but they never said where it would be useful. So with this lack of knowledge I stopped doing 4 A Levels and got a job in a Company that made ATM software and never looked back.&lt;/p&gt;
&lt;p&gt;So this idea of Feynman’s was appealing to me because its the way I have been working ever since — try every possibility there can possibly be and based on the statistics I have kept, we will see what falls out the end. So with that…&lt;/p&gt;
&lt;p&gt;I wanted to see what that looked like in T-SQL.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;2-what-itdoes&quot;&gt;2. What it does&lt;/h2&gt;
&lt;p&gt;Given a line of firewall log text, the engine produces the most likely reading of it with misspellings corrected, and a score for how coherent that reading is.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Firewalz oftehn blok malicius payloadds&lt;/code&gt; comes back as &lt;code&gt;firewalls often block malicious payloads&lt;/code&gt;, with all five corrections marked and a note that the input was heavily repaired. &lt;code&gt;kubernetes reconciled the deployment manifest successfully&lt;/code&gt; — perfect English, entirely outside its vocabulary — comes back unchanged, with a score reflecting that.&lt;/p&gt;
&lt;p&gt;Everything runs in SQL Server. No CLR, no external process, no Python scripts. Stored procedures, temp tables, one scalar function, and a lot of set-based work. Like before I should have stopped and just had a nice cup of tea and a lie down. I didn’t and here we are.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;3-how-itsbuilt&quot;&gt;3. How it’s built&lt;/h2&gt;
&lt;h2 id=&quot;31-thelattice&quot;&gt;3.1 The lattice&lt;/h2&gt;
&lt;p&gt;Each token position gets several &lt;strong&gt;candidate readings&lt;/strong&gt;: the word as written, plus lexicon entries it might be a misspelling of. Candidates come from two text processing favorites — a phonetic match on &lt;code&gt;SOUNDEX&lt;/code&gt;, or a shared initial letter within a tight length window — and are then priced by edit distance.&lt;/p&gt;
&lt;p&gt;That gives a lattice. Position one might read &lt;code&gt;Firewalz&lt;/code&gt; or &lt;code&gt;firewalls&lt;/code&gt;; position two &lt;code&gt;oftehn&lt;/code&gt; or &lt;code&gt;often&lt;/code&gt;. A path through it picks one candidate per position, which makes it a complete reading of the sentence.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_tx4x9QpjKSMu4fLXE74Dog.jpeg&quot; alt=&quot;Trust me, this is the most basic of text processing you can do…&quot;&gt;
&lt;em&gt;Trust me, this is the most basic of text processing you can do…&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Each node carries a cost for being read that way:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #LatticeNodes (PositionID, ObservedToken, CandidateToken, POSTag, NodePenalty, IsCorrection, InLexicon)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SequenceID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    COALESCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;POSTag&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LiteralTag&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;NN&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CASE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IS NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;   -- in lexicon as written&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LiteralTag&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IS NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;   -- a number or version string&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        ELSE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @OovPenalty                          &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- unknown, and staying that way&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IS NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #InputDocument d&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;LEFT JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LexiconToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; lex&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Domain&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @DomainContext &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The observed reading is always present, so the decoder can always decline to correct. Correction candidates go in alongside it, priced at &lt;code&gt;@CorrectionWeight × edit distance&lt;/code&gt;, plus an extra penalty if the observed word was &lt;em&gt;already&lt;/em&gt; in the lexicon.&lt;/p&gt;
&lt;h2 id=&quot;32-thecosts&quot;&gt;3.2 The costs&lt;/h2&gt;
&lt;p&gt;Transitions run strictly from position &lt;em&gt;i&lt;/em&gt; to position &lt;em&gt;i+1&lt;/em&gt;, so every path covers the whole sentence. Each one prices the pairing:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;less&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;CASE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    WHEN sem&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.BigramAction&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; IS NOT NULL           THEN sem&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.BigramAction&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    WHEN n1&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.POSTag&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; = N&apos;CD&apos; OR n2&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.POSTag&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; = N&apos;CD&apos; THEN @&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LiteralAdjacentCost&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;    WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (n&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.InLexicon = &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AND n&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.HasCandidate = &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;      OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (n&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.InLexicon = &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; AND n&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.HasCandidate = &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;THEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;OovAdjacentCost&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;    ELSE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;UnknownBigramCost&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  +&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(pos.FieldPenalty, @&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;UnknownGrammarCost&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;An verified bi-gram is best evidence — &lt;code&gt;-log P(w₂|w₁)&lt;/code&gt; fitted from a training corpus. Failing that, if either side is a number or a version string, no bi-gram table could ever have contained it, so allocating 100% would punish every log line containing an IP address. Failing that, an out-of-lexicon word with no near neighbour is unverified for the same reason. Only when both words are known and the pairing genuinely wasn’t seen, do you pay the full unverified cost. The grammar penalty, &lt;code&gt;-log P(tag₂|tag₁)&lt;/code&gt;, is added on top.&lt;/p&gt;
&lt;h2 id=&quot;33-thetrellis&quot;&gt;3.3 The trellis&lt;/h2&gt;
&lt;p&gt;Then the Feynman move: weight every complete path by &lt;code&gt;e^{-αS}&lt;/code&gt; where &lt;code&gt;S&lt;/code&gt; is its total cost, and normalise across the whole data set. Low-cost paths will dominate, high-cost paths vanish exponentially, and the winner is whatever survives.&lt;/p&gt;
&lt;p&gt;The naive way to do that is to enumerate the paths. Don’t (see 5.2). One pass over positions computes both the best path and the sum over all paths, without recording any of it:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHILE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @MaxSequence&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Incoming &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ToNodeID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;tr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FromNodeID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               prev&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;BestCost&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;StepCost&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                 AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CandCost,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               prev&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LogAlpha&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SoftmaxAlpha &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;StepCost&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; LogTerm&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Transitions tr&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        INNER JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Trellis prev &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; prev&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NodeID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FromNodeID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ToPosition&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Agg &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ToNodeID, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(CandCost) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; MinCost, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(LogTerm) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; MaxTerm&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Incoming &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ToNodeID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Summed &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;        -- shift by MaxTerm before exponentiating: no underflow&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ToNodeID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MinCost&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MaxTerm&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LogTerm&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MaxTerm&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ExpSum&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Agg a &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INNER JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Incoming i &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ToNodeID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ToNodeID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ToNodeID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MinCost&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MaxTerm&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    BestBack &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ToNodeID, FromNodeID,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;               ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ToNodeID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                                  ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CandCost &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ASC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, FromNodeID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ASC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rn&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Incoming&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Trellis (NodeID, PositionID, BestCost, BackNodeID, LogAlpha)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NodeID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @p,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MinCost&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NodePenalty&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;FromNodeID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MaxTerm&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LOG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ExpSum&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SoftmaxAlpha &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NodePenalty&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #LatticeNodes n&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INNER JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Summed   s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ToNodeID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NodeID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INNER JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; BestBack b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ToNodeID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NodeID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;rn&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PositionID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @p;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;      SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  END&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Three things happen in that one insert. &lt;code&gt;MinCost&lt;/code&gt; plus a backpointer is Viterbi — the cheapest way to reach this node. &lt;code&gt;LogAlpha&lt;/code&gt; is the forward algorithm in log space — the total weight of &lt;em&gt;every&lt;/em&gt; path reaching this node. And subtracting &lt;code&gt;MaxTerm&lt;/code&gt; before exponentiating is the log-sum-exp trick, which matters because a twenty-token sentence can accumulate an action in the hundreds and &lt;code&gt;EXP(-400)&lt;/code&gt; is zero in floating point. Without the shift, every path scores zero, the denominator is zero, and the whole thing silently returns nothing.&lt;/p&gt;
&lt;p&gt;It’s O(n·N²) in tokens and candidates. No recursion, no enumeration.&lt;/p&gt;
&lt;p&gt;Reading the answer back is a walk down the backpointers, which is the only recursion left and is linear in sentence length:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Walk &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NodeID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TerminalNodeID, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NodeID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;BackNodeID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Trellis t &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PositionID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @MaxSequence&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TerminalNodeID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NodeID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;BackNodeID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Walk w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INNER JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Trellis p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NodeID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;BackNodeID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;STRING_AGG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;IsCorrection&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                              THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ObservedToken&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;-&amp;gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CandidateToken&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                              ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CandidateToken&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX)), &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;         WITHIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; GROUP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PositionID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NVARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DecodedText,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;ObservedToken&lt;/code&gt; and &lt;code&gt;CandidateToken&lt;/code&gt; are both kept deliberately. A log-analysis tool that silently rewrites your logs is worse than useless — you need to see that &lt;code&gt;oftehn&lt;/code&gt; became &lt;code&gt;often&lt;/code&gt;, not just the tidied result. Although having said that, it would make a fine “cover your tracks” tool.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;4-where-the-physicsstops&quot;&gt;4. Where the physics stops&lt;/h2&gt;
&lt;p&gt;Remember when I started the article I said Feynman’s work inspired me to write this, I am not claiming to have solved Quantum mechanics or done anything other than used the idea of parsing everything at once and seeing from all possible paths which one succeeds.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This is not a quantum process and it is not a path integral.&lt;/strong&gt; Feynman’s amplitudes are complex: &lt;code&gt;e^{iS/ħ}&lt;/code&gt;. The entire content of the path integral is that phases can &lt;em&gt;cancel&lt;/em&gt; — destructive interference is what kills the non-classical paths. My weights are real and positive. Nothing ever cancels. Paths only ever add.*&lt;/p&gt;
&lt;p&gt;What I actually built is a Boltzmann-weighted sum over paths, which is a softmax over path costs, which is — to say it plainly although its actually not any plainer — the forward algorithm over a linear-chain conditional random field. An Hidden Markov Mode (HMM) decoder in a physicist’s coat. That’s is work that has been used in NLP for many years and once again I am thwarted by those pesky scientists and their meddling ways of thinking of everything possible many years ago.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_Yi5ov3M5aSd6QPAqw2l1XA.jpeg&quot; alt=&quot;You can’t teach a monkey new tricks&quot;&gt;
&lt;em&gt;You can’t teach a monkey new tricks&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So in all honesty my claim is weak: Feynman’s postulate is where the &lt;em&gt;design template&lt;/em&gt; came from. Include everything, cost everything, let the sum decide. The maths I ended up with is more thermal, not quantum. The inspiration was real; the isomorphism isn’t. Considering I self taught this stuff I think I’m doing as well as those kids with iPhones.&lt;/p&gt;
&lt;p&gt;*If anyone has access to a server that could actually do some quantum processing that would be nice…&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;5-seven-things-that-werewrong&quot;&gt;5. Seven things that were wrong&lt;/h2&gt;
&lt;p&gt;Most of these produced absolutely plausible output for many runs of this code, but its because the sample data is just way too small.&lt;/p&gt;
&lt;h2 id=&quot;51-string_split-doesnt-guarantee-order&quot;&gt;5.1 &lt;code&gt;STRING_SPLIT&lt;/code&gt; doesn’t guarantee order&lt;/h2&gt;
&lt;p&gt;I was assigning token positions from an &lt;code&gt;IDENTITY&lt;/code&gt; column populated by &lt;code&gt;INSERT ... SELECT FROM STRING_SPLIT(...)&lt;/code&gt;. Token order is the entire basis of a sequence model. The optimiser is free to return those rows in any order it likes and will change its mind under a different plan or parallelism. It worked on my test data by luck. Fixed with &lt;code&gt;OPENJSON&lt;/code&gt; and an explicit &lt;code&gt;ROW_NUMBER()&lt;/code&gt; over the array index.&lt;/p&gt;
&lt;h2 id=&quot;52-the-engine-was-deletingevidence&quot;&gt;5.2 The engine was deleting evidence&lt;/h2&gt;
&lt;p&gt;My early versions enumerated paths literally, with a recursive CTE that could skip ahead up to five tokens. Two problems.&lt;/p&gt;
&lt;p&gt;Path count grew as a Pentanacci sequence: five tokens gave eight paths, twenty gave 1.4 million, forty wouldn’t finish.&lt;/p&gt;
&lt;p&gt;Worse than that was routing &lt;em&gt;through&lt;/em&gt; a token cost two transitions while skipping &lt;em&gt;over&lt;/em&gt; it cost one, so skipping was almost always cheaper. When the engine met a word it didn’t recognise, its cheapest available explanation was to pretend the word wasn’t there. It was deleting evidence to lower its own score. On a log-analysis tool. Again one for the actual hackers.&lt;/p&gt;
&lt;h2 id=&quot;53-the-ensemble-wasempty&quot;&gt;5.3 The ensemble was empty&lt;/h2&gt;
&lt;p&gt;Requiring every transition to advance exactly one position fixed the deletion bug and immediately exposed a deeper one: with full coverage and one candidate per token, there is &lt;em&gt;exactly one path&lt;/em&gt;. The probability is 1.0 by definition. All the recursion was doing was summing over a set with one member.&lt;/p&gt;
&lt;p&gt;That’s what forced the lattice. Real alternatives have to come from competing &lt;em&gt;actual counts&lt;/em&gt; at each position, not from skipping them. Once the lattice existed the recursion became unnecessary, because a trellis gets the same answer without enumerating anything.&lt;/p&gt;
&lt;p&gt;So the naive implementation of “consider every path” died, and the postulate survived it. I think that’s the actual lesson: the physics gave me the right instinct, and I was correct eventually…&lt;/p&gt;
&lt;h2 id=&quot;54-normalising-edit-distance-hid-wholeedits&quot;&gt;5.4 Normalising edit distance hid whole edits&lt;/h2&gt;
&lt;p&gt;I was dividing edit distance by token length, so &lt;code&gt;conection → connection&lt;/code&gt; (one edit) scored 0.100 and &lt;code&gt;conection → connections&lt;/code&gt; (two edits) scored 0.182. A whole extra edit was worth 0.08.&lt;/p&gt;
&lt;p&gt;Meanwhile the bigram model had a strong opinion. The training corpus attested &lt;code&gt;inbound connections&lt;/code&gt; but never &lt;code&gt;inbound connection&lt;/code&gt;, a difference worth about 0.93. So the language model dragged the decoder onto the wrong inflection and the channel model was too quiet to object. Raw edit distance fixed it. Normalising by length is not standard for a channel cost, and this is why.&lt;/p&gt;
&lt;h2 id=&quot;55-plain-levenshtein-double-charges-transpositions&quot;&gt;5.5 Plain Levenshtein double-charges transpositions&lt;/h2&gt;
&lt;p&gt;After that fix, recall dropped from 94% to 80%. Five of the six new misses were transpositions: &lt;code&gt;friewalls&lt;/code&gt;, &lt;code&gt;unauthoirzed&lt;/code&gt;, &lt;code&gt;connectiosn&lt;/code&gt;, &lt;code&gt;immedaitely&lt;/code&gt;, &lt;code&gt;endopint&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Levenshtein scores an adjacent swap as two edits — a deletion and an insertion — so the single most common human typo was priced at double. Damerau-Levenshtein counts it as one:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Damerau: an adjacent transposition is ONE edit.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @i &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @j &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Ch     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Right, @j &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @ChPrev &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Right, @j,     &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Trans &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; UNICODE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Row2, @j &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;));&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Trans &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Best &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Best &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Trans;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The DP row is packed into an &lt;code&gt;NVARCHAR&lt;/code&gt;, one code unit per cell, offset by one because &lt;code&gt;NCHAR(0)&lt;/code&gt; returns &lt;code&gt;NULL&lt;/code&gt;. Damerau needs two previous rows rather than one, hence &lt;code&gt;@Row2&lt;/code&gt;. That change alone recovered every transposition miss.&lt;/p&gt;
&lt;h2 id=&quot;56-my-back-off-was-subsidising-typos&quot;&gt;5.6 My back-off was subsidising typos&lt;/h2&gt;
&lt;p&gt;I’d added a discount so transitions involving out-of-vocabulary words weren’t charged as though the pairing had been contradicted. Reasonable I thought — an IP address can never appear in a bigram table.&lt;/p&gt;
&lt;p&gt;But it also meant &lt;em&gt;keeping&lt;/em&gt; a misspelling got the discount while &lt;em&gt;correcting&lt;/em&gt; it paid full price. &lt;code&gt;ibound → inbound&lt;/code&gt; is a single edit and the engine still refused, because leaving the typo alone saved 1.2 on transitions and only cost 1.0 on the node. It was cheaper to be wrong.&lt;/p&gt;
&lt;p&gt;The fix is the &lt;code&gt;HasCandidate&lt;/code&gt; clause in 3.2: a word one edit from a real word is a suspected typo, not a legitimately unknown one, and doesn’t get the discount.&lt;/p&gt;
&lt;h2 id=&quot;57-select-assignment-doesnt-nullout&quot;&gt;5.7 &lt;code&gt;SELECT&lt;/code&gt; assignment doesn’t null out&lt;/h2&gt;
&lt;p&gt;This issue cost me an entire evening watching a query never finish.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- broken: loops forever&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @DocID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DocumentID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentQueue&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ProcessedStatus &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Pending&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DocumentID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @DocID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DocumentID;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When a &lt;code&gt;SELECT&lt;/code&gt; assignment matches no rows it leaves the variable &lt;strong&gt;unchanged&lt;/strong&gt;. So after the last document, &lt;code&gt;@DocID&lt;/code&gt; keeps its value, &lt;code&gt;WHILE @DocID IS NOT NULL&lt;/code&gt; stays true, and the final document is re-parsed forever.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- correct: SET with a scalar subquery assigns NULL on an empty result&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @DocID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(DocumentID) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentQueue&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;              WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ProcessedStatus &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Pending&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That difference between &lt;code&gt;SET&lt;/code&gt; and &lt;code&gt;SELECT&lt;/code&gt; is the entire bug. I now also keep a guard counter, so if the termination condition ever breaks again it raises rather than hangs.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;6-measuring-it&quot;&gt;6. Measuring it&lt;/h2&gt;
&lt;p&gt;I got tired of judging this by eye, so I built a harness.&lt;/p&gt;
&lt;p&gt;A 45-line training corpus of firewall log phrasings supplies the fitted costs: 150 lexicon tokens, 158 bigrams, 24 POS transitions. A separate 49-line test corpus — different sentences, same domain, 87% bigram coverage — supplies the evaluation. Typos are generated by deterministic single-character mutation.&lt;/p&gt;
&lt;p&gt;Crucially, every intended correction is verified by the candidate generator &lt;em&gt;before&lt;/em&gt; it goes into the corpus. That check found three targets — &lt;code&gt;ibound → inbound&lt;/code&gt;, &lt;code&gt;ivalid → invalid&lt;/code&gt;, &lt;code&gt;deied → denied&lt;/code&gt; — that were impossible by construction, because &lt;code&gt;SOUNDEX&lt;/code&gt; codes consonants positionally and dropping an early one moves every subsequent code. Without the check they’d have shown up as decoding failures that no amount of tuning could fix. They’re the reason the candidate generator has a second, non-phonetic recall channel.&lt;/p&gt;
&lt;p&gt;Scoring is token-level: a token that was wrong and got fixed is a true positive, one that was right and got broken is a false positive.&lt;/p&gt;
&lt;h2 id=&quot;7-results&quot;&gt;7. Results&lt;/h2&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Category                 TP FP FN TN &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Precision&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Recall&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Single typo              &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 56&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%     &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Multiple typos           &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 13&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%     &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Clean                    &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 66&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    —         —&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Out&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; of vocabulary        &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 29&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    —         —&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Scrambled word order     &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 23&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    —         —&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Literals &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; punctuation &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;multi&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sentence           &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 89&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    -&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;         —&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;All                      &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;35&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 285&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%      &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- And the coherence score separates cleanly by category:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Category                 Min   Avg   Max&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Clean                   &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;247&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;380&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;789&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Single typo             &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;247&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;380&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;789&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Multiple typos          &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;247&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;391&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;789&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Short lines             &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;250&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;555&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;675&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Literals (IPs, versions)&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;640&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;785&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;956&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Punctuation&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;heavy       &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;068&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;234&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;474&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Scrambled word order    &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;384&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;426&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;479&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Out&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; of vocabulary       &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;522&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;928&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;342&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2 id=&quot;8-two-different-questions&quot;&gt;8. Two different questions&lt;/h2&gt;
&lt;p&gt;Look at the first three rows of that table. Clean, single-typo and multi-typo lines have &lt;em&gt;identical&lt;/em&gt; ranges. That’s deliberate, and it took me a while to see why it should be.&lt;/p&gt;
&lt;p&gt;Originally the score included the cost of the corrections, so a line with four typos that decoded perfectly still read as low coherence. Arguably defensible — the input really was degraded — but it meant the number couldn’t answer the question I actually cared about, which is &lt;em&gt;how good is the reading I just produced&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;So the engine now tracks three costs: the total, the part spent repairing spelling, and the remainder. The verdict reads the remainder.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;TotalActionCost    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- how degraded was the input?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;CorrectionCost     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,       &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- what did the repairs cost?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;DecodedActionCost  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,       &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- how coherent is the result?The effect is exact. Every typo line now scores identically to the clean line it was derived from — test 16 went from 1.0972 to 0.7895, matching clean line 2 to four decimal places; test 25, five typos in five words, went from 2.1482 to 0.3300, matching clean line 1. Input quality is reported separately via the correction count.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It also removed an overlap that was making the verdict bands impossible to calibrate. Before the split, corrected lines ran up to 1.097 while punctuation-heavy lines started at 1.068, so no single threshold separated them. Afterwards everything that should read green tops out at 0.956 and everything that shouldn’t starts at 1.068. An actual gap.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;9-the-parameter-sweep&quot;&gt;9. The parameter sweep&lt;/h2&gt;
&lt;p&gt;Two constants control the correction behaviour, and they’re coupled. &lt;code&gt;@CorrectionWeight&lt;/code&gt; is the cost per edit; &lt;code&gt;@OovPenalty&lt;/code&gt; is the cost of leaving a token alone. I’d picked 2.0 and 3.0 by educated guess work and wanted to know whether that was a real optimum or just lucky, so I swept a 5×5 grid, re-running the whole corpus in each cell.&lt;/p&gt;
&lt;p&gt;F1 by cell, rows &lt;code&gt;@CorrectionWeight&lt;/code&gt;, columns &lt;code&gt;@OovPenalty&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_0C8im4DDpYXKEnDodV3AVw.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The control variable is O − W.&lt;/strong&gt; Line the cells up by the difference rather than the values and the recall side is almost perfectly determined:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_x4uviu4MOoqb3ceHGOuyOw.png&quot; alt=&quot;THE CONTROL VARIABLE &amp;amp; WEIGHTS&quot;&gt;
&lt;em&gt;THE CONTROL VARIABLE &amp;amp; WEIGHTS&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Identical along each diagonal. Which makes sense: O − W is the margin by which correcting a token is better leaving it alone, so it decides whether a one-edit fix fires at all. Below +0.5 it doesn’t, and recall falls off a cliff — 2 misses at zero margin, 12 at −1.0, 25 at −1.5.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;But there’s a second, independent constraint.&lt;/strong&gt;&lt;/em&gt; &lt;em&gt;The&lt;/em&gt; &lt;code&gt;*W = 1.0*&lt;/code&gt; &lt;em&gt;row breaks the diagonal pattern and never reaches 100% at any OOV penalty, carrying a floor of 2 false negatives that no amount of O fixes. That’s not a margin problem. It’s the channel model being too quiet to outvote the bigrams — exactly the inflection failure from §5.4, reappearing on its own from a completely different direction.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;False positives tell the other half. They occur only at low W with high O: five at (1.0, 3.0), three at (1.5, 3.5), zero anywhere with W ≥ 2.0. A three-edit correction costs 3W and becomes attractive once that drops below O plus the bigram saving. At W = 1.5 that’s 4.5 against roughly 4.6, so&lt;/em&gt; &lt;code&gt;*resumed → reset*&lt;/code&gt; &lt;em&gt;sneaks back in. At W = 2.0 it’s 6.0 against 5.1 and stays out.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;So:&lt;/em&gt; &lt;em&gt;&lt;strong&gt;W ≥ 1.5 for the channel model to be heard, W ≥ 2.0 to be immune to over-correction, and O − W ≥ 0.5 for corrections to fire at all.&lt;/strong&gt;&lt;/em&gt; &lt;em&gt;Eight cells satisfy all three. (2.0, 3.0) is the most interior of them, with three of four orthogonal neighbours also at 100%.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The hand-derived values turned out to be right, but I’d have had no way of knowing that without the grid — and more importantly, no way of knowing why.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;10-making-it-fast-enough-tosweep&quot;&gt;10. Making it fast enough to sweep&lt;/h2&gt;
&lt;p&gt;The first sweep attempt didn’t finish. Twenty-five cells at several minutes each is an afternoon, and I killed it so many times before working out where the time was going.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;fnEditDistance&lt;/code&gt; is a scalar UDF with a nested loop, called for every lexicon word that survives blocking. It sat inside a &lt;code&gt;CROSS APPLY&lt;/code&gt; over a derived table, and a derived table is not an optimisation fence — SQL Server flattens them routinely. If the blocking predicates don’t get pushed below the function, the UDF runs against all 150 lexicon rows per token instead of the six that survive. That’s 48,000 calls per cell instead of 2,000.&lt;/p&gt;
&lt;p&gt;The fix is one that should have been obvious from the start: &lt;strong&gt;edit distances don’t depend on the cost weights at all.&lt;/strong&gt; All 25 cells were recomputing byte-identical distances. So they’re computed once per distinct token, ever, and cached.&lt;/p&gt;
&lt;p&gt;The population is deliberately split into two statements, which is the part that matters:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Step 1: blocking only. Lands in a real table.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Blocked (Token, LexToken, POSTag)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;POSTag&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #NewTokens n&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INNER JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LexiconToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; lex&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Domain&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @DomainContext&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @CacheCeiling&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;       AND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ( &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DIFFERENCE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;             OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ( &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LEFT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LEFT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                  AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;lex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ) );&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Step 2: separate statement, so the function can only ever see survivors.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CandidateCache&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Domain, ObservedToken, CandidateToken, POSTag, RawEdit)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @DomainContext, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LexToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;POSTag&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RawEdit&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Blocked b&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fnEditDistance&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LexToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; RawEdit) e&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RawEdit&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RawEdit&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @CacheCeiling;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Inside one query the optimiser may reorder. Across two statements it cannot. Roughly 1,500 distance computations now cover the entire sweep, against 1.2 million in the flattened worst case. Cells went from minutes to under a second, and the output is byte-identical to the uncached run — which is the check that matters for a pure optimisation.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;11-what-this-doesntshow&quot;&gt;11. What this doesn’t show&lt;/h2&gt;
&lt;p&gt;A perfect score on a corpus I built myself is the point at which I should be &lt;em&gt;more&lt;/em&gt; suspicious, not less.&lt;/p&gt;
&lt;p&gt;The lexicon is 150 tokens in one domain. The corruptions are synthetic and uniform; real typists produce a messier distribution than four deterministic mutation rules. Every correction was pre-verified as reachable, which removes an entire failure mode that real text will happily supply. And 49 lines is small enough that one example moves the numbers several points — with 35 true positives.&lt;/p&gt;
&lt;p&gt;The score also measures vocabulary coverage more than it measures coherence. &lt;code&gt;kubernetes reconciled the deployment manifest successfully&lt;/code&gt; is flawless English and scores worse than anything else in the corpus. That’s the model reporting it has no vocabulary for the sentence, but read the number as “is this good English” and you’ll be misled.&lt;/p&gt;
&lt;p&gt;And I know of at least three things that will break on real data:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The&lt;/strong&gt; &lt;code&gt;**HasCandidate**&lt;/code&gt; &lt;strong&gt;fix inverts at scale.&lt;/strong&gt; With 150 words, few tokens have a lexicon neighbour. With 30,000, almost everything has one within three edits, so almost nothing gets the out-of-vocabulary discount and hostnames start being charged full price on both sides. The predicate probably needs tightening to “no neighbour within one edit”.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Blocking becomes a scan.&lt;/strong&gt; &lt;code&gt;DIFFERENCE(lex.Token, ...)&lt;/code&gt; and &lt;code&gt;LEFT(lex.Token, 1)&lt;/code&gt; are functions on the column, so there’s no seek. Invisible at 150 rows, painful at 30,000. Wants persisted computed columns and indexes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Candidate ranking gets crowded.&lt;/strong&gt; At this size the nearest word by edit distance is almost always the right one. At scale there will be a dozen words at distance one, and the ordering will need unigram frequency.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The next step isn’t more tuning. It’s real firewall log lines, with real errors in them, and finding out which of those three predictions was right.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;12-whybother&quot;&gt;12. Why bother&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_HgcMCD0Vd9RMGZLHs6XmtA.png&quot; alt=&quot;Sometimes, just sometimes I wish I never started these things.&quot;&gt;
&lt;em&gt;Sometimes, just sometimes I wish I never started these things.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;None of this belongs in a database. You could write it in fifty lines of Python with a library better than mine.&lt;/p&gt;
&lt;p&gt;But the constraint keeps teaching me things. Forcing a sequence model into set-based SQL made the exponential blow-up impossible to ignore, because a recursive CTE that fans out to a million rows doesn’t degrade gracefully — it stops. It made the ordering assumption visible, because SQL is the one language that will cheerfully reorder your data and be entirely within its rights. It made every cost explicit, because there’s nowhere to hide a heuristic in a &lt;code&gt;CASE&lt;/code&gt; expression. And it produced at least two bugs — the &lt;code&gt;SELECT&lt;/code&gt;-assignment loop, the flattened derived table — that simply don’t exist in other languages.&lt;/p&gt;
&lt;p&gt;The Feynman thing was never a claim. It was a way in: a specific, unusual instruction about how to organise a computation, borrowed from somewhere it had already proved itself. Consider everything. Cost everything. Let the sum decide.&lt;/p&gt;
&lt;p&gt;The maths I ended up with has a different name, and I should use that name. But I wouldn’t have got there any other way.&lt;/p&gt;
&lt;p&gt;As Promised: &lt;a href=&quot;https://github.com/sqlartist/feynman-sql&quot;&gt;https://github.com/sqlartist/feynman-sql&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If this was interesting, a few claps help other people find it. Follow me for more on Data.&lt;/p&gt;
</content:encoded><category>SQL Server</category><category>AI &amp; Data Science</category></item><item><title>The Cloud Has No Mercy</title><link>https://sqlartist.github.io/posts/the-cloud-has-no-mercy/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/the-cloud-has-no-mercy/</guid><description>Why we traded 56k dial-up frustration for automated digital hostage situations.</description><pubDate>Sun, 30 Aug 2026 12:00:37 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_8zM8AcHKh4jDh7IGToYYaw.png&quot; alt=&quot;Figure 1: Trading the agony of a 56k dial-up interruption for the looming dread of the infinite, faceless server farm.&quot;&gt;
&lt;em&gt;Figure 1: Trading the agony of a 56k dial-up interruption for the looming dread of the infinite, faceless server farm.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I was considering what it must be like for today’s generation of users, navigating technology while quite rightly taking it for granted. If you asked half of them how a file magically appeared on the screen of the device they are holding, they’d shrug and say, “Well, Jason sent it — duh!” The other half are actively plotting world domination from a handed-down iPhone.&lt;/p&gt;
&lt;p&gt;To go off topic slightly but it fits the timeline although I am tempted to take it out and make it a separate read, but readers of a certain age may enjoy the diversion.&lt;/p&gt;
&lt;p&gt;Nostalgia — aww, do you remember when…? Wasn’t the music… It was the best time ever, it will never be beaten, life was far simpler.&lt;/p&gt;
&lt;p&gt;Er no, I barely remember, the music is always good except for the 1980’s and I’m including fashion in that, it wasn’t the best time ever, and yes if you mean life was tediously boring with 3 TV channels, having to watch multiple episodes of the most depressing soap operas in history multiple times in the same day, it’s no wonder I developed a near identic memory — there was very little actually going on.&lt;/p&gt;
&lt;p&gt;I suffer from chronic cluster headaches from aged 30ish onwards probably caused by someone at my school breaking my neck, A 16-year-old, 4 years ahead of me, picked me up by my head and swung me around. I felt 2 clicks in my neck and was left on the floor not moving. Not knowing any better my school friends picked me up and carried me to the matron’s office. Long story short I was in a neck brace for a year, got excused from any sport at school and ended up in the library or computer room if they were unlocked. Computers were not switched on of course but still to be trusted to be in the most expensive room in the school was a bonus… or was it?&lt;/p&gt;
&lt;p&gt;Quick diversion as this is probably the single funniest thing to ever happen at that school. The day I got carried to the matron’s office, my parents were called and my mum arrived first and as you would expect went crazy, I was just sat there unable to move watching this play out. Quite a crowd was building outside the matron’s office. My mum was being calmed down by the deputy head (worst thing he could have done to be honest), quite a feared teacher and about the same height as my mum. When suddenly, my dad burst through the double doors straight from work (No mobile phones back then so he got a third hand message and didn’t know what to expect). They were both shaking when they saw me. The matron had not called an ambulance or done anything other than given me a hot cup of tea.&lt;/p&gt;
&lt;p&gt;To this day what happened next, I can remember word for word — the exact beat of what was said and the cheer that went up at the end from the entire sixth form who were still listening from outside the office, and before this moment I only heard about the teacher’s reputation from other kids.&lt;/p&gt;
&lt;p&gt;My dad was about a head taller than this guy who had to look up as my dad was standing close to him and spoke&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“You were a &lt;strong&gt;f*cking&lt;/strong&gt; little Hitler when I was here, and you still are a &lt;strong&gt;f*cking&lt;/strong&gt; little Hitler….you &lt;strong&gt;c*nt&lt;/strong&gt;! Right, we’re off…”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;He picked me up and we went straight to Accident &amp;amp; Emergency at the hospital. When my dad said this the entire sixth form crowd erupted in a massive cheer — no one liked this guy.&lt;/p&gt;
&lt;p&gt;That was quite a diversion and unexpected turn for this article but simply for the one-line insult it was worth it and of course for the near Oliver Twist experience living through the 1970’s and 1980’s in a very nice village in Hertfordshire, 21 miles away from Central London.&lt;/p&gt;
&lt;p&gt;I was the only pupil in the entire school to ever at that time be placed on Work Experience in London, quite a thing to be honest and it was with a computer Company called ICL — had no idea what they did as internet didn’t exist and no phones. I did have a computer at this point but was still under the impression that I had to learn to be a quick typist as the programs I found in magazines were way too long for me to type it in before the C15 tape ran out. I mean why weren’t computers allowed to use a C60 or C90 cassette tape? (for those that know will immediately see how my logic was flawed about the tape running out) But there was literally no information apart from a programming book my Godfather brought for me titled&lt;/p&gt;
&lt;p&gt;“The Century Computer Programming Course for the ZX81 and Spectrum”&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_SStJS_SbEM4CltxRDdUoMg.jpeg&quot; alt=&quot;Figure 2: A 570 page amazing book if I had a ZX81, which I didn’t&quot;&gt;
&lt;em&gt;Figure 2: A 570 page amazing book if I had a ZX81, which I didn’t&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;which was very handy for someone that had a Commodore 16 and no clue there were different versions of BASIC. I was using it as a riser for an overheating laptop until last year.&lt;/p&gt;
&lt;p&gt;Back to the main piece.&lt;/p&gt;
&lt;p&gt;I guess they never had the baggage of downloading a single image over a 56k modem from CompuServe or MSN. They don’t know the absolute heartbreak of your mum picking up the landline at 99% completion, completely ignoring those repeated, desperate pleas: “I know it’s your phone and you pay the bill, but &lt;em&gt;please&lt;/em&gt; do not make any calls for the next five hours!”&lt;/p&gt;
&lt;p&gt;It was right around that point — somewhere near the start of three decades deep in SQL databases — that I changed my entire trajectory. The singular goal? To never have to worry about that kind of expense or limitation ever again. We wanted to build systems that were faster, better, and limitless.&lt;/p&gt;
&lt;p&gt;But just as a piece of ancient vellum will comfortably outlast a carefully curated collection of 8,000 decaying DVDs, our technological trade-offs are rarely what they seem. We successfully eliminated the agonizing wait times and the physical friction of the 90s, but we replaced them with something much more insidious: the Cloud and AI.&lt;/p&gt;
&lt;p&gt;Some genius came up with the idea of limitless, instantly accessible compute, and it is glorious — right up until the moment it threatens to literally bankrupt you. They don’t even have the decency to invoice you upfront; you pay the bill after the algorithms have had their fun.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_GClE8oPrJ-a_72qpAPSNKg.png&quot; alt=&quot;Figure 3: Nimbus was the computer used at my school in 1986. It had a 10MB Winchester Hard Drive. I had to include a picture of that beast at the end of the article.&quot;&gt;
&lt;em&gt;Figure 3: Nimbus was the computer used at my school in 1986. It had a 10MB Winchester Hard Drive. I had to include a picture of that beast at the end of the article.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Between various Max subscriptions and managed cloud services, we have entered an era of unprecedented ruthlessness. If the money isn’t in that account the exact millisecond they check, they cut you off. They make unveiled threats to wipe your entire online history so quickly it makes your head spin. I mean, there should be a Nobel Prize for customer service this aggressively efficient. Even when you die, your loved ones don’t get processed with that kind of cold, calculated precision.&lt;/p&gt;
&lt;p&gt;Therein lies the danger of the “Jason sent it” mindset. When we abstract away the hardware and stop questioning how the underlying infrastructure actually works, we lose control. We traded the physical annoyance of dropped connections for a world where a faceless billing algorithm acts as an unforgiving landlord over our digital lives.&lt;/p&gt;
&lt;p&gt;The lesson here isn’t to go backwards, but to look beneath the hood. Understand the compute cycles you are spinning up. Keep a grip on your data sovereignty, because renting infinite power means you can be evicted in a heartbeat.&lt;/p&gt;
&lt;p&gt;Still, I suppose I should be grateful. At least I never had to punch little holes into a card and wait overnight to see if it had worked, just praying the mainframe hadn’t eaten the entire batch by morning…&lt;/p&gt;
&lt;p&gt;Or Fought in a War,&lt;/p&gt;
&lt;p&gt;Or had an AOL subscription&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_XIca-sgiMcAZoYoMfotHLQ.png&quot; alt=&quot;Figure 4: The 1986 RM Nimbus Winchester 10MB Hard Drive. A glorious, heavy beast that safely held less data than a single modern smartphone app notification.&quot;&gt;
&lt;em&gt;Figure 4: The 1986 RM Nimbus Winchester 10MB Hard Drive. A glorious, heavy beast that safely held less data than a single modern smartphone app notification.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If this was interesting, a few claps help other people find it. Follow me for more on Data.&lt;/p&gt;
</content:encoded><category>Life</category></item><item><title>Feynman’s Postulates and Relational Text Analytics in T-SQL</title><link>https://sqlartist.github.io/posts/feynmans-postulates-and-spatial-geometry-re-engineer-relational-text-analytics-in-t-sql/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/feynmans-postulates-and-spatial-geometry-re-engineer-relational-text-analytics-in-t-sql/</guid><description>Within the last few days Richard Feynman’s 80 year old quantum postulate has now been validated. It has been directly measured in an experiment for the first time.</description><pubDate>Thu, 27 Aug 2026 16:46:17 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://www.newscientist.com/article/2586608-richard-feynmans-80-year-old-quantum-postulate-has-now-been-validated/&quot;&gt;https://www.newscientist.com/article/2586608-richard-feynmans-80-year-old-quantum-postulate-has-now-been-validated/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Well thats just wonderful for all those scientists but here in the real world and someone whose life has been affected by Feynmans work its is no surprise.&lt;/p&gt;
&lt;p&gt;A bit of history, if you read any book or watch any documentary about a person read or watch “The Feynman Lectures on Physics”. I watched these and maybe understood 5% of the content, but what I got from it was Feynman’s energy and passion for his subject. A more readable for all the non mathematicians and physicists is “ &lt;em&gt;Surely You’re Joking, Mr. Feynman!”.&lt;/em&gt; There is also a BBC documentary on Youtube well worth watching.&lt;/p&gt;
&lt;p&gt;So affected by his life’s work on the Manhattan Project, Safe Cracking, Bongo playing, Lap Dancing and it mirroring my own life I got a tattoo with one of his famous (he won the Nobel prize for these) Feynman diagrams.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_h4bE13gYeQ109oP86xSLKw.jpeg&quot; alt=&quot;Yes, an actual Tattoo in tribute to Feynman Diagrams&quot;&gt;
&lt;em&gt;Yes, an actual Tattoo in tribute to Feynman Diagrams&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I am also making a model of his famous Feynman Van.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_Uwn1bEaZqZk4bGrW8HVVHg.jpeg&quot; alt=&quot;The Feynman Van&quot;&gt;
&lt;em&gt;The Feynman Van&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So, regardless of the scale of the end result I think he would be happy people use his ideas in unexpected ways. From a theory he made 80 years ago that has been validated by *proper* scientists has now been used to process some text in a SQL Database.&lt;/p&gt;
&lt;h2 id=&quot;abstract&quot;&gt;Abstract&lt;/h2&gt;
&lt;p&gt;Traditional natural language processing (NLP) inside classical relational databases relies on sequential string-splitting logic, cursors, or loops that process data character-by-character or by word-by-word. This article presents an alternative paradigm: a native text-analytics engine built entirely inside local Transact-SQL (T-SQL) that mirrors Richard Feynman’s “all paths” quantum postulate. By processing tokenisation, TF-IDF weighting, and multi-dimensional vector space layout via parallel set operations, I demonstrate how text can be analyzed, clustered via K-Means, and visually mapped on a physical canvas using SQL Server’s native Spatial Geometry view.&lt;/p&gt;
&lt;p&gt;1. The Core Philosophy: Sequential Reading vs. The All-Paths Matrix&lt;/p&gt;
&lt;h3 id=&quot;the-normal-text-processing-standard-sequential-explorer&quot;&gt;The Normal Text Processing Standard (Sequential Explorer)&lt;/h3&gt;
&lt;p&gt;I wrote my first version of this back in 1999 and found there was little interest in it. A fellow MVP Hillary Cotter was a great help back then when creating these ideas. I guess we weren’t mixing in the right circles as it didn’t go anywhere really. Fast forward 30 years…&lt;/p&gt;
&lt;p&gt;When a typical program parses text, it acts like an explorer manually walking through a maze. To extract keywords, phrases, or N-Grams, it reads a sentence word-by-word. It picks up the first word, looks at it, moves its pointer to the next word, and repeats. This is a linear timeline. If a database has to scan millions of rows of unstructured text logs this way, it bottlenecks the CPU by running millions of repetitive, sub-loops.&lt;/p&gt;
&lt;h3 id=&quot;the-feynman-methodology-the-infinite-stopwatch-maze&quot;&gt;The Feynman Methodology (The Infinite Stopwatch Maze)&lt;/h3&gt;
&lt;p&gt;Richard Feynman’s quantum postulate changes the entire architecture of the search. He argued that tiny particles don’t choose a single path from A to B — &lt;strong&gt;they travel down every single possible path at the exact same moment.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This T-SQL framework forces unstructured text strings to act exactly like Feynman’s quantum particles. Instead of looping through a sentence, a &lt;strong&gt;Tally Table Matrix&lt;/strong&gt; acts like a beam splitter. The second a string enters the query engine, it is instantly shattered into all possible character positions simultaneously.&lt;/p&gt;
&lt;p&gt;Every word location becomes an independent path running in parallel:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The Noise (Destructive Interference):&lt;/strong&gt; In quantum mechanics, paths have “stopwatches” with spinning hands. If hands point in opposite directions, they cancel out. In this code, common stop-words (like &lt;em&gt;“and”&lt;/em&gt; or &lt;em&gt;“uses”&lt;/em&gt;) have their weights calculated against the entire document collection via Inverse Document Frequency (IDF). Because they appear everywhere, their mathematical stopwatch hands point in opposite directions, creating &lt;strong&gt;destructive interference&lt;/strong&gt; that completely zeros out their linguistic noise.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Signal (Constructive Interference):&lt;/strong&gt; Unique, definitive terms (like &lt;em&gt;“quantum”&lt;/em&gt; or &lt;em&gt;“database”&lt;/em&gt;) align perfectly. Their stopwatches point in the exact same direction, creating &lt;strong&gt;constructive interference&lt;/strong&gt;. This piles up mathematical weight into specific vector pathways, letting the most important terms bubble to the top.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;2. Moving Beyond the “Bag of Words”: Geometry &amp;amp; Tied Dice&lt;/p&gt;
&lt;p&gt;A standard “Bag-of-Words” text tool is completely blind to context. It throws all words into an unstructured pile, losing track of word positions.&lt;/p&gt;
&lt;p&gt;By using Feynman’s spatial logic, words are not just counted; but are tracked along the physical geometry of their paths. Because the engine maps the spatial position of every token at the exact same moment, it can run instantaneous relational self-joins to build multi-word chains (&lt;strong&gt;N-Grams&lt;/strong&gt; and phrases) without losing the structural flow of the text.&lt;/p&gt;
&lt;p&gt;We can then leverage the quantum concept of &lt;strong&gt;Entanglement (the “Tied Dice” principle)&lt;/strong&gt; to handle document relationships. In standard database queries, comparing every document to every other document requires running thousands of isolated searches one after the other, or using a graph database.&lt;/p&gt;
&lt;p&gt;This engine runs a global matrix cross-join. It acts like pairs of magically tied dice: altering or evaluating a vector coordinate on one side of the matrix instantly forces the corresponding relationship score to resolve on the other side. This creates a true, multi-dimensional tensor contraction natively inside the relational engine, mapping the overlapping similarities of the entire corpus in a single pass.&lt;/p&gt;
&lt;p&gt;3. The Complete, End-to-End Local Framework&lt;/p&gt;
&lt;p&gt;The script below combines our entire pipeline. It initialises the unstructured text logs and stop-word filters, tokenises the text via parallel character paths, maps them into a 10-dimensional TF-IDF space, uses a matrix projection to compress those down to a 2D canvas, runs an automated K-Means distance clustering routine, and displays a &lt;strong&gt;Convex Hull Bounding Polygon&lt;/strong&gt; directly in SQL Server’s Management Studio Query Analyser Spatial canvas.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- =========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- 1. ENVIRONMENT INITIALIZATION&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- =========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; OBJECT_ID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dbo.DocumentSpatialPlot&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;U&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DROP&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.DocumentSpatialPlot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; OBJECT_ID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dbo.DocumentCoordinates3D&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;U&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DROP&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.DocumentCoordinates3D;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; OBJECT_ID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dbo.DocumentCorpus&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;U&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DROP&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.DocumentCorpus;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; OBJECT_ID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dbo.StopWords&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;U&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DROP&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.StopWords;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.DocumentCorpus (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    DocID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; IDENTITY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, DocTitle &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), DocText &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(MAX)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.StopWords (Word &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.DocumentCoordinates3D (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    DocTitle &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Coord_X &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Coord_Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Coord_Z &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, ClusterID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.DocumentSpatialPlot (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    DocTitle &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, ClusterID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, ClusterLabel &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), SpatialPoint &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GEOMETRY&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Seed Data &amp;amp; Noise Filter Matrix&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentCorpus&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (DocTitle, DocText) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Quantum Physics&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;quantum physics uses quantum mechanics and quantum states&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Database Systems&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;relational database systems use database tables and indexing&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Hybrid Engines&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;quantum computers and database systems create hybrid computing engines&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Hardware Clusters&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;superconducting circuits cluster hardware networks and processing arrays&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Network Security&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;secure networks use cryptographic keys inside database firewalls&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;StopWords&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (Word) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;and&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;use&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;uses&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;create&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;to&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;the&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;is&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;of&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;in&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;for&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- =========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- 2. PARALLEL TOKENIZATION, TF-IDF, AND DIMENSION REDUCTION&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- =========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Tally &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2000&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; N &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; sys&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;all_columns&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;RawTokens &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- FEYNMAN PATHWAY SPLIT: Shatters all character paths at the exact same moment&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocTitle&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           LOWER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocText&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CHARINDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocText&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CHARINDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocText&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CleanWord&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentCorpus&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Tally t &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocText&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUBSTRING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocText&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CHARINDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocText&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;FilteredTokens &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rt.&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; RawTokens rt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;LEFT JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;StopWords&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; sw &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; rt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CleanWord&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; sw&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Word&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; sw&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Word&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;TermFrequency &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DocID, DocTitle, CleanWord, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DocID) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TF&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FilteredTokens &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DocID, DocTitle, CleanWord&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;InverseDocFrequency &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- COHERENCE EVALUATION: Overlapping words create destructive interference, reducing their weight&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CleanWord, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LOG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentCorpus&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DISTINCT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DocID) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; IDF&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TermFrequency &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CleanWord&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;HighDimVectors &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tf&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocTitle&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;tf&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CleanWord&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;tf&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TF&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; idf&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;IDF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TF_IDF_Weight&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; TermFrequency tf &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; InverseDocFrequency idf &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; tf&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CleanWord&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; idf&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CleanWord&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;ProjectionWeights (WordToken, Comp_X, Comp_Y, Comp_Z) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- 10-Dimensional word matrix compression definitions&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;quantum&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;85&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNION ALL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;database&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;05&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;90&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;engines&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;70&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNION ALL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;physics&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;75&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;05&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;35&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;mechanics&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;80&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNION ALL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;relational&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;85&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;indexing&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;70&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNION ALL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;networks&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;80&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;hardware&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;75&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNION ALL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;cryptographic&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;50&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentCoordinates3D&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (DocTitle, Coord_X, Coord_Y, Coord_Z)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocTitle&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TF_IDF_Weight&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Comp_X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TF_IDF_Weight&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Comp_Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TF_IDF_Weight&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Comp_Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; HighDimVectors v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ProjectionWeights p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CleanWord&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;WordToken&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocTitle&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- =========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- 3. NATIVE K-MEANS DISTANCE CLUSTERING&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- =========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Centroids &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TABLE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (ClusterID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, X &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, Z &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Centroids (ClusterID, X, Y, Z) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @LoopCounter &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHILE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @LoopCounter &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 5&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- Measure spatial distance using Euclidean math&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DistanceCalculation &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocTitle&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ClusterID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Coord_X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Coord_Y&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Coord_Z&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Distance,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocTitle&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Coord_X&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Coord_Y&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Coord_Z&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Z&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ASC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ClosestRank&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentCoordinates3D&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; d &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Centroids c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; d &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ClusterID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ClusterID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentCoordinates3D&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; d &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DistanceCalculation dc &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocTitle&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocTitle&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dc&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ClosestRank&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DELETE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Centroids;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Centroids (ClusterID, X, Y, Z) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ClusterID, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Coord_X), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Coord_Y), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Coord_Z) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentCoordinates3D&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ClusterID;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @LoopCounter &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @LoopCounter &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- =========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- 4. SPATIAL GEOMETRY CONVERSION &amp;amp; MULTI-LAYER MAP PLOT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- =========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentSpatialPlot&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (DocTitle, ClusterID, ClusterLabel, SpatialPoint)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DocTitle, ClusterID, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ClusterID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Quantum Science&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ClusterID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Data &amp;amp; Network&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- Feature Scaling (*100) forces the SSMS Map View canvas to automatically zoom and scale perfectly&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    geometry&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;::STPointFromText(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;POINT(&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Coord_X &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Coord_Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;)&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentCoordinates3D&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- THE FINAL GRAPHICAL MAP VIEW GENERATION&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ScaledPoints &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ClusterLabel, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;geometry&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;::STPointFromText(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;POINT(&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Coord_X &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Coord_Y &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;)&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PointShape&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentCoordinates3D&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ClusterID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;ClusterBoundary &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- Convex Hull aggregates the separate point nails into a tight, solid background polygon sheet&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Cluster 2 Territory&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [Label], &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Data &amp;amp; Network&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [Group], &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;geometry&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;::UnionAggregate(PointShape).STConvexHull() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [SpatialShape] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ScaledPoints&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [Label], [Group], [SpatialShape] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ClusterBoundary&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; DocTitle &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [Label], ClusterLabel &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [Group], &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SpatialPoint&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;STBuffer&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [SpatialShape] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DocumentSpatialPlot&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;4. Visualizing the Final Measurement Map&lt;/p&gt;
&lt;p&gt;When you run this script inside SQL Server Management Studio (SSMS), look down at the query results window and select the &lt;strong&gt;Spatial Results&lt;/strong&gt; tab next to the grid text view. Set the drop down to map the &lt;code&gt;**Label**&lt;/code&gt; column on the screen.&lt;/p&gt;
&lt;p&gt;If you use your own text data you may encounter a problem which renders the Spatial view as completely blank. This can be resolved by multiplying everything by 100 which gives the Spatial Browser enough data to work with to allow it to display.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_piqbPRBDNo-yIPTOrZaXCg.png&quot; alt=&quot;The Spatial Query output&quot;&gt;
&lt;em&gt;The Spatial Query output&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_otwzjHYUk1_GdqJx5I053A.png&quot; alt=&quot;The Spatial Browser tab in SSMS has sadly been neglected but it does work&quot;&gt;
&lt;em&gt;The Spatial Browser tab in SSMS has sadly been neglected but it does work&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The Wave Function Collapse (The Shaded Polygon):&lt;/strong&gt; The &lt;code&gt;STConvexHull()&lt;/code&gt; function generates a shaded polygon area around the network infrastructure points. This polygon marks out the exact contextual territory of the data systems data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Bridge Point:&lt;/strong&gt; The &lt;em&gt;Hybrid Engines&lt;/em&gt; node sits right on the boundary line of the shape. Because it contains both quantum and database paths, its vector coordinate sits in the buffer zone between the two clusters.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Outlier:&lt;/strong&gt; The &lt;em&gt;Quantum Physics&lt;/em&gt; bubble floats completely outside the shaded shape on the other side of the screen canvas, proving that its vocabulary path belongs to a completely separate linguistic group.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By applying Feynman’s “all paths” perspective to database logic, we replace slow text loops with high-velocity geometric calculations — mapping raw strings into physical, visual coordinates on our screens.&lt;/p&gt;
&lt;p&gt;A way to use this on non textual data that is equally useful could be with Application Logs. Take the following as an example:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.ApplicationLogs (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    LogID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; IDENTITY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    LogCode &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    Description&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ApplicationLogs&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (LogCode, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;Description&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;ERR_404&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Page Not Found&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;ERR_500&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Internal Server Error&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;ERR_403&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Access Denied Forbidden&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;SYS_INIT&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;System Initialization Success&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;DB_CONN&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Database Connection Established&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;AUTH_FAIL&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;User Authentication Failed&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;CRIT_OOM&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Critical Out of Memory Warning&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;NET_TIMEOUT&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Network Request Timed Out&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;DISK_FULL&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Storage Space Exhausted&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;API_FAIL&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;External API Gateway Unresponsive&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;SEC_BREACH&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Unusual Login Location Detected&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;CACHE_MIS&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Redis Cache Miss Occurred&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;QUE_OVER&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Message Queue Overflowing&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;DATA_CORR&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Data Corruption Detected in Payload&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;FILE_MISS&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Configuration File Missing&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;PROC_DEAD&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Worker Process Terminated Unexpectedly&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; OBJECT_ID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;dbo.LocalQuantumRegister&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;U&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS NOT NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DROP&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LocalQuantumRegister&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.LocalQuantumRegister (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    PathID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    BinaryString &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Amplitude &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    Probability &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQUARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Amplitude)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PERSISTED&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We then create the stored procedure:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PROCEDURE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_QuantumSearchMultiTarget&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @SearchPattern &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOCOUNT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- 1. SETUP DATA MAPPING AND DYNAMIC MATRIX MATH&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @TotalPaths &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 16&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @InitialAmplitude &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@TotalPaths);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @MatchCount &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- Local table variable to bind textual identifiers to numeric PathIDs&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @DataMap &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TABLE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        PathID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; IDENTITY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        OriginalLogID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        LogCode &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        IsTarget &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BIT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DEFAULT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    );&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @DataMap (OriginalLogID, LogCode)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; LogID, LogCode &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ApplicationLogs&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- Flag all data entries matching the text parameter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @DataMap&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; IsTarget &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; LogCode &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;LIKE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SearchPattern;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @MatchCount &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @DataMap &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; IsTarget &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @MatchCount &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        RAISERROR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;Error: Zero database rows matched the specified criteria. Simulation halted.&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        RETURN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- Grover Math for Multi-Targets: Floor( (Pi / 4) * Sqrt(N / M) )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @OptimalIterations &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; FLOOR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PI&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@TotalPaths &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@MatchCount &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)));&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @OptimalIterations &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @OptimalIterations &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- 2. INITIALIZE UNIFORM SUPERPOSITION (&quot;ALL PATHS&quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    TRUNCATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LocalQuantumRegister&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; BinaryGeneration &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ID, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;0000&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; BinStr&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        UNION ALL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RIGHT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;0000&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((ID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(((ID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)%&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((((ID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)%&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)%&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;            CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((((ID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)%&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)%&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)%&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; BinaryGeneration &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ID &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 15&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LocalQuantumRegister&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (PathID, BinaryString, Amplitude)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ID, BinStr, @InitialAmplitude &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; BinaryGeneration;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- 3. CORE WAVE INTERFERENCE LOOP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @CurrentLoop &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @AvgAmplitude &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FLOAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHILE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @CurrentLoop &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @OptimalIterations&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;        -- Phase Inversion (The Oracle): Flip the amplitude sign for ALL matching targets&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; q&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SET&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Amplitude&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Amplitude&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LocalQuantumRegister&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; q&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @DataMap m &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PathID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PathID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;IsTarget&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;        -- Amplitude Amplification (The Diffusion Step): Invert around the global average&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @AvgAmplitude &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(Amplitude) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LocalQuantumRegister&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        UPDATE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LocalQuantumRegister&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Amplitude &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @AvgAmplitude) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Amplitude;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @CurrentLoop &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @CurrentLoop &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;    -- 4. INTERSECT QUANTUM STATES WITH REAL-WORLD LOG ROWS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;        m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PathID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [Quantum_Path_Index],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;        q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;BinaryString&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [Quantum_Address],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;        CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Probability&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; VARCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;%&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [Match_Confidence],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;        l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LogCode&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [Discovered_Key],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;        l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Description&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [Raw_Database_Value],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        @OptimalIterations &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; [Dynamic_Iterations_Executed]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LocalQuantumRegister&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; q&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @DataMap m &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PathID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;PathID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ApplicationLogs&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; l &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; m&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;OriginalLogID&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; l&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LogID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Probability&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and execute with different parameters each time. This is on an heap object.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; STATISTICS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IO&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_QuantumSearchMultiTarget&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SearchPattern &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;ERR%&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_QuantumSearchMultiTarget&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SearchPattern &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;DISK%&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_QuantumSearchMultiTarget&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @SearchPattern &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;NET%&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; STATISTICS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IO&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OFF&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_92wDKrhyD4EDsfYx3yjjVw.png&quot; alt=&quot;The output for the Quantum Search Query&quot;&gt;
&lt;em&gt;The output for the Quantum Search Query&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I want to scale this method to a huge amount of data but I also wish I wasn’t doing quantum calculations on a non quantum computer so if anyone at NVIDIA or Microsoft is feeling generous… :)&lt;/p&gt;
&lt;p&gt;That’s all for today, and its been exhausting, so I’m off just like Feynman would be to do more research sadly not at the local Lap Dancing club.&lt;/p&gt;
</content:encoded><category>SQL Server</category><category>AI &amp; Data Science</category></item><item><title>Relational Space Carving in SQL Server using My Head</title><link>https://sqlartist.github.io/posts/relational-space-carving-in-sql-server-using-my-head/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/relational-space-carving-in-sql-server-using-my-head/</guid><description>When you have spent 30 years designing relational databases and enforcing strict transactional integrity, there is something deeply satisfying about completely abusing the SQL engine to do exactly what it was never designed for.</description><pubDate>Sun, 23 Aug 2026 14:28:14 GMT</pubDate><content:encoded>&lt;p&gt;Here is the complete documentation of how you can turn SQL Server into a crude 3D photogrammetry engine, taking a flat image, mathematically carving it in a database, and outputting a watertight mesh ready for the 3D printer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Project: Relational Space Carving in SQL Server&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Goal:&lt;/strong&gt; Generate a 3D point cloud (.obj) of a human head natively within SQL Server using a 4-panel orthographic reference image, and process that raw data into a physical mesh.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1: The 2D Proof of Concept&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Before calculating Z-depth, the database needed to prove it could accurately shred a binary file and map spatial coordinates. We loaded an uncompressed 24-bit/32-bit BMP into memory using OPENROWSET, shredded the binary string using an inline Tally Table to avoid WHILE loops, and mapped the RGB luminance values to an ASCII gradient.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1__7DfiQ7IQ00fgAEi0-NkUg.png&quot; alt=&quot;A 2D rendering of my Head, Obviously Front View&quot;&gt;
&lt;em&gt;A 2D rendering of my Head, Obviously Front View&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;By inverting the gradient and compensating for the byte-stride of a 32-bit image, the database successfully rendered a 2D heightmap directly in the SSMS query results window.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_MoBxkuosKh-jnX8RrD-XZg.png&quot; alt=&quot;The inverted 2D ASCII render perfectly* mapped in SSMS text results exported to Notepad&quot;&gt;
&lt;em&gt;The inverted 2D ASCII render perfectly* mapped in SSMS text results exported to Notepad&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;When I say perfectly rendered my head, I mean I nearly lost it and abandoned the entire project at this point. The first time I ran it I got a very lopsided view of my neck. When I realised I had to zoom out quite a bit I did sort of see my head. &lt;br&gt;
I then inverted the image and then saw my head but still lopsided.&lt;br&gt;
 &lt;br&gt;
Eventually I realised I was looking at a 32-bit image; a 24-bit image looks at RED, GREEN and BLUE at 8-bits each. A 32-bit image looks at RED, GREEN and BLUE and an 8-bit alpha channel for transparency ! That is when it all appeared.&lt;/p&gt;
&lt;p&gt;I then did the same and rendered this image which is the input into the next section.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_2y4iXj-swl1LO5c2rLfC_Q.png&quot; alt=&quot;The Four Renders (Front, Left. Right and Back)&quot;&gt;
&lt;em&gt;The Four Renders (Front, Left. Right and Back)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I would smile more but if you ever want to animate your head it is important to maintain a “no expression” look, also I have a huge scar on the back of my actual head and because it is really tough taking a picture of the back of your head this is a stunt rear head&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2: The 3D Space Carving Architecture&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To generate 3D geometry, we utilized a technique called &lt;strong&gt;Visual Hull Intersection&lt;/strong&gt; (Space Carving).&lt;/p&gt;
&lt;p&gt;The query reads the top-left quadrant of the image as the Front Profile (X, Y) and the top-right quadrant as the Side Profile (Z, Y). By setting a luminance threshold of 150, we mathematically erased the grey studio background. I had issues at this point with my maths and ended up just resorting to using the top two views.&lt;/p&gt;
&lt;p&gt;The core engine is a strict INNER JOIN on the Y (height) axis. If a voxel is solid from the front view &lt;em&gt;and&lt;/em&gt; solid from the side view on the exact same row, it survives. If not, it is carved away.&lt;/p&gt;
&lt;p&gt;Early tests using a massive @Skip = 8 downsampling variable resulted in severe mathematical artifacts, including the “Cartesian explosion” when the background threshold was too high, and heavy horizontal terracing when the gaps between the evaluated rows were too wide.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_eqJp5KiAgWTGGqTKkU6s3g.png&quot; alt=&quot;The Cartesian explosion showing Moiré interference patterns&quot;&gt;
&lt;em&gt;The Cartesian explosion showing Moiré interference patterns&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;To eliminate the stepping artifacts, we dropped the downsampling to a 1:1 pixel resolution (@Skip = 1).&lt;/p&gt;
&lt;p&gt;Because evaluating millions of pixels via CTEs would cause the query optimizer to spool endlessly, the architecture was shifted to physical temporary tables. By inserting the front and side coordinates into #TempFront and #TempSide, and applying a &lt;strong&gt;Clustered Index&lt;/strong&gt; to the Y axis on both, we forced SQL Server to execute a lightning-fast Merge Join.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Final SQL Script&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 4: Skinning the Data in Blender&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Because SQL only writes vertices (points in space), the raw import into Blender appears as a solid black shadow. The geometry has no faces, so light cannot react to it.&lt;/p&gt;
&lt;p&gt;To convert this raw data into a manifold mesh, we bypass manual topology and use &lt;strong&gt;Geometry Nodes&lt;/strong&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Assign a Points to Volume node to the geometry, tuning the Radius up until the individual point spheres bridge the gaps between the coordinates.&lt;/li&gt;
&lt;li&gt;Pipe that volume directly into a Volume to Mesh node.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When this is executed on the 1:1 high-resolution SQL export, the severe terracing disappears, resulting in an incredibly dense, solid silhouette.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_r8Q_FG_5NfffgCK1zCs-QQ.png&quot; alt=&quot;The high-resolution 1:1 mesh output from the Geometry Nodes.&quot;&gt;
&lt;em&gt;The high-resolution 1:1 mesh output from the Geometry Nodes.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;You can almost see the head now turned, so using both the front view and the side view. The Moiré interference patterns were still showing and this is because when doing the combining of the views, SQL is using a pure join and if it does not match perfectly then the point cancels itself out. What I needed was a fuzzy join which looked for points near the actual point.&lt;/p&gt;
&lt;p&gt;I also forgot about Blender and the way it imports .obj files. So, for the first few attempts I was getting a head 6000 metres tall and I just thought Blender had failed to import.&lt;/p&gt;
&lt;p&gt;When I realised, I carried on with the post-processing.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 5: Post-Processing and Print Prep&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The final step is knocking down the micro-grid “waffle” texture left behind by the spherical voxel generation.&lt;/p&gt;
&lt;p&gt;By applying the Geometry Nodes modifier and passing the mesh through a Decimate modifier (to reduce the polygon count) followed by a Smooth modifier (to average the vertex laplacians), the head becomes perfectly clean.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_Kp01OSTBt3HEtaFildoZUg.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;It is now a watertight, production ready .stl or .obj, ready to be sent across to the eight 3D printers and brought into the physical world. I already have the eyes to put into the head but that’s another article.&lt;br&gt;
 &lt;br&gt;
 This is almost printable but rotating it shows why you should not leave a gap of more than 30 degrees between each image. They must overlap otherwise how can the algorithm now how to match each pixel to the next image. Photogrammetry tools do this well, I however am using SQL Server and have not. I could either increase the number of photos required for the image matching or I could use a photogrammetry tool. Guess which I choose 😊&lt;/p&gt;
&lt;p&gt;Next time I put my robot eyes into the 3d printed head and begin the cloning process ;)&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_EB5Ca7faD9HxtSXu5SItxw.png&quot; alt=&quot;I am sort of joking…&quot;&gt;
&lt;em&gt;I am sort of joking…&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Hope you enjoyed the failure and the article. For some unknown reason it would not let me paste the code into the article so screenshots for now. Code when I have it up on github.&lt;/p&gt;
&lt;p&gt;Trevor (@sqlartist)&lt;/p&gt;
</content:encoded><category>SQL Server</category><category>AI &amp; Data Science</category></item><item><title>Vellum Lasts 500 Years. My 8,000 DVDs Didn’t.</title><link>https://sqlartist.github.io/posts/vellum-lasts-500-years-my-8-000-dvds-didnt/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/vellum-lasts-500-years-my-8-000-dvds-didnt/</guid><description>I built a 3D Navigator in SQL Server to allow a virtual walk around your data.</description><pubDate>Wed, 19 Aug 2026 11:52:04 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_WHozgig7fxMm8nDVE-i7zQ.jpeg&quot; alt=&quot;Vellum and Acts of Parliament&quot;&gt;
&lt;em&gt;&lt;a href=&quot;https://www.patricialovett.com/vellum-and-acts-of-parliament/&quot;&gt;Vellum and Acts of Parliament&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;*I have around 80 terabytes accumulated over thirty years. I have managed to index roughly a fifth of it. Keeping it all was the easy part.*&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_sdyIzAp7FarHJIJF918laA.jpeg&quot; alt=&quot;A corridor rendered from a filesystem&quot;&gt;
&lt;em&gt;A corridor rendered from a filesystem&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Ask someone for a cassette player because you need to read an important document you stored on one, and watch their face.&lt;/p&gt;
&lt;p&gt;I had eight thousand DVDs. At the time that felt like permanence — physical, indexed, sitting on shelves. Then Blu-ray, then nothing, and now a stack of discs I have no confident way to read and no realistic way to search. Before that it was tape. Before that, floppies I dutifully copied forward for years until I stopped.&lt;/p&gt;
&lt;p&gt;Meanwhile there are documents in British archives written on vellum in the eleventh century that you can walk up to and read today. No reader required. No format migration. No driver. The Domesday Book is nearly a thousand years old and its retrieval technology is &lt;em&gt;*eyes*&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;That contrast has bothered me for a long time, and I think most people take the wrong lesson from it. The usual conclusion is that we need better media — longer-lived discs, archival film, quartz glass. And that’s a real field with real progress in it. But it isn’t the thing that has actually cost me.&lt;/p&gt;
&lt;p&gt;What’s actually cost me is that I &lt;em&gt;*have*&lt;/em&gt; the data and cannot see it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;## Thirty years of keeping everything&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I’ve saved almost everything since the mid-nineties. I’ve also lost nearly all of it several times over — drive failures, migrations, one memorable act of self-sabotage. Each time I had backups. Each time the backups turned out to be less restorable than I’d assumed. What survived, survived by accident and duplication rather than by strategy.&lt;/p&gt;
&lt;p&gt;The current state of that thirty-year sediment is roughly &lt;strong&gt;**80 TB**&lt;/strong&gt; — two main machines plus a shelf of external drives holding whatever was current when I last migrated. I have no complete inventory of it. I’m not sure a complete inventory is even possible without a month of downtime.&lt;/p&gt;
&lt;p&gt;What I &lt;em&gt;*have*&lt;/em&gt; indexed is the creative-work portion: the drives holding my Unreal Engine, Unity and Blender projects.&lt;/p&gt;
&lt;p&gt;- &lt;strong&gt;**11,217,469 files**&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;- &lt;strong&gt;**14.78 TB**&lt;/strong&gt; across four drives&lt;/p&gt;
&lt;p&gt;- &lt;strong&gt;**2,057,943 directories**&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;That’s the well-behaved fifth. The part I actually curate, actively use, and would have said I knew my way around. The other sixty-odd terabytes are worse in every respect.&lt;/p&gt;
&lt;p&gt;And that’s the uncomfortable bit. This isn’t a landfill I’d neglected. This is the good stuff.&lt;/p&gt;
&lt;p&gt;And here’s the thing that finally pushed me into building something: I have no way to look at it. Not “no convenient way” — no way at all. My actual tool for understanding my own storage is [WizTree](&lt;a href=&quot;https://diskanalyzer.com/&quot;&gt;https://diskanalyzer.com/&lt;/a&gt;), which is excellent at what it does and what it does is show me a treemap of &lt;em&gt;*sizes*&lt;/em&gt;. It tells me that 400 GB is sitting in a folder. It cannot tell me what any of it is.&lt;/p&gt;
&lt;p&gt;Explorer is worse. Search indexes filenames. Nothing tells me &lt;em&gt;*this is a car model, and so are these six hundred others, and four of them are the same car*&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The information is preserved. It is completely unnavigable. As far as actually using it goes, that’s the same as having lost it — just more expensive.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;## Preservation is a solved-ish problem. Comprehension isn’t.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There’s a whole discipline of digital preservation, and its practitioners worked this out decades ago. The threat to a digital archive isn’t usually the medium rotting. It’s that the &lt;em&gt;*reader*&lt;/em&gt; disappears — the drive, the codec, the application, the person who knew what the folder structure meant. Media obsolescence outpaces media decay by a wide margin. The standard defence isn’t a magic disc, it’s boring and effective: open formats, many copies, and migrating everything forward on a schedule, forever.&lt;/p&gt;
&lt;p&gt;But even that only guarantees the bytes survive. It says nothing about whether you can &lt;em&gt;*find*&lt;/em&gt; anything, or whether you’d recognise it if you did. A perfectly preserved archive that nobody can navigate is a very well-maintained landfill.&lt;/p&gt;
&lt;p&gt;That’s the problem I actually wanted to solve. Not “will this survive?” but “given that it survived, how do I stand in it and look around?”&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;## Two half-finished projects&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I’d been circling this from two directions without noticing they were the same direction.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;**The first**&lt;/strong&gt; was a Blender add-on. I wanted to browse my 3D work — Unreal Engine, Unity and Blender projects — the way you’d browse an OLAP cube: pivot it, slice it, drill down. So I wrote a fast filesystem scanner that catalogues everything into a local database, detects project roots by their marker files, and derives dimensions from what it finds — drive, path hierarchy, file type, calendar.&lt;/p&gt;
&lt;p&gt;Then I added the part that mattered: a &lt;strong&gt;**semantic layer**&lt;/strong&gt;. Rather than only recording that a folder exists, it parses project names, paths and READMEs into &lt;em&gt;*facets*&lt;/em&gt; — what a project depicts, what kind of asset it is, what genre it belongs to. Not “e:\\_Vehicles\\Vehicle_Red_Mustang” but &lt;em&gt;*vehicle, car, racing*&lt;/em&gt;. Geography and style are modelled as “depicts” facets rather than literal locations, so a desert canyon asset lives under `Natural &amp;gt; Arid &amp;gt; Desert` regardless of which folder it happens to sit in.&lt;/p&gt;
&lt;p&gt;That scan produced 4,546 detected projects out of the 11.2 million scanned files, with around 11,000 facet assertions describing them.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;**The second**&lt;/strong&gt; was, I’ll admit, a stunt. I’d been building increasingly unreasonable things inside SQL Server — a ray tracer, a Turing machine, eventually a playable renderer — mostly to find out how far T-SQL could be pushed as an expressive medium rather than a query language.&lt;/p&gt;
&lt;p&gt;The stunt gave me a renderer. The add-on gave me a semantically tagged map of my entire storage. It took me embarrassingly long to notice that the second thing was a &lt;em&gt;*world description*&lt;/em&gt; and the first thing could &lt;em&gt;*walk around in it*&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;## Standing inside your own hard drive&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So the two got welded together. The cube feeds a compiler that turns projects into architecture, and SQL Server renders it in first person.&lt;/p&gt;
&lt;p&gt;The mapping is deliberately literal, and every surface is a fact:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_VXj0GfTY7MxxTPh8RQxyVw.jpeg&quot; alt=&quot;What each colour and object represents&quot;&gt;
&lt;em&gt;What each colour and object represents&lt;/em&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| you see                   | it means                                    |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;|                           |                                             |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| room size                 | bytes on disk                               |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| ceiling height            | file count, log scaled                      |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| wall colour               | which semantic district you&apos;re standing in  |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| darkness                  | nothing has touched this in a long time     |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| amber doorframe           | a doorway into an adjacent project          |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| steel pillars             | the tags that classify this project         |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| a pit instead of a floor  | untagged - the classifier couldn&apos;t reach it |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| floor plate underfoot     | an asset this project shares with another   |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The result for my corpus: &lt;strong&gt;**4,546 rooms in 70 districts**&lt;/strong&gt;, 75,595 wall segments, 6,783 doorways, and 3,707 floor plates, laid out across a world just under 15,000 units across.&lt;/p&gt;
&lt;p&gt;Districts are the part that turns it from a visualisation into a place. Group by semantic facet and you get a vehicle quarter with several hundred rooms in it, a cyberpunk quarter, a large dark region of things nothing has opened in two years. You don’t query for those. You walk round a corner and there they are.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_slyLcFtkfJFgsysm6TW_sg.png&quot; alt=&quot;Crossing into a different district&quot;&gt;
&lt;em&gt;Crossing into a different district&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;## It’s also a text adventure&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A rendered view can’t tell you a row count, so every frame ships prose alongside the picture:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;less&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;- [&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vehicle&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;UltimateCarRacingProject&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;] 38,114 files 11&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; GB 4 tags 2,207 folders&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;exits: N [&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;vehicle&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;DestructibleVehicles5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.7] SW [&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;game&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;LyraStarterGame&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#8DDB8C&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; shares 107 files (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;11.4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; GB) with [demo].[CitySample]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And you can talk to it. What you type compiles into a predicate, and the matching rows become beacons visible through walls, with a bearing and a distance:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;/where is CitySample&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;/show me the biggest&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;/what&apos;s unused&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;/heaps&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Those beacons are the thing that makes fifteen terabytes tractable. You ask a question, and the answer becomes a direction you can walk in.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1__dkJYHNjwuJ10vIWcUtzsg.jpeg&quot; alt=&quot;The automap&quot;&gt;
&lt;em&gt;The automap&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;## What it told me that a query wouldn’t have&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Two things, and neither was what I built it to find.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;**The duplication is worse than I thought, and more interesting.**&lt;/strong&gt; The floor plates connect projects sharing substantial files. Standing in one project and seeing four plates underfoot — 107 files here, 88 there, 11 GB in one case — is a very different experience from a duplicate-file report. A report gives you a list to feel guilty about. The plates tell you &lt;em&gt;*which of your projects are secretly the same project*&lt;/em&gt;, which is information about how you actually work.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;**My classifier has holes I couldn’t see.**&lt;/strong&gt; Ask for `/heaps` and every untagged project lights up. Most were exactly what you’d expect: `_zips2`, `_MegaDownloads`, folders called `Documents2` — genuine landfill, correctly unclassified. But scattered among them were real projects with perfectly descriptive names the tokeniser simply wasn’t catching. I went in to look at the graphics and came out with a to-do list for the tagging vocabulary.&lt;/p&gt;
&lt;p&gt;That’s the argument for the whole approach, really. Both of those were sitting in the database the entire time. I’d never have thought to ask for either.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;## This isn’t only for filesystems&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;One file in the system knows where the data came from. Everything after it — layout, rendering, navigation, the query language — works from a normalised table of &lt;em&gt;*rooms*&lt;/em&gt; and &lt;em&gt;*links between rooms*&lt;/em&gt;. Replace the harvester and nothing downstream notices.&lt;/p&gt;
&lt;p&gt;I built the first version against &lt;strong&gt;**AdventureWorks2025**&lt;/strong&gt;, because a known schema makes it obvious when the geometry is wrong: tables as rooms, foreign keys as floor plates, heaps as rooms with no floor. It works, and at 71 tables it’s honestly pointless — you’d read the diagram faster.&lt;/p&gt;
&lt;p&gt;But the same engine would walk a purchase order system, where you’d step from an order into the customer who placed it and out into every other order they’ve made. Or a document archive. Or a photo library. Anything with entities and relationships between them has a floor plan hiding in it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;## Running it&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Seven SQL scripts, a PowerShell client, two Python bridges.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| file              | what it does                                               |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;|                   |                                                            |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| `01_schema.sql`   | tables, tunables, the intent grammar                       |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| `02_harvest.sql`  | database catalog harvester                                 |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| `03_layout.sql`   | the map compiler - partition, walls, doors, pillars, plates|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| `04_render.sql`   | raycaster, colour ramps, status line, automap              |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| `05_navigate.sql` | movement, collision, the command parser                    |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| `06_cube.sql`     | filesystem-cube staging and harvester                      |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| `07_perf.sql`     | spatial index for room lookups                             |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| `schemawalk.ps1`  | the client                                                 |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| `inspect_cube.py` |                                                            |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;| `export_cube.py`  | the bridge from the scanner&apos;s database                     |&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Install into any database — it doesn’t need to be the one you’re walking:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d SQLWORLD -C -i 01_schema&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d SQLWORLD -C -i 02_harvest&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d SQLWORLD -C -i 03_layout&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d SQLWORLD -C -i 04_render&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d SQLWORLD -C -i 05_navigate&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d SQLWORLD -C -i 07_perf&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To walk a database:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;EXEC nav.usp_Build &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;@source_db&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; = &apos;AdventureWorks2025&apos;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;EXEC nav.usp_Verify;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To walk a filesystem, add the cube staging and bridge the scanner’s output across:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;kotlin&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;S . &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;d SQLWORLD &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;C &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;i 06_cube.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;python inspect_cube.py D:\_AssetOLAP\&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;\asset_cube_v4.db&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;python export_cube.py D:\_AssetOLAP\&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;\asset_cube_v4.db &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;o cube_load.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;S . &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;d SQLWORLD &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;C &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;i cube_load.sql &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;f &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;65001&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;EXEC nav.usp_BuildCube &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;@district_by&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; = &apos;facet&apos;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;EXEC nav.usp_Verify;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then walk in:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;typescript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.\schemawalk.ps1 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Server . &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Database &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQLWORLD&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`w a s d` to move, &lt;br&gt;
`q e` to turn, &lt;br&gt;
`f` to follow the plate under your feet, &lt;br&gt;
`m` for the map, &lt;br&gt;
`/` to say something.&lt;/p&gt;
&lt;p&gt;`@district_by` decides what the quarters of the city are&lt;br&gt;
`facet` groups by what projects contain, &lt;br&gt;
`engine` by Unreal versus Blender versus Unity, &lt;br&gt;
`drive` by physical volume. Same data, three completely different cities.&lt;/p&gt;
&lt;p&gt;It runs at 70 to 120 frames per second on the full 4,546-room world, with the entire pipeline — visibility, projection, shading, string assembly — inside SQL Server. The client only forwards keystrokes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;## Back to the vellum&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I don’t think my problem was ever storage. I have the bytes. I have had the bytes, in some form, for thirty years, through several catastrophes and a lot of media formats that no longer exist.&lt;/p&gt;
&lt;p&gt;What I didn’t have was any way to stand in the middle of it and understand what I was looking at. And I suspect that’s the real archival problem for most people now. We solved &lt;em&gt;*keeping*&lt;/em&gt;. We did not solve &lt;em&gt;*comprehending*&lt;/em&gt;, and the gap between the two widens every year that storage gets cheaper.&lt;/p&gt;
&lt;p&gt;Vellum’s advantage was never really its longevity. It was that the reader and the medium were the same thing: you look at it, and you have it. Everything since has separated the two, and every layer we’ve added between the bytes and the understanding is another thing that can go obsolete.&lt;/p&gt;
&lt;p&gt;I can’t do much about that. But I can make a fifth of it into somewhere I can walk, look around, and notice something. The other sixty terabytes are next.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;— -&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;*Built with SQL Server, T-SQL, a filesystem scanner, and thirty years of not deleting anything.*&lt;/em&gt;&lt;/p&gt;
</content:encoded><category>SQL Server</category><category>Life</category></item><item><title>Running Doom Inside SQL Server</title><link>https://sqlartist.github.io/posts/running-doom-inside-sql-server/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/running-doom-inside-sql-server/</guid><description>Not a raycaster. Not a tribute. Actual Doom — real WAD, real BSP, real E1M1 — rendered by a relational database.</description><pubDate>Thu, 13 Aug 2026 15:47:46 GMT</pubDate><content:encoded>&lt;h2 id=&quot;appendix-runmd&quot;&gt;Appendix: RUN.md&lt;/h2&gt;
&lt;h2 id=&quot;running-doom-in-sqlserver&quot;&gt;Running Doom in SQL Server&lt;/h2&gt;
&lt;p&gt;Fourteen steps, in this order. Each owns a disjoint set of objects, so any one of them can be re-run on its own afterwards without disturbing the others.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;doom_schema.sql&lt;/code&gt; is NOT in the list: &lt;code&gt;E1M1_freedoom.sql&lt;/code&gt; already embeds it. Running it separately would drop the map data.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;markdown&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF;font-weight:bold&quot;&gt;# File                   Creates&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;1 E1M1_freedoom.sql      schema + E1M1 geometry + 158 textures&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;2 doom_render.sql        render_frame, sector_at, framebuffer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;3 doom_present.sql       frame_bmp, le4, screen_pixel, render_and_time&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;4 doom_game.sql          player, input_state, line_collide, &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                         p_tick, game_loop&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;5 doom_sprites.sql       sprite tables + render_sprites&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;6 E1M1_sprites.sql       sprite frames and columns&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;6b doom_sprites_fast.sql replaces render_sprites, adds thing_sector&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;7 doom_client.sql        p_frame, p_input_set&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;8 doom_doors.sql         door, p_use, p_door_tick; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                         takes over build_collision, &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                         move_blocked, p_frame&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;9 doom_sky.sql           render_sky; final p_frame &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                         (all later stages are OBJECT_ID-guarded, &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                         so nothing redefines it again)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;10 E1M1_sprites.sql      reload it: now 444 frames, &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                         including the weapon HUD sprites&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;11 doom_weapons.sql      inventory, pickups, firing, render_psprite&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;12 doom_statusbar.sql    hud_patch, hud_column, render_hud&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;13 hud.sql               37 status bar patches (map-independent)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i E1M1_freedoom&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i doom_render&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i doom_present&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i doom_game&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i doom_sprites&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i E1M1_sprites&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i doom_sprites_fast&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i doom_client&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i doom_doors&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i doom_sky&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i E1M1_sprites&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;      # reload: weapon sprites added&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i doom_weapons&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i doom_statusbar&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;sqlcmd -S . -d doom -i hud&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;doom_doors.sql&lt;/code&gt; must come after &lt;code&gt;doom_game.sql&lt;/code&gt; and &lt;code&gt;doom_client.sql&lt;/code&gt;: it redefines &lt;code&gt;build_collision&lt;/code&gt;, &lt;code&gt;move_blocked&lt;/code&gt; and &lt;code&gt;p_frame&lt;/code&gt;. &lt;br&gt;
Re-running either of those later reverts the world to static. After loading it, run &lt;code&gt;EXEC dbo.build_collision;&lt;/code&gt; — &lt;code&gt;line_collide&lt;/code&gt; now stores sector ids rather than cached opening heights, so doors can move without invalidating it.&lt;/p&gt;
&lt;p&gt;After &lt;code&gt;doom_sprites_fast.sql&lt;/code&gt;, run &lt;code&gt;EXEC dbo.build_thing_sector;&lt;/code&gt; once — it precomputes which sector each thing stands in, which keeps a scalar UDF out of the per-frame query.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;doom_sprites.sql&lt;/code&gt; creates the tables and DELETEs their contents, so &lt;code&gt;E1M1_sprites.sql&lt;/code&gt; must follow it. &lt;code&gt;p_frame&lt;/code&gt; calls &lt;code&gt;render_sprites&lt;/code&gt; only if it exists, so the game still runs without either.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Play&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;typescript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.\doom_client.ps1 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Server . &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;Database doom&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;W/S move, &lt;br&gt;
A/D turn, &lt;br&gt;
Q/E strafe, &lt;br&gt;
Shift run, &lt;br&gt;
SPACE open doors, &lt;br&gt;
CTRL fire, &lt;br&gt;
1–4 select weapon, &lt;br&gt;
R respawn, &lt;br&gt;
Esc quit.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;-Tics 12&lt;/code&gt; advances more simulation per displayed frame; &lt;code&gt;-Scale 4&lt;/code&gt; for a bigger window.&lt;/p&gt;
&lt;h2 id=&quot;healthcheck&quot;&gt;Healthcheck&lt;/h2&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;doom_healthcheck&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- optional but recommended&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;render_and_time&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;    &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- run twice; the first pays a ~780ms compile&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;render_and_time&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Expect roughly: &lt;code&gt;render_ms&lt;/code&gt; ~290, &lt;code&gt;present_ms&lt;/code&gt; ~35, and &lt;code&gt;pixels_lit&lt;/code&gt; close to 64,000 — with sky and the status bar in, the frame is fully covered.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;pixels_lit = 0&lt;/code&gt; means the texture tables are empty — the rasteriser INNER JOINs them, so it completes silently with no rows. Re-run &lt;code&gt;E1M1_freedoom.sql&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;other-maps&quot;&gt;Other maps&lt;/h2&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;python wad2sql&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.py&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FREEDOOM1&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.WAD&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; --list&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;python wad2sql&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.py&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FREEDOOM1&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.WAD&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; E1M3 -o E1M3&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;python gen_sprites&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.py&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; FREEDOOM1&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.WAD&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; E1M3 -o E1M3_sprites&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;.sql&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Sprite data is per-map: only the sprites that map’s things reference are extracted, plus the player’s weapons. The status bar graphics (&lt;code&gt;hud.sql&lt;/code&gt;) are map-independent and do not need regenerating.&lt;/p&gt;
&lt;p&gt;Needs &lt;code&gt;wad2sql.py&lt;/code&gt;, &lt;code&gt;wadtex.py&lt;/code&gt;, &lt;code&gt;wadsprite.py&lt;/code&gt;, &lt;code&gt;doom_schema.sql&lt;/code&gt; and &lt;code&gt;doom_textures.sql&lt;/code&gt; in the same directory. Works on any vanilla-format IWAD or PWAD; extended (ZDBSP-compressed) nodes are detected and rejected.&lt;/p&gt;
&lt;h2 id=&quot;known-gaps&quot;&gt;Known gaps&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;No monster AI: things are drawn, collide and can be shot, but nothing moves or fights back.&lt;/li&gt;
&lt;li&gt;Lifts, switches and walk-triggered lines: only manual (use) doors so far.&lt;/li&gt;
&lt;li&gt;Locked doors refuse: there is no key inventory yet.&lt;/li&gt;
&lt;li&gt;The status bar face is static; Doom’s reacts to damage and health.&lt;/li&gt;
&lt;li&gt;Masked middle textures on two-sided lines (grates, vines) aren’t drawn, though their alpha masks are stored.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;game_loop&lt;/code&gt; runs at ~12-15 tics/sec, not 35: &lt;code&gt;WAITFOR DELAY&lt;/code&gt; rounds up to SQL Server’s ~15.6ms timer resolution. The client’s &lt;code&gt;p_frame&lt;/code&gt; avoids this by batching tics per frame instead.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;Tested against FreeDoom (BSD-licensed) so the whole thing can be shared without redistributing commercial game data. It works with a retail&lt;/em&gt; &lt;code&gt;*DOOM.WAD*&lt;/code&gt; &lt;em&gt;too — same parser, same schema.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Sourcecode is now available:&lt;/em&gt; &lt;a href=&quot;https://github.com/sqlartist/DoomSQL&quot;&gt;https://github.com/sqlartist/DoomSQL&lt;/a&gt;&lt;/p&gt;
</content:encoded><category>SQL Server</category><category>Retro Computing</category></item><item><title>I Built a Language Model Entirely Inside SQL Server</title><link>https://sqlartist.github.io/posts/i-built-a-language-model-entirely-inside-sql-server/</link><guid isPermaLink="true">https://sqlartist.github.io/posts/i-built-a-language-model-entirely-inside-sql-server/</guid><description>No Python, no CLR, no web services — just tables, joins and a training loop in Transact-SQL, trained on the SQL you find on the internet.</description><pubDate>Sun, 09 Aug 2026 16:34:10 GMT</pubDate><content:encoded>&lt;p&gt;For the last 30 years I have known a single language — SQL. I never did the whole university Computer Science degree, I was hands on using Microsoft Excel 5.0 and then when my data was too large for 16,384 rows I started my journey into Microsoft SQL Server 6.0. Has it been a hindrance not being able to make apps over the data I was storing, of course but it also made me think in sets and I always think of performance the moment I write , not as some afterthought when the system is dying.&lt;/p&gt;
&lt;p&gt;Anyway this brings me to a little history and then the good stuff. Back in 1999 I was obsessed with unstructured data, and combining this with the structure in a SQL database had to be the holy grail. So I really got into Morphology, Semantics and Lexical analysis of unstructured data — think Word documents, Adobe PDFs or just plain HTML.&lt;/p&gt;
&lt;p&gt;I wrote a whole suite of SQL code that did the parsing into key-phrases and keywords using N-Grams, Algorithm processing using Term Frequency-Inverse Document Frequency (TF-IDF) and eventual display into a multi-dimensional structure (OLAP) which itself was displayed in near real time on a Call centre monitor (HOLAP with Zero Aggregations).&lt;/p&gt;
&lt;p&gt;Then I stopped for 27 years, until recently. I started hearing about LLMs and how they were changing the world, everyone out of a job because the code writes itself. Then I look into it and it’s a mess, releases every day and these strangely named models — YaLM 100B (Just like new stars, but there are so many of them they are just given a number, &lt;a href=&quot;https://en.wikipedia.org/wiki/HD_95086&quot; title=&quot;HD 95086&quot;&gt;HD 95086&lt;/a&gt;) given the strangest of names and no governance or even checks as to the source of the data. For someone that works in data for this long, suddenly the world has gone crazy, how on earth can you trust this stuff? You don’t know its source and to make decisions based on a version of the truth that an LLM produced that was superseded 3 times in a month by another LLM from a company with bigger pockets, which itself was superseded by a country with bigger pockets than the company…&lt;/p&gt;
&lt;p&gt;Which finally leads me onto why I am writing an article on using SQL to create, process, analyse and report on how an LLM works internally and you can see how the data moves between its networks and its final output. An interesting point is how many of my SQL friends around the world constantly amaze me with code that shouldn’t be written in SQL for whatever reason and they just nail it, sometimes even out performing the native language. Not bad for a language that is the same age as me.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_6WnalunLgl3qoPX3fQ6vAg.jpeg&quot; alt=&quot;The Joy Of Writing Code&quot;&gt;
&lt;em&gt;The Joy Of Writing Code&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Everyone knows a language model is matrix multiplication wearing a hat. Fewer people notice that matrix multiplication is just `GROUP BY` over a join, which means your database server has been quietly capable of this all along. So I built one: weights in tables, forward pass as a query, back propagation as a sequence of `UPDATE` statements. I trained it on a curated corpus of 122 idiomatic SQL queries, so the thing generates SQL.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;A language model written in SQL, trained on SQL, that emits SQL.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;**The Whole Model Is Five Lines of Algebra&lt;br&gt;
**I went with a Bengio-style neural language model rather than a transformer. It’s the transformer’s direct ancestor, and it’s small enough that every tensor fits comfortably in a table without any of it feeling like a stunt.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A Bengio-style neural language model, introduced by Yoshua Bengio and colleagues in 2003, is a feed forward architecture that predicts the next word in a sequence using a shared word embedding table and a multi-layer perceptron, overcoming the data sparsity limits of traditional n-gram models.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;My own work in this area was in 1999 with the TF-IDF algorithm and using this along with a semantic database called&lt;/em&gt; WordNet &lt;em&gt;to create structure from unstructured data but stopped due to a complete lack of interest from anyone except a fellow SQL Server MVP Tony Rogerson.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;But back to our main subject. Here’s the entire architecture. Context of C tokens, embedding lookup, concatenate, one dense layer with ReLU, project to the vocabulary, softmax:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;slot k of C holds token t_k&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;x[k*D + d] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; Emb[t_k, d] concatenated embeddings&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;z[h] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SUM_i x[i] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; W1[i,h] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; B1[h]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;a[h] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(z[h], &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) ReLU&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;logit[o] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SUM_h a[h] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; W2[h,o] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; B2[o]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;p[o] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(logit[o] — max) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(…) softmax&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Look at lines two and five. `SUM_i x[i] * W1[i,h]` is a sum of products, grouped by `h`. That’s not *like* a `GROUP BY` over a join. It **is** a `GROUP BY` over a join. Every line above becomes one CTE.&lt;/p&gt;
&lt;p&gt;Defaults are context 3, embedding dimension 16, hidden 32, vocabulary around 213 tokens. Roughly 12,000 parameters. Small, but genuinely learned rather than counted.&lt;br&gt;
Dimensions live in a config table rather than being hard-coded, so the model is re-sizable without editing a single function:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; Hyperparameters. One row. Every function joins to this instead&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; of hard-coding dimensions, so the model is resizable.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DROP&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IF&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; EXISTS&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ModelConfig&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#DCBDFB&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.ModelConfig&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; lock_col &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; PK_ModelConfig &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CONSTRAINT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; CK_ModelConfig_OneRow &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CHECK&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (lock_col &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ‘X’),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; C &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- context length, in tokens&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; D &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- embedding dimension per token&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; H &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- hidden units&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; V &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt; -- vocabulary size&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ModelConfig&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (lock_col, C, D, H, V) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (‘X’, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Tokenising SQL, In SQL&lt;/strong&gt;&lt;br&gt;
Before anything can be learned, the corpus has to be shredded into tokens. `COUNT(*)` needs to become three tokens, not one opaque blob, or the model never learns that parentheses have structure.&lt;/p&gt;
&lt;p&gt;The naive approach is a chain of `REPLACE` calls padding every punctuation character with spaces. That works right up until it meets `&amp;lt;&amp;gt;`, which the single-character pass happily shreds into `&amp;lt;` and `&amp;gt;`. Two tokens where there should be one, and the model spends its capacity learning that `&amp;lt;` is usually followed by `&amp;gt;`.&lt;/p&gt;
&lt;p&gt;The fix is to park the multi-character operators behind placeholders first, then restore them once the single-character pass is done:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; Normalisation. Lower-cases and separates punctuation so that&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; “COUNT(*)” becomes “count ( * )” — three tokens, not one blob.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;Multi-character operators (&amp;lt;&amp;gt;, &amp;gt;=, &amp;lt;=, !=) are parked behind&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; placeholders first, otherwise the single-character pass would&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; shred them into two tokens.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FUNCTION&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_Normalise&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@txt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(max))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;RETURNS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(max)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(max) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LOWER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@txt);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Park two-character operators.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@s,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’, N’~&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;~’), N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’, N’~&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;~’), N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’, N’~&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;~’), N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’, N’~&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;~’);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Pad single-character punctuation with spaces.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@s, N’(‘, N’ ( ‘);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@s, N’)’, N’ ) ‘);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@s, N’,’, N’ , ‘);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@s, N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’, N’ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ‘);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@s, N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’, N’ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ‘);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@s, N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’, N’ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ‘);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@s, N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’, N’ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ‘);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@s, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;39&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), N’ ‘ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NCHAR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;39&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; N’ ‘); &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- single quote&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; --Restore the two-character operators, now safely spaced.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@s,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; N’~&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;~’, N’ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ‘), N’~&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;~’, N’ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ‘), N’~&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;~’, N’ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ‘), N’~&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;~’, N’ &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ‘);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHILE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CHARINDEX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(N’  ‘, @s) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; REPLACE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@s, N’  ‘, N’ ‘);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;RETURN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LTRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;RTRIM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@s));&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Splitting on spaces is the easy half, but position matters — a language model without token order is just a bag of words. `STRING_SPLIT` only gained an ordinal in SQL Server 2022, which rules it out if you want this running on anything older. `OPENJSON` has always had one:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; Tokeniser. Splits on spaces and returns 1-based positions.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; OPENJSON is used rather than STRING_SPLIT because it yields an&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; ordinal on every supported version, not just 2022+.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FUNCTION&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_Tokenize&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@txt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(max))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;RETURNS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;RETURN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; pos &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; CAST&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(j.[key] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; int&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; token &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; OPENJSON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(N’[“‘ + REPLACE(dbo.fn_Normalise(@txt), N’ ‘, N’”,”’) + N’”]’) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; j&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; N’’;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Wrap the string in JSON array syntax, let `OPENJSON` do the splitting, and take `[key]` as the position. It’s a hack, but it’s a fast one and it works everywhere.&lt;/p&gt;
&lt;h3 id=&quot;randomness-is-harder-than-itlooks&quot;&gt;Randomness Is Harder Than It Looks&lt;/h3&gt;
&lt;p&gt;Weights start random. In SQL Server that’s a trap, because `RAND()` is evaluated once per statement, not once per row. Use it to initialise a weight table and you get several thousand identical values, a model with no symmetry to break, and a very confusing afternoon.&lt;/p&gt;
&lt;p&gt;`CHECKSUM(NEWID())` is evaluated per row, which is what you actually want. There’s a second trap hiding inside it: `ABS()` overflows on the single value `-2³¹`. Take the modulus first — `%` preserves the sign, so you get your uniform distribution either side of zero without needing `ABS()` at all:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; RAND() is constant for the whole statement, so it is useless for&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; filling a table. CHECKSUM(NEWID()) is evaluated per row.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; He initialisation for the ReLU layers: scale = sqrt(2/fan_in).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (hid, out_id, w)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; h&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CHECKSUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NEWID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;()) % &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1000001&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1000000&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @H)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Nums&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; n &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @H) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; h&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Vocab&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;**The Forward Pass Is One Query&lt;br&gt;
**Here’s the payoff. The entire inference path — embedding lookup, hidden layer, ReLU, output projection, softmax — as a single inline table-valued function. Five CTEs for five lines of algebra:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; fn_NextToken: the complete forward pass in one statement.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FUNCTION&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_NextToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@txt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(max))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;RETURNS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TABLE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;RETURN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; cfg &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; D &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ModelConfig&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* x : the concatenated embedding vector, length C*D */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; x &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; i &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;slot&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; cfg&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;D&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; val &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_ContextIds&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@txt) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; cfg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Emb&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* z, a : hidden pre-activation and ReLU activation */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hid&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; act &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;z&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;z&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hid&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, z &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;val&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; x &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w1 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;inp&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hid&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;B1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hid&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hid&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* logits : one per vocabulary entry. Driven from B2 with a LEFT JOIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; so that a fully dead hidden layer still yields a complete row set. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; lg &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;out_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; logit &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ISNULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;B2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; b&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; LEFT JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;out_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;act&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w2 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hid&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hid&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;act&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; w2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;out_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;out_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;out_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* softmax, with the usual max-subtraction for numerical safety */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ex &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; out_id, logit,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(logit — &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(logit) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ())&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; lg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; token_id &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;out_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; token &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; logit &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;logit&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ex&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Vocab&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ex&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;out_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Two details in there are load-bearing.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The `LEFT JOIN` driving the logits from `B2` rather than from the hidden layer looks like belt and braces. It isn’t. Filter on `a.act &amp;gt; 0` and join inwards, and a context that happens to kill every hidden unit produces zero rows — a softmax over nothing. Driving from the bias table guarantees a complete distribution whatever the activations do.&lt;/p&gt;
&lt;p&gt;The softmax is split across two scopes for a reason. The obvious one-liner is `SUM(EXP(x — MAX(x) OVER (…))) OVER (…)`, and SQL Server rejects it outright — a windowed function may not appear inside the argument of another windowed function. The max-subtraction and the normalising sum need separate CTE levels. I hit this in two places and it’s the sort of thing you only discover at `CREATE` time.&lt;/p&gt;
&lt;h3 id=&quot;back-propagation-and-the-order-thatmatters&quot;&gt;Back-propagation, And The Order That Matters&lt;/h3&gt;
&lt;p&gt;Training is where it stops being cute and starts being engineering. Here are the gradients, in the order they must be computed:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;dLogit[s,o] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (p[s,o] — &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;{o &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; target&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;[s]}) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; B&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;dW2[h,o] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SUM_s a[s,h] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; dLogit[s,o]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;dB2[o] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SUM_s dLogit[s,o]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;dZ[s,h] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (SUM_o dLogit[s,o] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; W2[h,o]) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;{z[s,h] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;dW1[i,h] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SUM_s x[s,i] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; dZ[s,h]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;dB1[h] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SUM_s dZ[s,h]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;dX[s,i] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SUM_h dZ[s,h] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; W1[i,h]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;dEmb[t,d] &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SUM &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;over&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; every (s,slot) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;where&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; context token &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t, of dX&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Read line four and line seven again. `dZ` needs `W2` and `dX` needs `W1` — and both need the values from *before* this batch’s update. Write the weights first and you’ll compute the backward pass against parameters that have already moved.&lt;/p&gt;
&lt;p&gt;The model still trains if you get this wrong. It just trains slowly, and silently wrongly, and you’ll spend a week blaming your learning rate. So both gradients are materialised into temp tables before either weight matrix is touched.&lt;/p&gt;
&lt;p&gt;The update itself is the part I enjoyed most. SGD with momentum is two assignments — `v ← m*v + g`, then `w ← w — lr*v` — and T-SQL evaluates every right-hand side in an `UPDATE` against pre-update row values. Which means both assignments land in a single statement, with no staging table and no ordering worry:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; SGD with momentum. Both assignments read pre-update values,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; which is exactly the semantics required.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; g &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hid&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;out_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, gr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;act&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #A &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #DL &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; d &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;seq_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;seq_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hid&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;out_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Momentum &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;gr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; — @curLr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@Momentum &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;gr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W2&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; g &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hid&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;hid&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;out_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;out_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The gradient for the embedding table is the fiddly one. `dX` comes back indexed by position in the concatenated input vector, so you have to unpick which context slot each index belonged to before you can scatter it onto the right token. Integer division and modulo do the job:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; Scatter dX back onto the embedding rows it came from.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; i / D recovers the context slot; i % D recovers the dimension.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; g &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, dim &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; % @D, gr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;grad&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #DX &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; dx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; #Ctx &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;seq_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;seq_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;slot&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @D&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dx&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; % @D&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Momentum &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;gr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; — @curLr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@Momentum &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;gr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Emb&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; t&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; g &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;The Bug That Cost Me The Most Time&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Not the calculus. A variable name.&lt;/p&gt;
&lt;p&gt;I’d declared `&lt;a href=&quot;http://twitter.com/b&quot; title=&quot;Twitter profile for @b&quot;&gt;@b&lt;/a&gt;` for the batch index and `&lt;a href=&quot;http://twitter.com/B&quot; title=&quot;Twitter profile for @B&quot;&gt;@B&lt;/a&gt;` for the batch row count, because that’s how the maths is written. SQL Server compares variable names case-insensitively, regardless of database collation, so those are the same variable. The `DECLARE` fails, every variable declared alongside them becomes unbound, and you get a screen of errors ending in a baffling complaint about a CTE forty lines further down.&lt;/p&gt;
&lt;p&gt;The same trap was sitting one line below: a local `&lt;a href=&quot;http://twitter.com/lr&quot; title=&quot;Twitter profile for @lr&quot;&gt;@lr&lt;/a&gt;` colliding with the `&lt;a href=&quot;http://twitter.com/Lr&quot; title=&quot;Twitter profile for @Lr&quot;&gt;@Lr&lt;/a&gt;` parameter. It hadn’t been reported yet only because the `DECLARE` never got that far.&lt;/p&gt;
&lt;p&gt;Worth internalising, because the error count tells you nothing. One bad `DECLARE` unbinds everything in it. Fix the first message and re-run rather than working down the list.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Does It Actually Work?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It does. 122 published SQL queries, 60 epochs, roughly two billion row operations:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_BEX-wypUkkr-IL-a8dDaNw.png&quot; alt=&quot;Model Training Performance&quot;&gt;
&lt;em&gt;Model Training Performance&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Perplexity of 2.9 over a 213-token vocabulary means that at each step it’s effectively choosing between about three candidates instead of 213. Prompt it and it produces recognisable SQL — `SELECT`, then a column list, then `FROM`, then a plausible table name.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_Generate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Prompt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;SELECT&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Temperature &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Samples &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_Generate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Prompt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;SELECT * FROM&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Greedy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_qpg32MXJf6WAW5nhRYZgPA.png&quot; alt=&quot;Result of usp_Generate procedure&quot;&gt;
&lt;em&gt;Result of usp_Generate procedure&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Two Things SQL Does Better Than Python&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I expected this to be a novelty. Two parts genuinely came out nicer than the equivalent imperative implementation, and both come from the same property: the model returns a *relation*.&lt;/p&gt;
&lt;p&gt;Because inference is a table-valued function, running a batch of prompts is `CROSS APPLY`. No loop, no padding, no batching logic — one tidy result set:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; Many prompts at once. The model is a table-valued function, so&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; CROSS APPLY runs a whole batch and the result is one relation.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; pr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;prompt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rank_pos &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; pr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;prompt&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; probability &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; FORMAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, ‘P1’)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; orders &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INNER JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; customers c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ranked &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (‘),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (N’&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; employees &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;’)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; ) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; pr(prompt)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) token, p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_NextToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;pr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;prompt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; nt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; pr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;prompt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;prompt                         rank_pos             token                          probability&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;------------------------------ -------------------- ------------------------------ ------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INNER JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; customers c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;      1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    o                              &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;43&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INNER JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; customers c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;      2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    p                              &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INNER JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; customers c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;      3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    c                              &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;INNER JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; customers c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;      4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    country                        &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;                         1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;                              30&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;                         2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    customer_id                    &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;                         3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    o                              &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;                         4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    c                              &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;                  1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    customers                      &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;29&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;                  2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    products                       &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;                  3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    employees                      &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;21&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;                  4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    orders                         &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; orders GR &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    customer_id                    &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;55&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; orders GR &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    category_id                    &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; orders GR &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    c                              &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; orders GR &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    country                        &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; employees &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    salary                         &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;47&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; employees &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    department_id                  &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; employees &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                    product_id                     &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; employees &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           4&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;                    &apos;                              3.2%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;WITH ranked AS (               1                    select                         84.3%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;WITH ranked AS (               2                    1                              8.8%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;WITH ranked AS (               3                    10                             1.2%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;WITH ranked AS (               4                    50                             0.7%&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The second one is better still. Constrained decoding — forcing generation to obey a grammar — is a genuinely awkward feature to bolt onto a normal inference stack. Here it’s a `WHERE` clause and a renormalising window function. `WHERE` is applied before window functions, so the arithmetic just works out:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  fn_Score runs the forward pass at every position at once and&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  returns the probability the model gave to the token that&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  actually appeared. High surprisal marks the spots where the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  query departs from what internet SQL usually looks like.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  position, token,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        probability    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; FORMAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(p, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;P2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        surprisal_bits &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(surprisal, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_Score&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT customer_id, COUNT(*) FROM orders GROUP BY customer_id;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; position;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_m94l6NnIL4YPATC1McgZGQ.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;The interesting part is the shape: &lt;code&gt;FROM&lt;/code&gt; after a column list will be near-certain, the table name after &lt;code&gt;FROM&lt;/code&gt; much less so.&lt;/p&gt;
&lt;p&gt;There’s a third benefit that isn’t about queries at all. Nothing is hidden in a binary blob. The trained model is rows, so it can be backed up, diffed, code-reviewed, version-controlled, and shipped by `INSERT`. Cosine similarity between token embeddings is a `GROUP BY` — and run it, and you’ll find table names cluster with table names and aggregates cluster with aggregates. Nobody told it those categories exist.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_H9_9ENhXU_TzwmA9ikGIwQ.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_sPE8m15zKRgCozbRK7YAjg.png&quot; alt=&quot;sum does return count and avg&quot;&gt;
&lt;em&gt;sum does return count and avg&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Constrained Decoding&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  QUERY 9 -- Constrained decoding.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  Because the distribution arrives as a rowset, constraining generation to a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  grammar is a WHERE clause plus a renormalisation window. No special decoder&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  is needed. Here: after FROM, only allow known table names.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  token,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        p_raw        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; FORMAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(p, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;P3&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        p_constrained&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; FORMAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(p) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (), &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;P1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_NextToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT * FROM&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   token &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;customers&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;orders&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;products&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;employees&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;                  N&apos;payments&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;departments&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;categories&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;https://sqlartist.github.io/images/medium/1_BdlMAL58xhWkYryCQJp6Qg.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark-dimmed&quot; style=&quot;background-color:#22272e;color:#adbac7; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  A SMALL LANGUAGE MODEL, ENTIRELY INSIDE SQL SERVER&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  File 04 of 04 : Sampling procedure and example queries against the model&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  Everything below treats the language model as what it now is: a set of&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  tables, and a function that returns a probability distribution as a rowset.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  That means the usual toolkit -- TOP, WHERE, GROUP BY, CROSS APPLY, window&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  functions -- applies to the model itself, not just to its training data.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;USE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; SqlLlm;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOCOUNT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  SAMPLER&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  Autoregressive decoding needs a loop, because each step depends on the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  previous one, and a recursive CTE may not call a table-valued function on&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  its recursive member. So this is the one part of the system that is&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  procedural rather than set-based.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  The context is recovered by re-tokenising the accumulated text each step.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  That is O(n) per token rather than O(1), but n is a few dozen tokens, and&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  it keeps the state in one place.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ALTER&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PROCEDURE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_Generate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @Prompt      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(max) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;select&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @MaxTokens   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @Temperature &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- &amp;lt; 1 sharpens, &amp;gt; 1 flattens&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @TopK        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,     &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- sample only from the k most likely tokens&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @Greedy      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;bit&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,     &lt;/span&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- 1 = always take the argmax (deterministic)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    @Samples     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;   =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SET&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOCOUNT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @out &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;TABLE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (sample_no &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;generated&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(max), tokens &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @txt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(max),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @i   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @tok &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            @r   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHILE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Samples&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @txt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_Normalise&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@Prompt);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @i   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        WHILE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @i &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @MaxTokens&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @tok &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Greedy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Temperature &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;05&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) @tok &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; token&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_NextToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@txt)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            END&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            ELSE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            BEGIN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; RAND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;CHECKSUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;NEWID&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;()));&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                ;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; topk &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@TopK) token, p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_NextToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@txt)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                ),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                tempered &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; token, q &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; POWER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(p, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Temperature) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; topk&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                ),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                normed &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; token, q &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; q &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; NULLIF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(q) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; tempered&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                ),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                cumulative &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; token,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                           hi &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(q) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; q &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ROWS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; UNBOUNDED&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; PRECEDING&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   normed&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;                )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) @tok &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; token&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   cumulative&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  hi &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @r&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; hi;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;                -- floating-point tail guard&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @tok &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                    SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) @tok &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; token &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_NextToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@txt) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            IF&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @tok &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @tok &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;&amp;lt;/s&amp;gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BREAK&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @txt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @txt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @tok;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @i &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        INSERT INTO&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @out (sample_no, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;generated&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, tokens)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@s, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_Detokenise&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(@txt), @i);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SET&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @s &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; sample_no, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;generated&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, tokens &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @out &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; sample_no;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  QUERY 1 -- The model card.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  How big is this thing, and what did it read?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  context_tokens &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; C,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        embed_dim      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; D,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        hidden_units   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; H,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        vocab_size     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; V,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        total_parameters &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; V&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;D &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (C&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;D)&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;H &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; H &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; H&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;V &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; V&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ModelConfig&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  tensor &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Emb (token embeddings)&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, parameters &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Emb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UNION ALL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;W1 (input -&amp;gt; hidden)&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,  &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UNION ALL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;B1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,                    &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;B1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UNION ALL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;W2 (hidden -&amp;gt; vocab)&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,  &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UNION ALL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;B2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,                    &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;B2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; parameters &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  source_site, queries &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Corpus&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; source_site&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; queries &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  QUERY 2 -- Next-token distribution.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  The core inference call. Ask the model what comes after a prefix.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        token,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        probability &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; FORMAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(p, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;P2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        logit       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(logit, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_NextToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT * FROM&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- How confident is it? Shannon entropy of the same distribution, in bits.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  entropy_bits &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LOG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(p) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LOG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        uniform_bits &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  LOG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; V &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ModelConfig&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LOG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_NextToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT * FROM&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  QUERY 3 -- Many prompts at once.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  This is the part that is genuinely nicer in SQL than in an imperative&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  language: the model is a table-valued function, so CROSS APPLY runs a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  whole batch of prompts and the result is one tidy relation.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  pr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;prompt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        rank_pos &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;PARTITION&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; pr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;prompt&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;        nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        probability &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; FORMAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;P1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT * FROM&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT customer_id,&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT COUNT(*) FROM orders GROUP BY&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT * FROM customers WHERE&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;INNER JOIN customers c ON&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;WITH ranked AS (&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;UPDATE employees SET&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        ) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; pr(prompt)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) token, p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_NextToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;pr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;prompt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;        ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; nt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; pr&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;prompt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nt&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  QUERY 4 -- Generation.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  Deterministic first, then sampled at three temperatures.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_Generate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Prompt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;SELECT * FROM&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Greedy &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @MaxTokens &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 40&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_Generate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Prompt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;SELECT&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,        @Temperature &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Samples &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_Generate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Prompt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;SELECT&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,        @Temperature &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Samples &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_Generate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Prompt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;SELECT&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,        @Temperature &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Samples &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_Generate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Prompt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;WITH monthly AS (&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,            @Temperature &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Samples &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;usp_Generate&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @Prompt &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;SELECT c.customer_name, COUNT(&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Temperature &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, @Samples &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  QUERY 5 -- Scoring.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  fn_Score returns, per token, the probability the model assigned to the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  token that actually appeared. High surprisal marks the spots where the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  query departs from what internet SQL usually looks like.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  position, token,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        probability   &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; FORMAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(p, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;P2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        surprisal_bits&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(surprisal, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_Score&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT customer_id, COUNT(*) FROM orders GROUP BY customer_id;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; position;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Typical query versus deliberately odd query, side by side.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        tokens      &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        avg_bits    &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;surprisal&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        perplexity  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;log_p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;idiomatic&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,  &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT * FROM customers WHERE country = &apos;&apos;germany&apos;&apos;;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;idiomatic&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,  &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT category_id, AVG(price) FROM products GROUP BY category_id;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;unusual&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,    &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT GROUP BY customers price WHERE FROM ;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;unusual&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,    &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;DELETE products SET orders JOIN AVG ( 3 ;&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        ) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; q(label, sql_text)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_Score&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sql_text&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;q&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;sql_text&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; perplexity;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  QUERY 6 -- Perplexity leaderboard over the training corpus.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  Which published queries does the model find most and least predictable?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  The worst-scoring rows are the ones whose patterns appear only once, which&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  makes this a serviceable outlier detector for a query log.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; scored &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;doc_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;source_site&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;query_text&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            tokens     &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            perplexity &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; EXP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;log_p&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Corpus&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_Score&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;query_text&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;doc_id&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;source_site&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;query_text&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  band &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; CASE&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; THEN&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;most predictable&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ELSE&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;least predictable&apos;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        query_text, tokens, perplexity &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(perplexity, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, rn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; perplexity),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;              rd &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; perplexity &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; scored&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; x&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rn &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; OR&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; rd &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 8&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; perplexity;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  QUERY 7 -- What did the embeddings learn?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  Cosine similarity between token vectors. Restricted to reasonably frequent&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  tokens, because a token seen twice has an embedding that barely moved from&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  its random initialisation.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  Expect table names to cluster with table names, and aggregate functions to&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  cluster with aggregate functions -- the model was never told that these&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  categories exist.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @probe &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;customers&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; probe &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Emb&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Vocab&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @probe&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;pnorm &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; nrm &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; probe)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;        v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;freq&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        cosine &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; probe&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                       /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;pnorm&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nrm&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Emb&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    probe &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; probe&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Vocab&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; pnorm&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;freq&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 8&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;  AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @probe&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;freq&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; cosine &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- The same probe, run over several tokens at once.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  probe&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; probe_token, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nn&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; neighbour, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nn&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;cosine&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;    (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;customers&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;sum&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;where&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;inner&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;group&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;            AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; probe(token)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; APPLY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;           v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;           cosine &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; pe&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                          /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;pn&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nrm&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Emb&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Vocab&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Emb&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Vocab&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v2 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;           WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  v2&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; probe&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; pe &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; pe&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; nrm &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Emb&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Vocab&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v3 &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  v3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; probe&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; pn&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;freq&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; probe&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; cosine &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; nn&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; probe&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nn&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;cosine&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  QUERY 8 -- Vector arithmetic on the embedding table.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;      vec(&apos;orders&apos;) - vec(&apos;order_id&apos;) + vec(&apos;customer_id&apos;)  ~=  ?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  On a corpus this small the result is noisy, and it is honest to say so;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  the point is that the arithmetic is a GROUP BY over a 16-column table.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @a &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;orders&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        @b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;order_id&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        @c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; N&apos;customer_id&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; target&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    SELECT&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;  e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;            w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CASE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @a &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @b &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;THEN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; WHEN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; @c &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;THEN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; END&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Emb&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Vocab&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@a, @b, @c)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;tnorm &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; nrm &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; w)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; target&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;        v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        cosine &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; target&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;                       /&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SQRT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;tnorm&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;nrm&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Emb&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;    target&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; target&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Vocab&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;CROSS JOIN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; tnorm&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;   v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;freq&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; &amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AND&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; NOT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (@a, @b, @c)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; cosine &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  QUERY 9 -- Constrained decoding.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  Because the distribution arrives as a rowset, constraining generation to a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  grammar is a WHERE clause plus a renormalisation window. No special decoder&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  is needed. Here: after FROM, only allow known table names.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  token,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        p_raw        &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; FORMAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(p, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;P3&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        p_constrained&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; FORMAT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; SUM&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(p) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (), &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;&apos;P1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;fn_NextToken&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;SELECT * FROM&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   token &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;IN&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;customers&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;orders&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;products&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;employees&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;                  N&apos;payments&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;departments&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt;N&apos;categories&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  QUERY 10 -- Training diagnostics.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  epoch, avg_loss &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(avg_loss, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        perplexity &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(perplexity, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        lr &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(lr, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), elapsed_ms&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TrainLog&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; epoch;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Loss reduction per epoch, as a window function over the log.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  epoch,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        perplexity  &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(perplexity, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;        delta       &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(perplexity &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; LAG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(perplexity) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;OVER&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; epoch), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;TrainLog&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; epoch &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- Weight magnitudes. A hidden unit whose W2 row is near zero has stopped&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;-- contributing; a very negative B1 usually means a dead ReLU.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  tensor &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;W1&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, mean_abs &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(w)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), max_abs &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(w)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UNION ALL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;W2&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;,  &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(w)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(w)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;W2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;UNION ALL&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; SELECT&lt;/span&gt;&lt;span style=&quot;color:#96D0FF&quot;&gt; &apos;Emb&apos;&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;AVG&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(w)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;ABS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(w)), &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Emb&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;  dead_ish_hidden_units &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; COUNT&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;B1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;   w &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;/*==============================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  QUERY 11 -- The whole model, as data.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  Nothing here is hidden in a binary blob. This is the entire trained model,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;  and it can be backed up, diffed, version-controlled, or shipped by INSERT.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;==============================================================================*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; TOP&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;weight&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; ROUND&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;w&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Emb&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; e&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;    dbo&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;Vocab&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt; v &lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;span style=&quot;color:#F47067&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;token_id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#768390&quot;&gt;--WHERE   v.token = N&apos;select&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;ORDER BY&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#6CB6FF&quot;&gt;dim&lt;/span&gt;&lt;span style=&quot;color:#ADBAC7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F47067&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Where It Falls Over&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;I’d rather say this plainly than oversell it.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;A three-token context window means it has learned local SQL *syntax*, not SQL *semantics*. It’ll cheerfully open a `WITH` clause and never close it, or emit `WHERE order_id = ‘london’`. It has no idea what a table is.&lt;/p&gt;
&lt;p&gt;122 training queries is a very small corpus, so it memorises templates as much as it generalises. Embedding neighbours are meaningful for frequent tokens and close to noise for rare ones, whose vectors have barely moved from initialisation.&lt;/p&gt;
&lt;p&gt;And autoregressive sampling stays stubbornly procedural. Each token depends on the last, and a recursive CTE can’t call a table-valued function on its recursive member. That one loop is the only imperative code in the whole system.&lt;/p&gt;
&lt;h2 id=&quot;the-point&quot;&gt;The Point&lt;/h2&gt;
&lt;p&gt;This isn’t how you should serve a language model. It’s a demonstration that the gap between “database engine” and “machine learning framework” is narrower than the tooling implies. Both are doing sums over sets. One of them just has better marketing.&lt;/p&gt;
&lt;p&gt;If you work with SQL every day, building one of these will teach you more about what a language model actually does than any number of tutorials with a `&lt;code&gt;model.fit()`&lt;/code&gt; in them. There’s nowhere to hide. Every matrix multiply is a join you wrote yourself.&lt;/p&gt;
&lt;p&gt;There’s a detail here I didn’t notice until I’d finished writing the code. In 1999 I was doing n-grams and TF-IDF in T-SQL, and I stopped because nobody was interested. The wall I’d have hit next is &lt;em&gt;data sparsity&lt;/em&gt; — n-grams can only count what they’ve already seen, and most sequences they never see at all.&lt;/p&gt;
&lt;p&gt;Bengio’s paper is the answer to exactly that problem. It was published in 2003. I put the work down four years too early.&lt;/p&gt;
&lt;p&gt;So this isn’t a departure from what I was doing back then. It’s the next page of it, in the same language, twenty-seven years later. I write Python when the job needs it. I’ve never needed a second language for the part I actually care about.&lt;/p&gt;
&lt;p&gt;The full scripts run on SQL Server 2016 or later, and on Azure SQL. Four files: schema and corpus, model and forward pass, training, example queries. They can be ported in principle to PostgreSQL though the tokeniser and temp tables need rewriting.&lt;/p&gt;
&lt;p&gt;I would suggest running the code from the scripts rather than copy/paste from this article as the Medium publishing tool replaces characters that are needed. I think I caught them all but the files have been run and tested.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://drive.google.com/drive/folders/1BGKPr8nkRhQmrKZPmFr49MmPDvi2QL4k?usp=sharing&quot;&gt;https://drive.google.com/drive/folders/1BGKPr8nkRhQmrKZPmFr49MmPDvi2QL4k?usp=sharing&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;**If this was useful, a few claps help other people find it. Follow me for more on SQL as a computational medium — I keep finding things it can do that it probably shouldn’t.**&lt;/p&gt;
&lt;p&gt;*What’s the strangest thing you’ve built inside a database? I’d genuinely like to know — leave a comment.*&lt;/p&gt;
</content:encoded><category>SQL Server</category><category>AI &amp; Data Science</category></item></channel></rss>