<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="http://orourke.tv/web/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>orourke.tv - tech-notes:sql</title>
        <description>every banana has 5 sides</description>
        <link>http://orourke.tv/web/</link>
        <lastBuildDate>Thu, 06 Aug 2026 12:01:33 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>http://orourke.tv/web/lib/exe/fetch.php?media=wiki:dokuwiki.svg</url>
            <title>orourke.tv</title>
            <link>http://orourke.tv/web/</link>
        </image>
        <item>
            <title>index</title>
            <link>http://orourke.tv/web/doku.php?id=tech-notes:sql:index&amp;rev=1566293564&amp;do=diff</link>
            <description>SQL Indexing

SQL Query should use index seeks and not index scans.

* &lt;https://www.red-gate.com/simple-talk/sql/performance/identifying-and-solving-index-scan-problems/&gt;

	* You can select the &#039;Display Estimated Execution Plan&#039; (4 to the right of the &#039;! Execute&#039; button).
	* You can select &#039;Include Actual Execution Plan&#039; (7 to the left of the &#039;! Execute&#039; button), so see exactly how the SQL was run, after you execute it.</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Tue, 20 Aug 2019 09:32:44 +0000</pubDate>
        </item>
        <item>
            <title>pivot</title>
            <link>http://orourke.tv/web/doku.php?id=tech-notes:sql:pivot&amp;rev=1663849288&amp;do=diff</link>
            <description>SQL Pivots

Reference: &lt;https://www.sqlservertutorial.net/sql-server-basics/sql-server-pivot/&gt;

An Example

The First Step is to get the Table in the format you need - so you can pivot it.

Our Original Table


SELECT     
CollectionID = CC.CollectionID, 
TransferCallType = TransferCallType,
SUM(ISNULL(CTRT.RouterCallsQNow, 0)) AS CallsQueuedNow

FROM        
dbo.Call_Type_Real_Time(nolock) AS CTRT 
INNER JOIN dbo.v_Collection_Calltypes AS CC WITH (nolock) ON CTRT.CallTypeID = CC.CallTypeID

GRO…</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Thu, 22 Sep 2022 12:21:28 +0000</pubDate>
        </item>
    </channel>
</rss>
