<?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: Script optimization - Group by in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519097#M37101</link>
    <description>&lt;P&gt;Well, I guess I got your point now. Try like:&lt;/P&gt;&lt;PRE&gt;[WorkplaceStateHistory]:
Load
[workplace],
imputationDate as [Keydate],
[stateType],
SUM(Interval([endDate]-[startDate],'hh:mm:ss')) as [Duration]
&lt;STRONG&gt;group by workplace, stateType, imputationDate;&lt;/STRONG&gt;
Select
"workplace",
"startDate",
"stateType",
"endDate",
"imputationDate"
FROM "Serv"."dbo"."WorkplaceStateHistory" ;&lt;/PRE&gt;</description>
    <pubDate>Tue, 11 Dec 2018 09:40:35 GMT</pubDate>
    <dc:creator>tresB</dc:creator>
    <dc:date>2018-12-11T09:40:35Z</dc:date>
    <item>
      <title>Script optimization - Group by</title>
      <link>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519055#M37096</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm using this code for now, and it works just fine :&lt;/P&gt;&lt;P&gt;[WorkplaceStateHistoryTemp]:&lt;BR /&gt;SQL SELECT&lt;BR /&gt;"workplace",&lt;BR /&gt;"startDate",&lt;BR /&gt;"stateType",&lt;BR /&gt;"endDate",&lt;BR /&gt;"imputationDate" as [Keydate]&lt;BR /&gt;FROM "Serv"."dbo"."WorkplaceStateHistory";&lt;/P&gt;&lt;P&gt;[WorkplaceStateHistory]:&lt;BR /&gt;Load&lt;BR /&gt;[workplace],&lt;BR /&gt;Date([Keydate]) as [Keydate],&lt;BR /&gt;[stateType],&lt;BR /&gt;Sum(Interval([endDate]-[startDate],'hh:mm:ss')) as [Duration]&lt;BR /&gt;Resident [WorkplaceStateHistoryTemp]&lt;BR /&gt;group by workplace, stateType, [Keydate];&lt;BR /&gt;Drop table [WorkplaceStateHistoryTemp];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the loading time is huge, since I'm loading a massive database THEN using it again as a resident table before dropping it.&lt;/P&gt;&lt;P&gt;I found this way of doing the loading that saves me 20% of loading time, but I can't figure put how to use the group by:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[WorkplaceStateHistory]:&lt;BR /&gt;Load&lt;BR /&gt;[workplace],&lt;BR /&gt;imputationDate as [Keydate],&lt;BR /&gt;[stateType],&lt;BR /&gt;SUM(Interval([endDate]-[startDate],'hh:mm:ss')) as [Duration];&lt;BR /&gt;Select&lt;BR /&gt;"workplace",&lt;BR /&gt;"startDate",&lt;BR /&gt;"stateType",&lt;BR /&gt;"endDate",&lt;BR /&gt;"imputationDate"&lt;BR /&gt;FROM "Serv"."dbo"."WorkplaceStateHistory"&lt;BR /&gt;group by workplace, stateType, imputation;&lt;/P&gt;&lt;P&gt;How am I suppose to do the group by in the second solution ? Is there even a faster way to get what I'm doing ?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 09:01:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519055#M37096</guid>
      <dc:creator>Antoine</dc:creator>
      <dc:date>2018-12-11T09:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Script optimization - Group by</title>
      <link>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519072#M37097</link>
      <description>&lt;P&gt;One alternative way &lt;STRONG&gt;you can try&lt;/STRONG&gt; using sorting the table in resident load before grouping them, like suggested here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/t5/QlikView-Documents/Optimize-Group-By-Performance/ta-p/1481470/show-comments/true" target="_self"&gt;Optimize-Group-By-Performance&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 09:22:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519072#M37097</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2018-12-11T09:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Script optimization - Group by</title>
      <link>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519081#M37098</link>
      <description>&lt;P&gt;It's worth a try, thanks!&lt;/P&gt;&lt;P&gt;But that means there's no way to do a group by without going for a resident table ?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 09:27:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519081#M37098</guid>
      <dc:creator>Antoine</dc:creator>
      <dc:date>2018-12-11T09:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Script optimization - Group by</title>
      <link>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519085#M37099</link>
      <description>I guess we are talking about better way, right? You can always use group by in the first load and resident load is not necessary for that.</description>
      <pubDate>Tue, 11 Dec 2018 09:30:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519085#M37099</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2018-12-11T09:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Script optimization - Group by</title>
      <link>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519091#M37100</link>
      <description>&lt;P&gt;Ok, so what's wrong in this script:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[WorkplaceStateHistory]:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Load&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[workplace],&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;imputationDate as [Keydate],&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[stateType],&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SUM(Interval([endDate]-[startDate],'hh:mm:ss')) as [Duration];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Select&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"workplace",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"startDate",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"stateType",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"endDate",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"imputationDate"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FROM "Serv"."dbo"."WorkplaceStateHistory"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;group by workplace, stateType, imputationDate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It sends me back an error message:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Connector reply error: SQL##f - SqlState: 37000, ErrorCode: 8120, ErrorMsg: [Microsoft][ODBC SQL Server Driver][SQL Server]Column 'Serv.dbo.WorkplaceStateHistory.startDate' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 09:34:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519091#M37100</guid>
      <dc:creator>Antoine</dc:creator>
      <dc:date>2018-12-11T09:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Script optimization - Group by</title>
      <link>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519097#M37101</link>
      <description>&lt;P&gt;Well, I guess I got your point now. Try like:&lt;/P&gt;&lt;PRE&gt;[WorkplaceStateHistory]:
Load
[workplace],
imputationDate as [Keydate],
[stateType],
SUM(Interval([endDate]-[startDate],'hh:mm:ss')) as [Duration]
&lt;STRONG&gt;group by workplace, stateType, imputationDate;&lt;/STRONG&gt;
Select
"workplace",
"startDate",
"stateType",
"endDate",
"imputationDate"
FROM "Serv"."dbo"."WorkplaceStateHistory" ;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Dec 2018 09:40:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519097#M37101</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2018-12-11T09:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Script optimization - Group by</title>
      <link>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519110#M37102</link>
      <description>&lt;P&gt;Works perfectly!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still struggling on how to order THEN group by, but I will probably get it soon.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 09:51:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-optimization-Group-by/m-p/1519110#M37102</guid>
      <dc:creator>Antoine</dc:creator>
      <dc:date>2018-12-11T09:51:14Z</dc:date>
    </item>
  </channel>
</rss>

