<?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>Question Re: How do I left outer join on different different data types? in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaa-p/12420000#M4649640</link>
    <description>&lt;P&gt;This was very helpful and I now don't get errors regarding syntax, however I was able to discover that I can't cast into numeric because this field is sometimes alphanumeric.  Is there a way to join on a conditional cast and left join on the alphanumeric data?&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;AR10000 = Null&lt;/P&gt;&lt;P&gt;175572 = 175572&lt;/P&gt;</description>
    <pubDate>Tue, 27 Apr 2021 23:31:02 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2021-04-27T23:31:02Z</dc:date>
    <item>
      <title>How do I left outer join on different different data types?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaq-p/12419997</link>
      <description>&lt;P&gt;I have a Crystal Report where I need to do a left outer join to another table. I need to display contents from the aropen table and only those values from the second table (inv-hdr-his) when there is a match. However, I'm trying to connect on two different data types. The aropen table has a 12 character string field called "doc-no" that I am trying to link to a 9 digit integer field called "inv-num".&lt;/P&gt;
  &lt;P&gt;I found a post on a Sql Server blog that said that if I place the sql statement in the Command field, it will work, but so far I have only received syntax errors. Please help, my sql is very limited and strung together by what I can find online.&lt;/P&gt;
  &lt;P&gt;Current sql query: &lt;/P&gt;
  &lt;P&gt; SELECT "aropen1"."comp-no", "aropen1"."balance", "aropen1"."doc-no", "aropen1"."doc-date", "aropen1"."due-date", "aropen1"."po", "aropen1"."amount", "aropen1"."doc-type", "aropen1"."descrip", "aropen1"."doc-pre", "aropen1"."cust-id", "aropen1"."stat", "aropen1"."freight", "inv_hdr_his"."invoice-num" FROM "PAPER"."PUB"."aropen" "aropen1" LEFT OUTER JOIN "inv-hdr-his" "inv-hdr-his" ON "aropen1"."doc-no"= CAST("inv_hdr_his"."invoice-num" AS char(12)) AS "doc-no" ) WHERE "aropen1"."comp-no"=""inv_hdr_his"."comp-no"&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;Current error:&lt;/P&gt;
  &lt;P&gt;Failed to retrive data from the database. Details: 42000:[DataDirect}{ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Syntax error (7587) [Database Vendor Code: -20003]&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 03:00:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaq-p/12419997</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-04-23T03:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I left outer join on different different data types?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaa-p/12419998#M4649638</link>
      <description>&lt;P&gt;Hi Cathy,&lt;/P&gt;&lt;P&gt;that does not look like a problem with the join, you should double check Error 42000.&lt;BR /&gt;Can you do a simple select on both of the tables without a problem (and without the join) ?&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Tobias&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 05:20:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaa-p/12419998#M4649638</guid>
      <dc:creator>former_member681242</dc:creator>
      <dc:date>2021-04-23T05:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do I left outer join on different different data types?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaa-p/12419999#M4649639</link>
      <description>&lt;P&gt;It looks like the problem is in the Where clause - there's an extra quote.  There's another problem in your Cast statement - you don't need the "as" part of it.  &lt;/P&gt;&lt;P&gt;Also, your Where clause looks like it could also be part of the join instead.  So, I would change the SQL to &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT 
  "aropen1"."comp-no", 
  "aropen1"."balance", 
  "aropen1"."doc-no", 
  "aropen1"."doc-date", 
  "aropen1"."due-date", 
  "aropen1"."po", 
  "aropen1"."amount", 
  "aropen1"."doc-type", 
  "aropen1"."descrip", 
  "aropen1"."doc-pre", 
  "aropen1"."cust-id", 
  "aropen1"."stat", 
  "aropen1"."freight", 
  "inv_hdr_his"."invoice-num" 
FROM "PAPER"."PUB"."aropen" "aropen1" 
  LEFT OUTER JOIN "inv-hdr-his" "inv-hdr-his" 
    ON "aropen1"."doc-no" = CAST("inv_hdr_his"."invoice-num" AS char(12))
	AND "aropen1"."comp-no" = "inv_hdr_his"."comp-no"
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Also, you should read this blog to get more information about working with Commands:&lt;/P&gt;&lt;P&gt;&lt;A href="https://blogs.sap.com/2015/04/01/best-practices-when-using-commands-with-crystal-reports/" target="test_blank"&gt;https://blogs.sap.com/2015/04/01/best-practices-when-using-commands-with-crystal-reports/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;-Dell&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 13:28:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaa-p/12419999#M4649639</guid>
      <dc:creator>DellSC</dc:creator>
      <dc:date>2021-04-23T13:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do I left outer join on different different data types?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaa-p/12420000#M4649640</link>
      <description>&lt;P&gt;This was very helpful and I now don't get errors regarding syntax, however I was able to discover that I can't cast into numeric because this field is sometimes alphanumeric.  Is there a way to join on a conditional cast and left join on the alphanumeric data?&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;AR10000 = Null&lt;/P&gt;&lt;P&gt;175572 = 175572&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 23:31:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaa-p/12420000#M4649640</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-04-27T23:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I left outer join on different different data types?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaa-p/12420001#M4649641</link>
      <description>&lt;P&gt;Instead of casting the String (inv_hdr_his"."invoice-num") to a Number, you could cast the Number ("aropen1"."doc-no") to a String.  The left join would then match only the numeric strings in  inv_hdr_his"."invoice-num" and filter out the alpha-numeric strings.&lt;/P&gt;&lt;P&gt;-Dell&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 15:57:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaa-p/12420001#M4649641</guid>
      <dc:creator>DellSC</dc:creator>
      <dc:date>2021-04-28T15:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I left outer join on different different data types?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaa-p/12420002#M4649642</link>
      <description>&lt;P&gt;Hi Dell, I was able to get it to work like a charm.  Turns out the exact character count was 24, so once I cast to that amount the link worked. Thanks for all your help!  Final formula wound up being:&lt;/P&gt;&lt;P&gt;SELECT
"aropen1"."comp-no", 
"aropen1"."balance", 
"aropen1"."doc-no", 
"aropen1"."doc-date", 
"aropen1"."due-date", 
"aropen1"."po", 
"aropen1"."amount", 
"aropen1"."doc-type", 
"aropen1"."descrip", 
"aropen1"."doc-pre", 
"aropen1"."cust-id", 
"aropen1"."stat", 
"aropen1"."freight",
"inv_hdr_his"."invoice-num", 
"inv_hdr_his"."ord-num", 
"inv_hdr_his"."cust-po"
FROM
"PAPER"."PUB"."aropen" "aropen1" 
   LEFT OUTER JOIN "PAPER"."PUB"."inv-hdr-his" "inv_hdr_his" 
      ON "aropen1"."doc-no" = CAST("inv_hdr_his"."invoice-num" as char(24))
WHERE
"aropen1"."comp-no"=1 AND "aropen1"."stat"&amp;lt;&amp;gt;'C'
ORDER BY
"aropen1"."doc-date", "aropen1"."doc-no"&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 01:22:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-do-i-left-outer-join-on-different-different-data-types/qaa-p/12420002#M4649642</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-05-13T01:22:19Z</dc:date>
    </item>
  </channel>
</rss>

