<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: COUNT() in SQL Script not Working in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062523#M641710</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Quite often it's helpful to make your transformations within qlikview and not within the sql-part which will be executed by the database, see: &lt;A href="https://community.qlik.com/qlik-blogpost/2972"&gt;Preceding Load&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 06 Feb 2016 08:06:45 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2016-02-06T08:06:45Z</dc:date>
    <item>
      <title>COUNT() in SQL Script not Working</title>
      <link>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062521#M641707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi There, I'm trying to figure out what I may be doing wrong with a Qlik file that seeks to perform counts in a temp table via SQL. The script is longer than what I have posted below, but I'm able to get this to return results in a different query application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I add it into my qlikView document, it doesn't throw an error, but it also doesn't return results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been able to narrow it down to the COUNT() function, but I don't understand exactly WHY this isn't working in qlikView... is it a reserved keyword it's not compiling properly, or something else?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT ROW_NUMBER() OVER(PARTITION BY t.Record_ID ORDER BY t.Order_Placed) AS rowNumb,&lt;/P&gt;&lt;P&gt;&amp;nbsp; t.Record_ID,&lt;/P&gt;&lt;P&gt;&amp;nbsp; t.Order_Shipped,&lt;/P&gt;&lt;P&gt;&amp;nbsp; t.Value&lt;/P&gt;&lt;P&gt;INTO #treatmentSummary&lt;/P&gt;&lt;P&gt;FROM #treatments AS t&lt;/P&gt;&lt;P&gt;WHERE t.Section_Field_Name = 'Scheduled Treatment #'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT d.Record_ID&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: #ff0000;"&gt;, COUNT(ts.RowNumb) OVER(PARTITION BY d.Record_ID) as No_of_Orders &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;INTO #temp_orderCount&lt;/P&gt;&lt;P&gt;FROM #Data AS d&lt;/P&gt;&lt;P&gt;&amp;nbsp; LEFT JOIN #treatmentSummary AS ts&lt;/P&gt;&lt;P&gt;&amp;nbsp; ON d.Record_ID = ts.Record_ID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i replace the above red text with&lt;/P&gt;&lt;P&gt;, 1 as No_of_Orders&lt;/P&gt;&lt;P&gt;the code runs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know there are some dependent tables missing in the above queries, but does anyone know why this is happening, and how I might be able to get around it? Thanks in advance for your insight!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Feb 2016 18:34:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062521#M641707</guid>
      <dc:creator />
      <dc:date>2016-02-05T18:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: COUNT() in SQL Script not Working</title>
      <link>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062522#M641709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't use your already loaded table on other SQL statement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you executing any procedure in Qlikview ? Please share your script ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Feb 2016 21:42:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062522#M641709</guid>
      <dc:creator />
      <dc:date>2016-02-05T21:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: COUNT() in SQL Script not Working</title>
      <link>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062523#M641710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Quite often it's helpful to make your transformations within qlikview and not within the sql-part which will be executed by the database, see: &lt;A href="https://community.qlik.com/qlik-blogpost/2972"&gt;Preceding Load&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Feb 2016 08:06:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062523#M641710</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2016-02-06T08:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: COUNT() in SQL Script not Working</title>
      <link>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062524#M641713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Marcus; I'm not sure that will be possible in this case. The temp table has a lot of dependencies to other elements in the SQL script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I figured out a workaround for this instance, but I'm still just trying to understand WHY this wouldn't work in Qlik. Count() is a pretty common function; why wouldn't Qlik be able to handle it within the SQL code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2016 18:38:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062524#M641713</guid>
      <dc:creator />
      <dc:date>2016-02-08T18:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: COUNT() in SQL Script not Working</title>
      <link>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062525#M641715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Dathu, and sorry if I'm being unclear. This is all being handled in SQL code, of which COUNT() is a valid function. I'm not 100% sure what you mean by "executing procedures in Qlik", but the entirety of the SQL code is being executed in Qlik via an OLEDB connection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script itself should be fine; it executes in other querying tools like Management Studio; I'm trying to understand why it doesn't execute in Qlik while not throwing any errors.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2016 18:43:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062525#M641715</guid>
      <dc:creator />
      <dc:date>2016-02-08T18:43:18Z</dc:date>
    </item>
    <item>
      <title>Re: COUNT() in SQL Script not Working</title>
      <link>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062526#M641717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It hasn't anything to do with qlikview if a sql-statement didn't worked then qlikview don't execute the sql - the order is the following: qlikview connects to your database and gives the sql-statement to the odbc/oledb-driver which communicate between database and qlikview which will only return the result of the query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case it could be that your odbc/oledb isn't appropriate for your database respectively to your kind of sql-statement - many driver provides only old standard-sql and not quite new and/or specialized sql-features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2016 19:43:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062526#M641717</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2016-02-08T19:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: COUNT() in SQL Script not Working</title>
      <link>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062527#M641718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Regarding this statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;SELECT d.Record_ID&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-family: inherit; color: #ff0000;"&gt;, COUNT(ts.RowNumb) OVER(PARTITION BY d.Record_ID) as No_of_Orders&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;INTO #temp_orderCount&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;FROM #Data AS d&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;&amp;nbsp; LEFT JOIN #treatmentSummary AS ts&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;&amp;nbsp; ON d.Record_ID = ts.Record_ID&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;I would check if the 2 # tables have data before this statement and if the left join between the 2 tables gives some result.&lt;/P&gt;&lt;P&gt;I would check what happens removing the INTO .......; do you get some rows in Qlik?&lt;/P&gt;&lt;P&gt;Also, maybe you can replace the COUNT....OVER with a group by?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2016 20:05:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/COUNT-in-SQL-Script-not-Working/m-p/1062527#M641718</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2016-02-08T20:05:36Z</dc:date>
    </item>
  </channel>
</rss>

