<?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: Scripting a SQL sum() in QV Load in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629891#M678986</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So this will differ in one case to the other. But basically the method was:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Run the SQL in QVD alone without LOAD&lt;/LI&gt;&lt;LI&gt;CTRL-T and Locate the generated field name&lt;/LI&gt;&lt;LI&gt;Add the generated name (and any other names) to your LOAD.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So step 1:&lt;/P&gt;&lt;P&gt;Run the script:&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL SELECT&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;Field1,&amp;nbsp; Field2,&amp;nbsp; Field3,&amp;nbsp; "Field4, sum(Field5)&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;&lt;SPAN style="font-family: inherit; line-height: 1.5em; font-weight: inherit; font-style: inherit; font-size: 10pt;"&gt;FROM &lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5em;"&gt;Table1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;WHERE&amp;nbsp; Field1 = 'test query'&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;GROUP BY &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Field1,&amp;nbsp; Field2, Field3,&amp;nbsp; Field4&lt;/SPAN&gt; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step 2:&lt;/P&gt;&lt;P&gt;CTRL-T to find what the Database returned as a field name for "sum(Field5)"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step 3:&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;LOAD&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;[Field1] as [FirstField],&amp;nbsp; [Field2] as [SecondField],&amp;nbsp; [Field3] as [ThirdField],&amp;nbsp; [Field4] as [FourthField], 00012 as [SumOfFifthField];&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL SELECT&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4", sum("Field5") as Count5&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;FROM &lt;/SPAN&gt;Table1&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;WHERE&amp;nbsp; Field1 = 'test query'&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;GROUP BY &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Field1,&amp;nbsp; Field2, Field3,&amp;nbsp; Field4&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in this case 00012 was given by the database to the sum() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NB: The queries and loads above are written by hand (not my actuals) because my actual is WAY too complex to point out the exact solve (50 lines of SQL), but this should tell you the story.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I actually replicated that logic for a count() I had in another tab of my script, and works there too! excellent thought process by &lt;A href="https://community.qlik.com/qlik-users/10670"&gt;Massimo Grossi&lt;/A&gt; (grazie mille)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 May 2014 22:32:42 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-05-27T22:32:42Z</dc:date>
    <item>
      <title>Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629874#M678957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello folks!&lt;/P&gt;&lt;P&gt;A QV newbie here!&lt;/P&gt;&lt;P&gt;I want to load a GIANT dataset into QV and to make it very simple I want to use a SQL sum() in my statement to cut down on returned rows (since i'll sum them anyway).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically I want to Load this:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SELECT&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Field 1,&amp;nbsp; Field 2,&amp;nbsp; Field 3,&amp;nbsp; Field 4, sum(Field5) as Count5&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;FROM&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Table1&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;WHERE&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;...&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;GROUP BY &lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;...&lt;/P&gt;&lt;P&gt;I figured this would be done by saying:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Table:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Load&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;[Field 1] as [FirstField],&amp;nbsp; [Field 2] as [SecondField],&amp;nbsp; [Field 3] as [ThirdField],&amp;nbsp; [Field 4] [FourthField], Count5 as [CountOfFifthField]&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;Now:&lt;/P&gt;&lt;P&gt;The SQL on it's own works and gives me exactly what I need in a SQL edito&lt;/P&gt;&lt;P&gt;The SQL without "sum(Field5) as Count5" works in QV.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But once I add "sum(Field5) as Count5" to my SQL in QV, it complains that: Field not found &amp;lt;Count5&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I add that Sum() to my SQL so I do it in SQL rather than part of the Load statement itself (the bottleneck is pulling the data)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: &lt;SPAN style="color: #545454; font-family: arial, sans-serif; font-size: small;"&gt;RDBMS is DB2, and the SQL above is pretty fake.. but pretty accurate structure wise (there's a LOT of joins in there &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:07:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629874#M678957</guid>
      <dc:creator />
      <dc:date>2014-05-27T19:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629875#M678958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try to start with the simpler statement, no LOAD, no as&lt;/P&gt;&lt;P&gt;does it works?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SQL&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;SELECT&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Field 1,&amp;nbsp; Field 2,&amp;nbsp; Field 3,&amp;nbsp; Field 4, sum(Field5)&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;FROM&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Table1&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;WHERE&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;...&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;GROUP BY&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;...;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:27:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629875#M678958</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-05-27T19:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629876#M678959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not sure I understand... Are you saying that &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ODBC CONNECT TO &amp;lt;DB2_Data_Source&amp;gt; ;&lt;/P&gt;&lt;P&gt;SQL SELECT &lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4", sum("Field5") as Count5&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;FROM &lt;/SPAN&gt;Table1&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;WHERE&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;GROUP BY &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4"&lt;/SPAN&gt; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;doesn't work in QlikView? If the connect string is OK and the fields exist, I see no reason why it shouldn't.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HIC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:33:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629876#M678959</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2014-05-27T19:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629877#M678961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My Mistake, I would've been more clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm saying this works:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;ODBC CONNECT TO &amp;lt;DB2_Data_Source&amp;gt; ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;SQL SELECT&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4", sum("Field5") as Count5&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;FROM &lt;/SPAN&gt;Table1&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;WHERE&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;GROUP BY &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4"&lt;/SPAN&gt; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;But this doesn't:&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;ODBC CONNECT TO &amp;lt;DB2_Data_Source&amp;gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Table:&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Load&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;[Field 1] as [FirstField],&amp;nbsp; [Field 2] as [SecondField],&amp;nbsp; [Field 3] as [ThirdField],&amp;nbsp; [Field 4] [FourthField], Count5 as [CountOfFifthField]&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL SELECT&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4", sum("Field5") as Count5&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;FROM &lt;/SPAN&gt;Table1&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;WHERE&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;GROUP BY &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4"&lt;/SPAN&gt; ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:37:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629877#M678961</guid>
      <dc:creator />
      <dc:date>2014-05-27T19:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629878#M678962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No load and no as works, sample data was loaded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think my issue is that in the LOAD portion I can't "rename" &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;sum(Field5)&lt;/SPAN&gt;, so i thought i'd give it a SQL alias. So that's why I added the SQL as&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:39:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629878#M678962</guid>
      <dc:creator />
      <dc:date>2014-05-27T19:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629879#M678964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 14.0pt; font-family: 'Times New Roman','serif'; color: black;"&gt;14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="text-decoration: underline;"&gt;To Connect a database using JDBC&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="text-decoration: underline;"&gt;&lt;SPAN lang="EN-US" style="font-size: 14.0pt; font-family: 'Times New Roman','serif'; color: black;"&gt; &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 14.0pt; font-family: 'Times New Roman','serif'; color: black;"&gt;Program:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;import java.sql.*;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;import java.lang.*;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;public class Db{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; public static void main(String[] args) {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; System.out.println("display result");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; Connection con = null;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; try{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; Class.forName("com.mysql.jdbc.Driver");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; con = DriverManager.getConnection("jdbc:mysql://localhost:3306/felistas","root","");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt; try{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; String sql = "select * from t1";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; Statement st = con.createStatement();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt; ResultSet rs=st.executeQuery(sql);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; System.out.println("result are!");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; while(rs.next())&lt;/SPAN&gt;&lt;/P&gt;&lt;OL style="list-style-type: upper-alpha;"&gt;&lt;LI&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;System.out.println(rs.getString("name")+"\t"+rs.getString("regno"));&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; con.close();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; } catch (SQLException s){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; System.out.println("SQL statement is not executed!");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; catch (Exception e){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; e.printStackTrace();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:43:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629879#M678964</guid>
      <dc:creator />
      <dc:date>2014-05-27T19:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629880#M678965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe its a typo, but an as is missing between [Field4] and [FourthField]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eduardo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:44:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629880#M678965</guid>
      <dc:creator>eduardo_sommer</dc:creator>
      <dc:date>2014-05-27T19:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629881#M678967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no true &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:45:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629881#M678967</guid>
      <dc:creator />
      <dc:date>2014-05-27T19:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629882#M678972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use jdbc&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;ODBC CONNECT TO &amp;lt;DB2_Data_Source&amp;gt; ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;SQL SELECT&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4", sum("Field5") as Count5&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;FROM &lt;/SPAN&gt;Table1&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;WHERE&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;GROUP BY &lt;SPAN style="font-style: inherit; font-family: inherit;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4"&lt;/SPAN&gt; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;But this doesn't:&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-style: inherit;"&gt;ODBC CONNECT TO &amp;lt;DB2_Data_Source&amp;gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Table:&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Load&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;[Field 1] as [FirstField],&amp;nbsp; [Field 2] as [SecondField],&amp;nbsp; [Field 3] as [ThirdField],&amp;nbsp; [Field 4] [FourthField], Count5 as [CountOfFifthField]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL SELECT&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4", sum("Field5") as Count5&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;FROM &lt;/SPAN&gt;Table1&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;WHERE&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;GROUP BY &lt;SPAN style="font-style: inherit; font-family: inherit;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4"&lt;/SPAN&gt; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;not sql&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:46:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629882#M678972</guid>
      <dc:creator />
      <dc:date>2014-05-27T19:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629883#M678973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can rename sum(Field5) in the LOAD portion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[sum(Field5)] as ......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:48:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629883#M678973</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-05-27T19:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629884#M678974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes, an as is there, it's a typo in here (i manually typed the example)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:49:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629884#M678974</guid>
      <dc:creator />
      <dc:date>2014-05-27T19:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629885#M678976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems you put count statement twice for the load statement use it only once and try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;ODBC CONNECT TO &amp;lt;DB2_Data_Source&amp;gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Table:&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Load&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;[Field 1] as [FirstField],&amp;nbsp; [Field 2] as [SecondField],&amp;nbsp; [Field 3] as [ThirdField],&amp;nbsp; [Field 4] as [FourthField], &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;Field5&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; as [CountOfFifthField]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL SELECT&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4", &lt;STRONG&gt;sum("Field5") as &lt;/STRONG&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;Field5&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;FROM &lt;/SPAN&gt;Table1&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;WHERE&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;GROUP BY &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4"&lt;/SPAN&gt; ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:49:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629885#M678976</guid>
      <dc:creator>its_anandrjs</dc:creator>
      <dc:date>2014-05-27T19:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629886#M678980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;I think that got me a bit closer! now it says that fieldisn't found:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Field not found - &amp;lt;sum(MCAQRYLIB.MPC_MBFINL.BWMEID05)&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 19:54:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629886#M678980</guid>
      <dc:creator />
      <dc:date>2014-05-27T19:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629887#M678982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if you load without LOAD, just sql select&lt;/P&gt;&lt;P&gt;and then CTRL-T (table viewer) I suppose you can see all field (upper/lower case)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then, using these field names you add the LOAD section&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 20:00:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629887#M678982</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-05-27T20:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629888#M678983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Isn't there a semicolon missing at the end of the preceding load?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Load&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;[Field 1] as [FirstField],&amp;nbsp; [Field 2] as [SecondField],&amp;nbsp; [Field 3] as [ThirdField],&amp;nbsp; [Field 4] &lt;SPAN style="; color: #ff0000; font-size: 12pt;"&gt;&lt;STRONG&gt;as&lt;/STRONG&gt;&lt;/SPAN&gt; [FourthField], Count5 as [CountOfFifthField]&amp;nbsp; &lt;SPAN style="color: #ff0000; font-size: 18pt;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL SELECT&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4", sum("Field5") as Count5&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;FROM &lt;/SPAN&gt;Table1&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;WHERE&amp;nbsp; ...&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;GROUP BY &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4"&lt;/SPAN&gt; ;&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;regards&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 21:27:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629888#M678983</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2014-05-27T21:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629889#M678984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;BINGO!!! you got it!&lt;/P&gt;&lt;P&gt;So the logic is, for "generated" fields I need to fetch the field name the database generates and then rename that in my LOAD!&lt;/P&gt;&lt;P&gt;THANK YOU!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 21:45:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629889#M678984</guid>
      <dc:creator />
      <dc:date>2014-05-27T21:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629890#M678985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can you please post the generated LOAD/SELECT for us to learn the changes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 21:51:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629890#M678985</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2014-05-27T21:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting a SQL sum() in QV Load</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629891#M678986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So this will differ in one case to the other. But basically the method was:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Run the SQL in QVD alone without LOAD&lt;/LI&gt;&lt;LI&gt;CTRL-T and Locate the generated field name&lt;/LI&gt;&lt;LI&gt;Add the generated name (and any other names) to your LOAD.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So step 1:&lt;/P&gt;&lt;P&gt;Run the script:&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL SELECT&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;Field1,&amp;nbsp; Field2,&amp;nbsp; Field3,&amp;nbsp; "Field4, sum(Field5)&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;&lt;SPAN style="font-family: inherit; line-height: 1.5em; font-weight: inherit; font-style: inherit; font-size: 10pt;"&gt;FROM &lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5em;"&gt;Table1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;WHERE&amp;nbsp; Field1 = 'test query'&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;GROUP BY &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Field1,&amp;nbsp; Field2, Field3,&amp;nbsp; Field4&lt;/SPAN&gt; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step 2:&lt;/P&gt;&lt;P&gt;CTRL-T to find what the Database returned as a field name for "sum(Field5)"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step 3:&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;LOAD&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;[Field1] as [FirstField],&amp;nbsp; [Field2] as [SecondField],&amp;nbsp; [Field3] as [ThirdField],&amp;nbsp; [Field4] as [FourthField], 00012 as [SumOfFifthField];&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL SELECT&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;"Field 1",&amp;nbsp; "Field 2",&amp;nbsp; "Field 3",&amp;nbsp; "Field 4", sum("Field5") as Count5&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;FROM &lt;/SPAN&gt;Table1&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;WHERE&amp;nbsp; Field1 = 'test query'&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f6f6f6;"&gt;GROUP BY &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Field1,&amp;nbsp; Field2, Field3,&amp;nbsp; Field4&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in this case 00012 was given by the database to the sum() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NB: The queries and loads above are written by hand (not my actuals) because my actual is WAY too complex to point out the exact solve (50 lines of SQL), but this should tell you the story.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I actually replicated that logic for a count() I had in another tab of my script, and works there too! excellent thought process by &lt;A href="https://community.qlik.com/qlik-users/10670"&gt;Massimo Grossi&lt;/A&gt; (grazie mille)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 22:32:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-a-SQL-sum-in-QV-Load/m-p/629891#M678986</guid>
      <dc:creator />
      <dc:date>2014-05-27T22:32:42Z</dc:date>
    </item>
  </channel>
</rss>

