<?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: How to Translate JMP-where-clause from data filter to SQL-where-clause in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/84846#M37984</link>
    <description>&lt;P&gt;Hey Eric,&lt;/P&gt;&lt;P&gt;thanks for the quick response, it helped,&lt;/P&gt;&lt;P&gt;and Query Builder has some very nice features. So I will look, where to use.&lt;/P&gt;&lt;P&gt;I could save the query with defined joins,&lt;/P&gt;&lt;P&gt;and use it again.&lt;/P&gt;&lt;P&gt;But a kind of filter of tables (stopping and saving Query at joining step) was not possible,&lt;/P&gt;&lt;P&gt;and I found not the possibility to connect filters with AND instead of OR.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Georg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Dec 2018 10:04:12 GMT</pubDate>
    <dc:creator>Georg</dc:creator>
    <dc:date>2018-12-03T10:04:12Z</dc:date>
    <item>
      <title>How to Translate JMP-where-clause from data filter to SQL-where-clause</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/80249#M36900</link>
      <description>&lt;P&gt;Dear Community,&lt;/P&gt;&lt;P&gt;I'd like to use the data filter object to let users filter some data to be queried from Oracle database via SQL.&lt;/P&gt;&lt;P&gt;So I extracted a small part from data into a JMP table,&lt;/P&gt;&lt;P&gt;and put a data filter over it.&lt;/P&gt;&lt;P&gt;From Data Filter I can extract the where clause,&lt;/P&gt;&lt;P&gt;it may look as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Select Where(
	(:PC == "A_PROCESS" | :PC == "C_PROCESS" | :PC == "D_PROCESS") &amp;amp; :TC == "01"
	 &amp;amp; (:POS &amp;gt;= 25 &amp;amp; :POS &amp;lt;= 126)
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I would like to transfer this into an SQL Where-Clause like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;where 
PC in ("A_PROCESS", "C_PROCESS", "D_PROCESS")
and TC == "01"
and POS between 25 and 126&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I'm not so familiar with text processing,&lt;/P&gt;&lt;P&gt;is there an easy way how to do this in JMP,&lt;/P&gt;&lt;P&gt;especially how to disassemble the JMP-where-clause (that may be more complex than only concatenated And's),&lt;/P&gt;&lt;P&gt;and to re-assemble it in an SQL-where-clause?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any hint, best regards,&lt;/P&gt;&lt;P&gt;Georg&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:52:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/80249#M36900</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2018-10-24T14:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to Translate JMP-where-clause from data filter to SQL-where-clause</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/82349#M37127</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;meanwhile I solved the issue. I realized, my script has not to understand the JMP-where clause, but simply should translate it to a working SQL-where&amp;nbsp;clause.&lt;/P&gt;&lt;P&gt;So here is an example JSL for doing this.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Example for translating a JMP-where-clause from e.g. Data Filter to a SQL-where-clause
JMP_where_clause =
"Select Where(
	(:PC == \!"A_PROCESS\!" | :PC == \!"C_PROCESS\!" | :PC == \!"D_PROCESS\!") &amp;amp; :TC == \!"01\!"
	 &amp;amp; (:POS &amp;gt;= 25 &amp;amp; :POS &amp;lt;= 126)
)";

	jmp2sql_where = Function( {jmp_where}, 
	// remove "Select Where()" from the string
		df_list = Regex Match( jmp_where, "Select Where\((.*)\)" );
	// replace JMP keywords by SQL keywords
		sql_where = "AND " || Substitute( df_list[2], "\!"", "'", "==", "=", ":", "CZIM.", "&amp;amp;", "AND", "|", "OR" );
		Return( sql_where );
	);
	sql_where = jmp2sql_where( JMP_where_clause);

show(sql_where);&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And the result is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;sql_where = "AND 
	(CZIM.PC = 'A_PROCESS' OR CZIM.PC = 'C_PROCESS' OR CZIM.PC = 'D_PROCESS') AND CZIM.TC = '01'
	 AND (CZIM.POS &amp;gt;= 25 AND CZIM.POS &amp;lt;= 126)
";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Georg&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 09:32:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/82349#M37127</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2018-11-02T09:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to Translate JMP-where-clause from data filter to SQL-where-clause</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/82518#M37186</link>
      <description>&lt;P&gt;Hey, Georg,&lt;/P&gt;
&lt;P&gt;Have you looked at Query Builder at all in JMP?&amp;nbsp; File &amp;gt; Database &amp;gt; Query Builder.&amp;nbsp; It allows you to build queries interactively against ODBC data sources, including filtering, included filters that prompt, and then you can either run the queries interactively or use them in JSL.&amp;nbsp; It's a lot less time-consuming than writing your own SQL by hand for most people (but if you want to write your own SQL to use with Query Builder, that is also an option).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Eric&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2018 12:49:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/82518#M37186</guid>
      <dc:creator>Eric_Hill</dc:creator>
      <dc:date>2018-11-05T12:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Translate JMP-where-clause from data filter to SQL-where-clause</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/83937#M37710</link>
      <description>&lt;P&gt;Hey Eric,&lt;/P&gt;&lt;P&gt;thanks for your answer, yes, I had a look at Query Builder.&lt;/P&gt;&lt;P&gt;I use the Query Builder in several scripts etc., but I always do not use the dialog, but only the custom sql method.&lt;/P&gt;&lt;P&gt;This is for two reasons:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;our databases are rather complex (many schemes, tables etc.), so it needs a lot clicking before anyone can find the right table&lt;/LI&gt;&lt;LI&gt;the documentation / saved queries in data table are looking quite ugly, when you have clicked the table together instead of using custom sql,&lt;BR /&gt;so it can not be used again ...&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So I like to work with "New SQL Query" + custom SQL, especially to use the generated tables by that way (e.g. update from database and do the same analysis again&amp;nbsp;...).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My target is to build a user interface for querying very complex data,&lt;/P&gt;&lt;P&gt;the first part is done at database (client with jmp cannot do by reason of performance),&lt;/P&gt;&lt;P&gt;and the second part is done by jmp starting with getting the data from Database by an easy to use customized GUI.&lt;/P&gt;&lt;P&gt;Here JMP offers perfect tools, but sometimes there remains a small problem to solve, like for the where clause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Georg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 13:59:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/83937#M37710</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2018-11-21T13:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Translate JMP-where-clause from data filter to SQL-where-clause</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/84809#M37966</link>
      <description>&lt;P&gt;Hey Eric,&lt;/P&gt;&lt;P&gt;your comment brings me to another question,&lt;/P&gt;&lt;P&gt;as we have very complex databases with many schemes and tables,&lt;/P&gt;&lt;P&gt;does the JMP Query Builder allow one to start it user defined?&lt;/P&gt;&lt;P&gt;I.e. can I start the Query builder with predefined schemes and filtered tables,&lt;/P&gt;&lt;P&gt;so that I do not need several minutes to click through the database?&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Georg&lt;/P&gt;</description>
      <pubDate>Sat, 01 Dec 2018 18:42:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/84809#M37966</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2018-12-01T18:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Translate JMP-where-clause from data filter to SQL-where-clause</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/84824#M37970</link>
      <description>&lt;P&gt;Hey, Georg,&lt;/P&gt;
&lt;P&gt;Great question.&amp;nbsp; Here is what I do:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Launch Query Builder and connect to the database.&lt;/LI&gt;
&lt;LI&gt;Use the&amp;nbsp;&lt;STRONG&gt;Select Tables for Query&lt;/STRONG&gt; dialog to add whatever tables and join relationships that you expect to use frequently.&lt;/LI&gt;
&lt;LI&gt;Click&amp;nbsp;&lt;STRONG&gt;Build Query&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;When the&amp;nbsp;&lt;STRONG&gt;Query Builder&lt;/STRONG&gt; window comes up, don't add any columns or filters to the query.&amp;nbsp; Instead, immediatly click&amp;nbsp;&lt;STRONG&gt;Save&lt;/STRONG&gt; and give the query a name like&amp;nbsp;&lt;STRONG&gt;complex_query_template.jmpquery.&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;When you want to build a query using that template as a starting point, find&amp;nbsp;&lt;STRONG&gt;complex_query_template.jmpquery&lt;/STRONG&gt; in the&amp;nbsp;&lt;STRONG&gt;Home&lt;/STRONG&gt; window&amp;nbsp;&lt;STRONG&gt;Recent Files&lt;/STRONG&gt; list, right-click on it and select&amp;nbsp;&lt;STRONG&gt;Edit a Copy&lt;/STRONG&gt;.&amp;nbsp; This will launch Query Builder with all the tables and joins in place as the template defined, and then you can proceed to select columns and add filters.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;If you template query is not in your Home Window Recent Files list, you can use&amp;nbsp;&lt;STRONG&gt;File Open&lt;/STRONG&gt; to open it, but you just have to remember to immediately do a&amp;nbsp;&lt;STRONG&gt;Save As&lt;/STRONG&gt; so that after you add stuff to the query and save it, you don't overwrite your template.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eric&lt;/P&gt;</description>
      <pubDate>Sun, 02 Dec 2018 13:35:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/84824#M37970</guid>
      <dc:creator>Eric_Hill</dc:creator>
      <dc:date>2018-12-02T13:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to Translate JMP-where-clause from data filter to SQL-where-clause</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/84846#M37984</link>
      <description>&lt;P&gt;Hey Eric,&lt;/P&gt;&lt;P&gt;thanks for the quick response, it helped,&lt;/P&gt;&lt;P&gt;and Query Builder has some very nice features. So I will look, where to use.&lt;/P&gt;&lt;P&gt;I could save the query with defined joins,&lt;/P&gt;&lt;P&gt;and use it again.&lt;/P&gt;&lt;P&gt;But a kind of filter of tables (stopping and saving Query at joining step) was not possible,&lt;/P&gt;&lt;P&gt;and I found not the possibility to connect filters with AND instead of OR.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Georg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 10:04:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/84846#M37984</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2018-12-03T10:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Translate JMP-where-clause from data filter to SQL-where-clause</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/84881#M37995</link>
      <description>&lt;P&gt;Hey, Georg,&lt;/P&gt;
&lt;P&gt;I'm not sure I follow this statement:&amp;nbsp; "But a kind of filter of tables (stopping and saving Query at joining step) was not possible."&lt;/P&gt;
&lt;P&gt;On the filters, AND is implicit.&amp;nbsp; I can see how that is confusing.&amp;nbsp; But if you just add a bunch of filters without clicking that OR button, you get AND.&amp;nbsp; In this query, for example:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="and_filters.png" style="width: 952px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/14682iDDA72C0FBD5D47E3/image-size/large?v=v2&amp;amp;px=999" role="button" title="and_filters.png" alt="and_filters.png" /&gt;&lt;/span&gt;I dragged&amp;nbsp;&lt;STRONG&gt;Rating&lt;/STRONG&gt; from the&amp;nbsp;&lt;STRONG&gt;Available Columns&lt;/STRONG&gt; list over into the&amp;nbsp;&lt;STRONG&gt;Filters&lt;/STRONG&gt; list, and then I dragged&amp;nbsp;&lt;STRONG&gt;DaysOut&lt;/STRONG&gt;, and then I dragged&amp;nbsp;&lt;STRONG&gt;State&lt;/STRONG&gt;.&amp;nbsp; I never clicked the&amp;nbsp;&lt;STRONG&gt;OR&lt;/STRONG&gt; button.&amp;nbsp; So those three filters are AND'd together - that filter is&amp;nbsp;&lt;STRONG&gt;(Rating = 'PG' AND DaysOut &amp;gt;= 5 AND State = 'FL')&lt;/STRONG&gt;.&amp;nbsp; So, you can have a single group of AND'd filters, or you can have multiple single filters that are OR'd together, or you can have groups of AND'd filters that are OR'd with each other.&amp;nbsp; The only think you can't have is a group of filters that is OR'd together that is AND'd with another group of filters that are OR'd together.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ultimately, if you can't get all the way to what you need with Query Builder, you can get as far as it will take you, and then use the red triangle menu at the upper left and select&amp;nbsp;&lt;STRONG&gt;Convert to Custom SQL Query&lt;/STRONG&gt;.&amp;nbsp; That will generate the SQL for the query as you have built it interactively and put it in a text editor so that you can edit it by hand to get what you need:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="custom.png" style="width: 646px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/14683i12876B0BF08CFAE9/image-size/large?v=v2&amp;amp;px=999" role="button" title="custom.png" alt="custom.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Once you make changes in&amp;nbsp;&lt;STRONG&gt;Custom SQL&lt;/STRONG&gt; mode, you can't really go back to interactive mode.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eric&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 17:37:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Translate-JMP-where-clause-from-data-filter-to-SQL-where/m-p/84881#M37995</guid>
      <dc:creator>Eric_Hill</dc:creator>
      <dc:date>2018-12-03T17:37:58Z</dc:date>
    </item>
  </channel>
</rss>

