<?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 JSL function with SQL Join pulling data rows 3 times compared to one without JOIN -why? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-function-with-SQL-Join-pulling-data-rows-3-times-compared-to/m-p/706891#M89134</link>
    <description>&lt;P&gt;The first function below with SQL INNER JOIN pulls each data rows (for &lt;EM&gt;LNo&lt;/EM&gt;) two additional times from the database compared to the second function below without JOIN. Where am I going wrong?&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 );
opnDtb = Function( {R, M, T}, {dtm}, 
	dtm = Open Database(
	"Driver=SQL Server;
	Server=ABCD-EFGH;
	DATABASE=myDB;
    Trusted_Connection=Yes;",
		"SELECT SM.[LNo], SM.[TestDate] AS [orgTestDate], SM.[Median], MT.[EntryDate] AS [TestDate]
	     FROM [myDB].[dbo].[P_STD_" || R|| "_" || T || "_" || M || "_SUMMARY] AS SM 
	     INNER JOIN [myDB].[dbo].[P_STD_" || R || "_" || T || "_" || M || "_META] AS MT 
	     ON SM.LNo =  MT.LNo"
	);
	Return( dtm );
);
////TEST  
clear log (); R  =  "D12"; T = "7"; M = "5"; dtm = opnDtb(R, M, T); dtm &amp;lt;&amp;lt; set name ("sTable");&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
opnDtb = Function( {R, M, T}, {dtm}, 
	dtm = Open Database(
	"Driver=SQL Server;
	Server=ABCD-EFGH;
	DATABASE=myDB;
    Trusted_Connection=Yes;",
		"SELECT SM.[LNo], SM.[TestDate], SM.[Median] FROM [myDB].[dbo].[P_STD_" || R|| "_" || T || "_" || M || "_SUMMARY] AS SM"
	);
	Return( dtm );
);
////TEST  
clear log (); R  =  "D12"; T = "7"; M = "5"; dtm = opnDtb(R, M, T); dtm &amp;lt;&amp;lt; set name ("sTable");&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, 07 Dec 2023 20:06:26 GMT</pubDate>
    <dc:creator>Neo</dc:creator>
    <dc:date>2023-12-07T20:06:26Z</dc:date>
    <item>
      <title>JSL function with SQL Join pulling data rows 3 times compared to one without JOIN -why?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-function-with-SQL-Join-pulling-data-rows-3-times-compared-to/m-p/706891#M89134</link>
      <description>&lt;P&gt;The first function below with SQL INNER JOIN pulls each data rows (for &lt;EM&gt;LNo&lt;/EM&gt;) two additional times from the database compared to the second function below without JOIN. Where am I going wrong?&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 );
opnDtb = Function( {R, M, T}, {dtm}, 
	dtm = Open Database(
	"Driver=SQL Server;
	Server=ABCD-EFGH;
	DATABASE=myDB;
    Trusted_Connection=Yes;",
		"SELECT SM.[LNo], SM.[TestDate] AS [orgTestDate], SM.[Median], MT.[EntryDate] AS [TestDate]
	     FROM [myDB].[dbo].[P_STD_" || R|| "_" || T || "_" || M || "_SUMMARY] AS SM 
	     INNER JOIN [myDB].[dbo].[P_STD_" || R || "_" || T || "_" || M || "_META] AS MT 
	     ON SM.LNo =  MT.LNo"
	);
	Return( dtm );
);
////TEST  
clear log (); R  =  "D12"; T = "7"; M = "5"; dtm = opnDtb(R, M, T); dtm &amp;lt;&amp;lt; set name ("sTable");&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
opnDtb = Function( {R, M, T}, {dtm}, 
	dtm = Open Database(
	"Driver=SQL Server;
	Server=ABCD-EFGH;
	DATABASE=myDB;
    Trusted_Connection=Yes;",
		"SELECT SM.[LNo], SM.[TestDate], SM.[Median] FROM [myDB].[dbo].[P_STD_" || R|| "_" || T || "_" || M || "_SUMMARY] AS SM"
	);
	Return( dtm );
);
////TEST  
clear log (); R  =  "D12"; T = "7"; M = "5"; dtm = opnDtb(R, M, T); dtm &amp;lt;&amp;lt; set name ("sTable");&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, 07 Dec 2023 20:06:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-function-with-SQL-Join-pulling-data-rows-3-times-compared-to/m-p/706891#M89134</guid>
      <dc:creator>Neo</dc:creator>
      <dc:date>2023-12-07T20:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: JSL function with SQL Join pulling data rows 3 times compared to one without JOIN -why?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-function-with-SQL-Join-pulling-data-rows-3-times-compared-to/m-p/706900#M89135</link>
      <description>&lt;P&gt;Have you checked what type of data you have in MT table (maybe there are multiple rows for each LNo in that table)?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 17:59:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-function-with-SQL-Join-pulling-data-rows-3-times-compared-to/m-p/706900#M89135</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-12-07T17:59:30Z</dc:date>
    </item>
  </channel>
</rss>

