<?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: SQL Calculated Where-Condition / EXEC SQL in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-calculated-where-condition-exec-sql/m-p/322685#M4909</link>
    <description>&lt;P&gt;If you are connecting to MS SQL server using native SQL:&lt;/P&gt;&lt;P&gt;EXEC SQL&lt;/P&gt;&lt;P&gt;SELECT QUANTITY FROM MY_TABLE WHERE DATEPART(weekday,DATE)=1&lt;/P&gt;&lt;P&gt;ENDEXEC&lt;/P&gt;</description>
    <pubDate>Fri, 21 Oct 2016 12:50:19 GMT</pubDate>
    <dc:creator>former_member186338</dc:creator>
    <dc:date>2016-10-21T12:50:19Z</dc:date>
    <item>
      <title>SQL Calculated Where-Condition / EXEC SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-calculated-where-condition-exec-sql/m-p/322682#M4906</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I would
like to select database table entries with a calculated condition.&lt;/P&gt;&lt;P&gt;An content example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SITE DATE        QUANTITY UNIT_OF_MEASURE
1000 12.10.10216 3        PCE
1010 13.10.10216 5        PCE
1010 16.10.10216 8        PCE
1020 18.10.10216 4        PCE
1420 19.10.10216 1        PCE
---&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The where-condition should be defined in that way, that only entries will be selected
with weekday eq &amp;lt;weekday&amp;gt;, e.g weekday is sunday&lt;/P&gt;&lt;P&gt;Is it
possible to formulate a where-condition using EXEC SQL in that way?&lt;/P&gt;&lt;P&gt;Can it be implemented by a stored procedure?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM MY_TABLE
WHERE calculate_weekdey(DATE) EQ 1. (1 = Sunday, 2 = Monday, etc.)
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you
for your reply.&lt;/P&gt;&lt;P&gt;Best
regards,&lt;/P&gt;&lt;P&gt;Kurt&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 15:36:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-calculated-where-condition-exec-sql/m-p/322682#M4906</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-10-20T15:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Calculated Where-Condition / EXEC SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-calculated-where-condition-exec-sql/m-p/322683#M4907</link>
      <description>&lt;P&gt;hi Kurt,&lt;/P&gt;&lt;P&gt;Do you have access to CDS and or AMDP in your environment?&lt;/P&gt;&lt;P&gt;The following link has some good examples of relevant sqlscript functions for AMDP usage.&lt;/P&gt;&lt;P&gt;&lt;A href="https://blogs.sap.com/2016/06/23/valuable-sqlscript-functions-for-use-in-amdps/" target="test_blank"&gt;https://blogs.sap.com/2016/06/23/valuable-sqlscript-functions-for-use-in-amdps/&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Select posting_date, day_number, sum(day_number)
From (  Select map(dayname(posting_date),'MONDAY',1,
  'TUESDAY',2,
  'WEDNESDAY',3,
  'THURSDAY',4,
  'FRIDAY',5,
  'SATURDAY',6,
  '7'
   ) as day_number,
   posting_date
  From crmd_orderadm_h
  Where created_at &amp;gt;= to_dats(add_days(current_date, -7))||replace(to_time(current_timestamp),':','')
  )
Group by posting_date, day_number
order by 2&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Above example of using a converting the columns during select, you can then apply a filter outside of Select if you so wished.&lt;/P&gt;&lt;P&gt;You can also create defined functions that could do the same thing in SQLScript, but it's hard to know what implementation would suit unless you tell us what env you are working in.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sean.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 12:24:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-calculated-where-condition-exec-sql/m-p/322683#M4907</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-10-21T12:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Calculated Where-Condition / EXEC SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-calculated-where-condition-exec-sql/m-p/322684#M4908</link>
      <description>&lt;P&gt;What SQL server you are talking about?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 12:27:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-calculated-where-condition-exec-sql/m-p/322684#M4908</guid>
      <dc:creator>former_member186338</dc:creator>
      <dc:date>2016-10-21T12:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Calculated Where-Condition / EXEC SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-calculated-where-condition-exec-sql/m-p/322685#M4909</link>
      <description>&lt;P&gt;If you are connecting to MS SQL server using native SQL:&lt;/P&gt;&lt;P&gt;EXEC SQL&lt;/P&gt;&lt;P&gt;SELECT QUANTITY FROM MY_TABLE WHERE DATEPART(weekday,DATE)=1&lt;/P&gt;&lt;P&gt;ENDEXEC&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 12:50:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-calculated-where-condition-exec-sql/m-p/322685#M4909</guid>
      <dc:creator>former_member186338</dc:creator>
      <dc:date>2016-10-21T12:50:19Z</dc:date>
    </item>
  </channel>
</rss>

