<?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 SQL Custom and Eval / Parse (and \!\!\!...) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339906#M58819</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I do a lot of queries that can't use the JMP query builder and have to be written in SQL Custom.&lt;BR /&gt;But as I also want to generalize my code I have to integrate a lot of eval / inserts and \!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code not yet generalized&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New SQL Query(
	Connection(
		"ODBC:blabla"
	),
	QueryName( "v_test_run" ),
	CustomSQL(
		"SELECT \!"t1\!".lot_id 
		FROM \!"public\!".\!"v_test_run\!"  \!"t1\!" 
		WHERE  (  (  ( \!"t1\!".test_run_timestamp &amp;gt;= '2020-11-01 15:25:11' )  )  ) ;"
	)
) &amp;lt;&amp;lt; Modify;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Code Generalized to include a date:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;gbStr = Eval Insert("

New SQL Query(
	Connection(
		\!"ODBC:blabla\!"
	),
	QueryName( \!"v_test_run\!" ),
	CustomSQL(
		\!"SELECT \!\!\!"t1\!\!\!".lot_id 
FROM \!\!\!"public\!\!\!".\!\!\!"v_test_run\!\!\!"  \!\!\!"t1\!\!\!" 
WHERE  (  (  ( \!\!\!"t1\!\!\!".test_run_timestamp &amp;gt;= '^date_deb^' )  )  ) ;\!"
)
) &amp;lt;&amp;lt; Modify;


");
Eval( Parse( gbStr ) );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there any other method that would save me from having to juggle with these &lt;CODE class=" language-jsl"&gt;\!\!\!&amp;nbsp;&lt;/CODE&gt;symbols?&lt;/P&gt;&lt;P&gt;On complex scripts it's really difficult to handle and debug!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 22:00:00 GMT</pubDate>
    <dc:creator>Franck_R</dc:creator>
    <dc:date>2023-06-09T22:00:00Z</dc:date>
    <item>
      <title>SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339906#M58819</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I do a lot of queries that can't use the JMP query builder and have to be written in SQL Custom.&lt;BR /&gt;But as I also want to generalize my code I have to integrate a lot of eval / inserts and \!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code not yet generalized&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New SQL Query(
	Connection(
		"ODBC:blabla"
	),
	QueryName( "v_test_run" ),
	CustomSQL(
		"SELECT \!"t1\!".lot_id 
		FROM \!"public\!".\!"v_test_run\!"  \!"t1\!" 
		WHERE  (  (  ( \!"t1\!".test_run_timestamp &amp;gt;= '2020-11-01 15:25:11' )  )  ) ;"
	)
) &amp;lt;&amp;lt; Modify;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Code Generalized to include a date:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;gbStr = Eval Insert("

New SQL Query(
	Connection(
		\!"ODBC:blabla\!"
	),
	QueryName( \!"v_test_run\!" ),
	CustomSQL(
		\!"SELECT \!\!\!"t1\!\!\!".lot_id 
FROM \!\!\!"public\!\!\!".\!\!\!"v_test_run\!\!\!"  \!\!\!"t1\!\!\!" 
WHERE  (  (  ( \!\!\!"t1\!\!\!".test_run_timestamp &amp;gt;= '^date_deb^' )  )  ) ;\!"
)
) &amp;lt;&amp;lt; Modify;


");
Eval( Parse( gbStr ) );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there any other method that would save me from having to juggle with these &lt;CODE class=" language-jsl"&gt;\!\!\!&amp;nbsp;&lt;/CODE&gt;symbols?&lt;/P&gt;&lt;P&gt;On complex scripts it's really difficult to handle and debug!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:00:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339906#M58819</guid>
      <dc:creator>Franck_R</dc:creator>
      <dc:date>2023-06-09T22:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339929#M58822</link>
      <description>&lt;P&gt;There are a few options outlined in &lt;A href="https://community.jmp.com/t5/JSL-Cookbook/Insert-one-expression-into-another-using-Eval-Insert-Eval-Expr/ta-p/48998" target="_self"&gt;this article&lt;/A&gt;, I recommend starting with Eval( Eval Expr()) and then wrapping each piece you need to replace with Expr(), and using \[ ... ]\ to reduce the number of escaped characters.&amp;nbsp; It could look something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval( Eval Expr(
	New SQL Query(
		Connection(
			"ODBC:blabla"
		),
		QueryName( "v_test_run" ),
		CustomSQL(
			Expr( "\[SELECT "t1".lot_id 
			FROM "public"."v_test_run"  "t1" 
			WHERE  (  (  ( "t1".test_run_timestamp &amp;gt;= ']\" || date_deb || "' )  )  ) ;")
		)
	) &amp;lt;&amp;lt; Modify
) );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 18:09:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339929#M58822</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2020-12-07T18:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339951#M58824</link>
      <description>&lt;P&gt;Thank you very much! I had read this article and had tried but I still have difficulties in mastering this eval (eval expr (expr))&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 18:14:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339951#M58824</guid>
      <dc:creator>Franck_R</dc:creator>
      <dc:date>2020-12-07T18:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339952#M58825</link>
      <description>&lt;P&gt;I would use the delimiters \[ and ]\ to include double quotes in the string.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;date_deb = "to_date('01-Mar-2019', 'dd-mon-yyyy')";
gbStr = Eval Insert("\[
New SQL Query(
	Connection(
		"ODBC:blabla"
	),
	QueryName( "v_test_run" ),
	CustomSQL(
		"SELECT "t1".lot_id 
FROM "public"."v_test_run"  "t1" 
WHERE  (  (  ( "t1".test_run_timestamp &amp;gt;= ^date_deb^ )  )  ) ;"
)
) &amp;lt;&amp;lt; Modify;
]\");

write(gbstr);

Eval( Parse( gbStr ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;PRE&gt;New SQL Query(
	Connection(
		"ODBC:blabla"
	),
	QueryName( "v_test_run" ),
	CustomSQL(
		"SELECT "t1".lot_id 
FROM "public"."v_test_run"  "t1" 
WHERE  (  (  ( "t1".test_run_timestamp &amp;gt;= to_date('01-Mar-2019', 'dd-mon-yyyy') )  )  ) ;"
)
) &amp;lt;&amp;lt; Modify;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Dec 2020 18:15:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339952#M58825</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2020-12-07T18:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339957#M58826</link>
      <description>&lt;P&gt;I agree that this syntax is only obvious once you understand it, and even then it is confusing.&amp;nbsp; Check out &lt;A href="https://community.jmp.com/t5/JMP-Wish-List/Introduce-Eval-Expr-First-as-a-new-wrapper-for-Eval-Eval-Expr/idi-p/278599" target="_self"&gt;this wish list item&lt;/A&gt;&amp;nbsp;to introduce an Eval Expr First() function, maybe that would be more intuitive?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 18:38:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339957#M58826</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2020-12-07T18:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339969#M58833</link>
      <description>&lt;P&gt;I like to&amp;nbsp;follow a different path avoiding unintuitive eval parse combinations, where I find them quite useful for other purposes.&lt;/P&gt;&lt;P&gt;Often I have complex queries (built in plain SQL by other Tools like SQL developer). And I Need to modify some variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The attached example Shows how it works with big class datatable, howewer it would work for all ODBC Connections in a similar way.&lt;/P&gt;&lt;P&gt;Simply I prepare my Connection string (not used here) and the SQL Query in a string variable, given to the "New SQL Query".object.&lt;/P&gt;&lt;P&gt;I use "assign" (instead of "=") because it works nice for large queries and Code folding.&lt;/P&gt;&lt;P&gt;And I'm more flexible for&amp;nbsp;also using open database function, or processing the SQL in other ways.&lt;/P&gt;&lt;P&gt;Usually the double quotes are not needed in a plain SQL (and I try to avoid also), unless you have names with spaces etc. like "Big Class".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

cdt = Open( "$Sample_Data\Big Class.jmp" );
age = "15";

// define custom SQL with placeholder
Assign( sql_str, "SELECT t1.name, t1.age, t1.sex, t1.height, 
	t1.weight 
FROM \!"Big Class\!"  t1 
WHERE  (  (  ( t1.age IN  ( &amp;amp;age )  )  )  ) ;" );

// fill placeholder
Substitute Into( sql_str, "&amp;amp;age", "15" );

// execute query
dt_age = New SQL Query( Version( 130 ), Connection( "JMP" ), JMP Tables( cdt ), QueryName( "aged" || "_" || age ), CustomSQL( sql_str ) ) &amp;lt;&amp;lt; Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Dec 2020 22:05:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/339969#M58833</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2020-12-07T22:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/340070#M58847</link>
      <description>&lt;P&gt;Great, that's really very useful! And since we've just created the database and I was the main actor of this creation, I've just made sure that no table name or variable name has parentheses or spaces, so it should simplify this generalisation.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 07:34:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/340070#M58847</guid>
      <dc:creator>Franck_R</dc:creator>
      <dc:date>2020-12-08T07:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768666#M94890</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4550"&gt;@pmroz&lt;/a&gt;&amp;nbsp;I tried the similar thing as above. after custom SQL run, returning the result&amp;nbsp; is 1 in the end of log. could you please help explain more about the result of 1? is it&amp;nbsp;Eval( Parse( gbStr ) ) return code that you mentioned in your script?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ReliabilityWolf_0-1719413439347.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65584i480804D511F2BE24/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ReliabilityWolf_0-1719413439347.png" alt="ReliabilityWolf_0-1719413439347.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 15:09:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768666#M94890</guid>
      <dc:creator>ReliabilityWolf</dc:creator>
      <dc:date>2024-06-26T15:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768668#M94891</link>
      <description>&lt;P&gt;Sorry I don't use Query Builder.&amp;nbsp; I would guess that the return value of 1 is true indicating success.&amp;nbsp; But that could be a wild surmise :)&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 15:14:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768668#M94891</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2024-06-26T15:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768834#M94908</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4550"&gt;@pmroz&lt;/a&gt;&amp;nbsp;thanks for your reply. May I have your support to review the following script?&amp;nbsp;&lt;/P&gt;&lt;P&gt;SQL Query usually takes a few minutes to access database. deleting rows (if :rank &amp;gt;1) sometimes doesn't execute but can do manually. I have no idea.... not sure if my script has any problem?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;date_deb = "to_date('01-Mar-2019', 'dd-mon-yyyy')";
gbStr = Eval Insert("\[
dt1 = New SQL Query(
	Connection(
		"ODBC:blabla"
	),
	QueryName( "v_test_run" ),
	CustomSQL(
		"SELECT "t1".lot_id 
FROM "public"."v_test_run"  "t1" 
WHERE  (  (  ( "t1".test_run_timestamp &amp;gt;= ^date_deb^ )  )  ) ;"
)
) &amp;lt;&amp;lt; Run foreground;
]\");

write(gbstr);

Eval( Parse( gbStr ) );

dt1 &amp;lt;&amp;lt; New Column( "Rank", Numeric, "Continuous", Format( "Best", 12 ) );
dt1:Rank &amp;lt;&amp;lt; set Formula( Col Rank( :DATE* -1, :ID ) );
dt1 &amp;lt;&amp;lt; Row Selection(select where(:Rank &amp;gt; 1 ));
dt1 &amp;lt;&amp;lt; delete rows;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 02:24:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768834#M94908</guid>
      <dc:creator>ReliabilityWolf</dc:creator>
      <dc:date>2024-06-27T02:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768849#M94913</link>
      <description>&lt;P&gt;I think formula evaluation takes some time,&lt;/P&gt;&lt;P&gt;a wait(0) would force JMP to finish until row selection is done (see script) and deletion can be done.&lt;/P&gt;&lt;P&gt;I would really encourage you to keep the string part as small as possible, as it is always error prone and difficult to read.&lt;/P&gt;&lt;P&gt;As well it is a great possiblity to use JMP Tables to figure out these kind of problems, and&amp;nbsp; to write scripts for the community that everyone can run out of the box.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edited: replaced "&lt;CODE class=" language-jsl"&gt;\C:\Program Files\JMP\JMPPRO\18\Samples\Data&lt;/CODE&gt;" by "$SAMPLE_DATA"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// date_deb = "to_date('01-Mar-2019', 'dd-mon-yyyy')";

date_str = "2008-06-19";

/*
gbStr = Eval Insert("\[
dt1 = New SQL Query(
	Connection(
		"ODBC:blabla"
	),
	QueryName( "v_test_run" ),
	CustomSQL(
		"SELECT "t1".lot_id 
FROM "public"."v_test_run"  "t1" 
WHERE  (  (  ( "t1".test_run_timestamp &amp;gt;= ^date_deb^ )  )  ) ;"
)
) &amp;lt;&amp;lt; Run foreground;
]\");
*/

dt1_sql = Eval Insert(
	"\[SELECT t1.Date, t1.State, t1."Flu Cases", t1.Region, 
	t1."Population (July 2009)" 
FROM "Seasonal Flu"  t1 
WHERE  (  (  ( t1.Date &amp;gt;= JMPDATE('^date_str^') )  )  ) ;]\"
);

dt1 = New SQL Query(
	Version( 130 ),
	Connection( "JMP" ),
	JMP Tables( ["Seasonal Flu" =&amp;gt; "$SAMPLE_DATA\Seasonal Flu.jmp"] ),
	QueryName( "SQLQuery1" ),
	CustomSQL( dt1_sql )
) &amp;lt;&amp;lt; run;

// Write( gbstr );
// Eval( Parse( gbStr ) );

dt1 &amp;lt;&amp;lt; New Column( "Rank", Numeric, "Continuous", Format( "Best", 12 ) );
dt1:Rank &amp;lt;&amp;lt; set Formula( Col Rank( :DATE * -1, /* :ID */ :State) );
wait(0);
dt1 &amp;lt;&amp;lt; Row Selection( select where( :Rank &amp;gt; 1 ) );
dt1 &amp;lt;&amp;lt; delete rows;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 06:56:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768849#M94913</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2024-06-27T06:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768906#M94921</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/9474"&gt;@Georg&lt;/a&gt;&amp;nbsp;thanks for suggestion. it's really a good and smart idea for&amp;nbsp;&lt;SPAN&gt;keeping the string part as small as possible. i tried it, and deletion still fail with wait(0). but it works for wait(1). however, when I access more size data from SQL datacenter (likely it takes a few mins to fetch data from server),&amp;nbsp; it works until wait(5). my guess is col rank() usually takes some time to calculate. more data size, more time for calculation. &amp;nbsp;when row selection execute before col rank calculation finish, deletion will fail. is there any way to determine the calculation complete? if yes, I can use IF function to run next step.&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 09:44:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768906#M94921</guid>
      <dc:creator>ReliabilityWolf</dc:creator>
      <dc:date>2024-06-27T09:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768910#M94923</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/57778"&gt;@ReliabilityWolf&lt;/a&gt;&amp;nbsp;generally I would try to do the filtering at database, so it depends on the sql language you have how to do (you can use rank with subselect in sql as well). And you gain a lot of time for unnecessary traffic.&lt;/P&gt;&lt;P&gt;Additionally I would avoid using a formula for this, if you want to have unique values for the ID, you can sort in SQL and use select duplicate rows and delete, see below. Database usually is much faster doing these tasks than your client.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding formulas, if you need, perhaps the table message "run formulas" or "rerun formulas" helps. Or you can delete formula, or write the results directly into the column ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

date_str = "2008-06-19";

dt1_sql = Eval Insert(
	"\[SELECT t1.Date, t1.State, t1."Flu Cases", t1.Region, 
	t1."Population (July 2009)" 
FROM "Seasonal Flu"  t1 
WHERE  (  (  ( t1.Date &amp;gt;= JMPDATE('^date_str^') )  )  )
order by
t1.State, t1.date desc;]\"
);

dt1 = New SQL Query(
	Version( 130 ),
	Connection( "JMP" ),
	JMP Tables( ["Seasonal Flu" =&amp;gt; "$SAMPLE_DATA\Seasonal Flu.jmp"] ),
	QueryName( "SQLQuery1" ),
	CustomSQL( dt1_sql )
) &amp;lt;&amp;lt; run;

dt1 &amp;lt;&amp;lt; Select Duplicate Rows( Match( :State ) ) &amp;lt;&amp;lt; delete rows();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 11:10:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768910#M94923</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2024-06-27T11:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Custom and Eval / Parse (and \!\!\!...)</title>
      <link>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768930#M94927</link>
      <description>&lt;P&gt;really appreciate your new direction on&amp;nbsp;&lt;SPAN&gt;filtering at database. let me take a look at this. thanks again.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 13:41:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQL-Custom-and-Eval-Parse-and/m-p/768930#M94927</guid>
      <dc:creator>ReliabilityWolf</dc:creator>
      <dc:date>2024-06-27T13:41:28Z</dc:date>
    </item>
  </channel>
</rss>

