<?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 SAL HANA SQL Query question in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sal-hana-sql-query-question/m-p/12577310#M2009020</link>
    <description>&lt;P&gt;HI all&lt;/P&gt;
  &lt;P&gt;i have code for Some Monthly sales analysis Report.&lt;/P&gt;
  &lt;P&gt;i seen this on &lt;/P&gt;
  &lt;P&gt;&lt;A href="https://www.asug.com/insights/b1-useful-queries-comparing-sap-business-one-sales-across-years"&gt;Useful SAP Business One Queries: Comparing Monthly Sales Across Multiple Years - ASUG&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;but some point reason this code is not working&lt;/P&gt;
  &lt;P&gt;seems getdata is strange&lt;/P&gt;
  &lt;P&gt;do you guys and ladies know how to fix it?&lt;/P&gt;
  &lt;P&gt;SELECT T0."CardCode", T0."CardName",&lt;/P&gt;
  &lt;P&gt;(SUM(T1."Debit") - sum(T1."Credit")) AS "2017",&lt;/P&gt;
  &lt;P&gt;((SUM(T1."Debit") - sum(T1."Credit"))/12) AS "2017Average Sales",&lt;/P&gt;
  &lt;P&gt;(SUM(T2."Debit") - sum(T2."Credit")) AS "2018",&lt;/P&gt;
  &lt;P&gt;((SUM(T2."Debit") - sum(T2."Credit"))/Month(GETDATE()))AS "2018 Average Sales" &lt;/P&gt;
  &lt;P&gt;FROM OCRD T0 &lt;/P&gt;
  &lt;P&gt;LEFT JOIN JDT1 T1&lt;/P&gt;
  &lt;P&gt; ON T1."ShortName" = T0."CardCode"&lt;/P&gt;
  &lt;P&gt;AND YEAR(T1."DueDate") =2017 AND T1."TransType" in('13','14')&lt;/P&gt;
  &lt;P&gt;LEFT JOIN JDT1 T2 ON T2."ShortName" = T0."CardCode" AND Year(T2."DueDate") = 2018&lt;/P&gt;
  &lt;P&gt;AND T2."TransType" in ('13','14') &lt;/P&gt;
  &lt;P&gt;WHERE T0."CardType" = 'C' &lt;/P&gt;
  &lt;P&gt;GROUP BY T0."CardCode", T0."CardName"&lt;/P&gt;</description>
    <pubDate>Mon, 05 Sep 2022 05:05:33 GMT</pubDate>
    <dc:creator>former_member820000</dc:creator>
    <dc:date>2022-09-05T05:05:33Z</dc:date>
    <item>
      <title>SAL HANA SQL Query question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sal-hana-sql-query-question/m-p/12577310#M2009020</link>
      <description>&lt;P&gt;HI all&lt;/P&gt;
  &lt;P&gt;i have code for Some Monthly sales analysis Report.&lt;/P&gt;
  &lt;P&gt;i seen this on &lt;/P&gt;
  &lt;P&gt;&lt;A href="https://www.asug.com/insights/b1-useful-queries-comparing-sap-business-one-sales-across-years"&gt;Useful SAP Business One Queries: Comparing Monthly Sales Across Multiple Years - ASUG&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;but some point reason this code is not working&lt;/P&gt;
  &lt;P&gt;seems getdata is strange&lt;/P&gt;
  &lt;P&gt;do you guys and ladies know how to fix it?&lt;/P&gt;
  &lt;P&gt;SELECT T0."CardCode", T0."CardName",&lt;/P&gt;
  &lt;P&gt;(SUM(T1."Debit") - sum(T1."Credit")) AS "2017",&lt;/P&gt;
  &lt;P&gt;((SUM(T1."Debit") - sum(T1."Credit"))/12) AS "2017Average Sales",&lt;/P&gt;
  &lt;P&gt;(SUM(T2."Debit") - sum(T2."Credit")) AS "2018",&lt;/P&gt;
  &lt;P&gt;((SUM(T2."Debit") - sum(T2."Credit"))/Month(GETDATE()))AS "2018 Average Sales" &lt;/P&gt;
  &lt;P&gt;FROM OCRD T0 &lt;/P&gt;
  &lt;P&gt;LEFT JOIN JDT1 T1&lt;/P&gt;
  &lt;P&gt; ON T1."ShortName" = T0."CardCode"&lt;/P&gt;
  &lt;P&gt;AND YEAR(T1."DueDate") =2017 AND T1."TransType" in('13','14')&lt;/P&gt;
  &lt;P&gt;LEFT JOIN JDT1 T2 ON T2."ShortName" = T0."CardCode" AND Year(T2."DueDate") = 2018&lt;/P&gt;
  &lt;P&gt;AND T2."TransType" in ('13','14') &lt;/P&gt;
  &lt;P&gt;WHERE T0."CardType" = 'C' &lt;/P&gt;
  &lt;P&gt;GROUP BY T0."CardCode", T0."CardName"&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 05:05:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sal-hana-sql-query-question/m-p/12577310#M2009020</guid>
      <dc:creator>former_member820000</dc:creator>
      <dc:date>2022-09-05T05:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAL HANA SQL Query question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sal-hana-sql-query-question/m-p/12577311#M2009021</link>
      <description>&lt;P&gt;I understand you have an SAP HANA database. An example you share is for the MS SQL Server database (as stated as well in the article you linked).&lt;/P&gt;&lt;P&gt;If I got it right then the equivalent of &lt;A href="https://docs.microsoft.com/ru-ru/sql/t-sql/functions/getdate-transact-sql?view=sql-server-ver16" target="_blank"&gt;GetDate&lt;/A&gt; from MS SQL should be &lt;A href="https://help.sap.com/docs/HANA_SERVICE_CF/7c78579ce9b14a669c1f3295b0d8ca16/20ddfe5d75191014af50837e2818462d.html" target="_blank"&gt;CURRENT_DATE&lt;/A&gt; in HANA.&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 10:27:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sal-hana-sql-query-question/m-p/12577311#M2009021</guid>
      <dc:creator>Vitaliy-R</dc:creator>
      <dc:date>2022-09-06T10:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAL HANA SQL Query question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sal-hana-sql-query-question/m-p/12577312#M2009022</link>
      <description>&lt;P&gt;I tried but seems still error&lt;/P&gt;&lt;P&gt;i'm really beginner so i don't know how to solve this&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2090906-image.png" /&gt;&lt;/P&gt;&lt;P&gt;SELECT T0."CardCode", T0."CardName",&lt;/P&gt;&lt;P&gt;(SUM(T1."Debit") - sum(T1."Credit")) AS "2017",&lt;/P&gt;&lt;P&gt;((SUM(T1."Debit") - sum(T1."Credit"))/12) AS "2017Average Sales",&lt;/P&gt;&lt;P&gt;(SUM(T2."Debit") - sum(T2."Credit")) AS "2018",&lt;/P&gt;&lt;P&gt;((SUM(T2."Debit") - sum(T2."Credit"))/Month(CURRENT_DATE())) AS "2018 Average Sales" &lt;/P&gt;&lt;P&gt;FROM &lt;/P&gt;&lt;P&gt;OCRD T0 &lt;/P&gt;&lt;P&gt;LEFT JOIN JDT1 T1&lt;/P&gt;&lt;P&gt; ON T1."ShortName" = T0."CardCode"&lt;/P&gt;&lt;P&gt;AND YEAR(T1."DueDate") =2017 AND T1."TransType" in('13','14')&lt;/P&gt;&lt;P&gt;LEFT JOIN JDT1 T2 ON T2."ShortName" = T0."CardCode" AND Year(T2."DueDate") = 2018&lt;/P&gt;&lt;P&gt;AND T2."TransType" in ('13','14') WHERE T0."CardType" = 'C' GROUP BY T0."CardCode", T0."CardName"&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 02:52:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sal-hana-sql-query-question/m-p/12577312#M2009022</guid>
      <dc:creator>former_member820000</dc:creator>
      <dc:date>2022-09-07T02:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAL HANA SQL Query question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sal-hana-sql-query-question/m-p/12577313#M2009023</link>
      <description>&lt;P&gt;CURRENT_DATE is a function, but it does not require () at the end. Try that.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 15:50:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sal-hana-sql-query-question/m-p/12577313#M2009023</guid>
      <dc:creator>Vitaliy-R</dc:creator>
      <dc:date>2022-09-08T15:50:57Z</dc:date>
    </item>
  </channel>
</rss>

