SELECT TOP with multiple UNION and with ORDER BY
<p>I want to select the latest records from the DB in SQL Server. If only <strong>one item</strong> is selected the final output is this:</p>

<pre><code>SELECT TOP(10) * from dbo.Eventos WHERE Tipo LIKE '%OS%' AND Distrito LIKE '%' 
</code></pre>

<p>+ always added at the end:</p>

<pre><code>ORDER BY Data DESC
</code></pre>

<p><strong>NOTE</strong>: <code>Distrito LIKE '%'</code> must stay as it sometimes is programatically changed to something other than <code>%</code>.</p>

<p>If there are more items selected, the query gets one <code>UNION</code> line <em>added programatically for each item</em>. At the end, the <code>ORDER BY</code>is added as always. Example with all 4 items checked:</p>

<pre><code>SELECT TOP(10) * from dbo.Eventos WHERE Tipo LIKE '%OS%' AND Distrito LIKE '%' 
UNION ALL SELECT TOP(10) * from dbo.Eventos WHERE Tipo LIKE '%Rad%' AND Distrito LIKE '%' 
UNION ALL SELECT TOP(10) * from dbo.Eventos WHERE Tipo LIKE '%Aci%' AND Distrito LIKE '%'
UNION ALL SELECT TOP(10) * from dbo.Eventos WHERE Tipo LIKE '%Out%' AND Distrito LIKE '%' 
ORDER BY Data DESC
</code></pre>

<p>But this gives me the <strong>OLDEST</strong> 10 results for each <code>WHERE</code> clause sorted <code>BY Data DESC</code>. </p>

<p>How can i get the <strong>NEWEST</strong> X results for each item (<code>WHERE</code>)?</p>