<?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 Help with:  WITH and CAST Functions in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-with-WITH-and-CAST-Functions/m-p/166380#M12803</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was given a program (written by someone else) to run.&amp;nbsp; My SAS/SQL skills are beginner-intermediate.&amp;nbsp; I have never worked with WITH and CAST functions before.&amp;nbsp; When I tried to run this program, it would take hours until it times out.&amp;nbsp; I put the option to bring back only 10 OBS - theoretically it shouldn't take long.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thoughts?&amp;nbsp; It seems like the program is running in loops &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;OPTIONS OBS=10;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;OPTIONS COMPRESS=YES;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; connect to teradata(database=xyz tdpid=edwprod user=xxxx password="xxxx");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; create table agent as select *&amp;nbsp; from connection to teradata (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; WITH ahist (contact_id, duration, account_id, per_num) as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; SELECT distinct&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.contact_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.duration,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.account_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; FROM acct_data ahist&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; where ahist.per_num = 6368&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; SELECT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ecm.cl_tid,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.account_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.duration,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; agent.ecmcontact_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; agent.per_num,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; agent.user_role_dsc,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; agent.start_ts,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; artf.create_ts,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; note.history_key_nm,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; cast(agent.start_ts as date) as emp_date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; FROM ecmcontact agent&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; join ahist&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; on ahist.contact_id=agent.ecmcontact_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; and ahist.per_num=agent.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; left outer join ecm_account ecm&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; on ecm.account_id=ahist.account_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; left outer join ecmartifact artf&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; on ahist.contact_id=artf.contact_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; and ahist.per_num=artf.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; left outer join citiecmnote note&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; on ahist.per_num=note.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; and note.ecm_artifact_id = artf.ecmartifact_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ORDER BY ecm.cl_tid, artf.create_ts&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Dec 2013 21:23:40 GMT</pubDate>
    <dc:creator>jen123</dc:creator>
    <dc:date>2013-12-06T21:23:40Z</dc:date>
    <item>
      <title>Help with:  WITH and CAST Functions</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-with-WITH-and-CAST-Functions/m-p/166380#M12803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was given a program (written by someone else) to run.&amp;nbsp; My SAS/SQL skills are beginner-intermediate.&amp;nbsp; I have never worked with WITH and CAST functions before.&amp;nbsp; When I tried to run this program, it would take hours until it times out.&amp;nbsp; I put the option to bring back only 10 OBS - theoretically it shouldn't take long.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thoughts?&amp;nbsp; It seems like the program is running in loops &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;OPTIONS OBS=10;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;OPTIONS COMPRESS=YES;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; connect to teradata(database=xyz tdpid=edwprod user=xxxx password="xxxx");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; create table agent as select *&amp;nbsp; from connection to teradata (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; WITH ahist (contact_id, duration, account_id, per_num) as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; SELECT distinct&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.contact_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.duration,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.account_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; FROM acct_data ahist&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; where ahist.per_num = 6368&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; SELECT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ecm.cl_tid,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.account_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.duration,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; agent.ecmcontact_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; agent.per_num,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; agent.user_role_dsc,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; agent.start_ts,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; artf.create_ts,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; note.history_key_nm,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; cast(agent.start_ts as date) as emp_date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; FROM ecmcontact agent&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; join ahist&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; on ahist.contact_id=agent.ecmcontact_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; and ahist.per_num=agent.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; left outer join ecm_account ecm&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; on ecm.account_id=ahist.account_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; left outer join ecmartifact artf&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; on ahist.contact_id=artf.contact_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; and ahist.per_num=artf.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; left outer join citiecmnote note&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; on ahist.per_num=note.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; and note.ecm_artifact_id = artf.ecmartifact_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ORDER BY ecm.cl_tid, artf.create_ts&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Dec 2013 21:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-with-WITH-and-CAST-Functions/m-p/166380#M12803</guid>
      <dc:creator>jen123</dc:creator>
      <dc:date>2013-12-06T21:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help with:  WITH and CAST Functions</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-with-WITH-and-CAST-Functions/m-p/166381#M12804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're using something called SQL Pass Through, which means the syntax after the&amp;nbsp; section below must be valid Terabase SQL. I don't know enough about Terabase to help, but you may be better off in posting to a Terabase forum or checking those out at least.&amp;nbsp; WITH looks like a sub query to me, so you could potentially rewrite the code very easily, but I'd test it thoroughly. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;create table agent as select *&amp;nbsp; from connection to teradata (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This may work, if I understand the above correctly, which I'm not sure I do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;OPTIONS OBS=10;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;OPTIONS COMPRESS=YES;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; connect to teradata(database=xyz tdpid=edwprod user=xxxx password="xxxx");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; create table agent as select *&amp;nbsp; from connection to teradata (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; SELECT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ecm.cl_tid,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.account_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.duration,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; agent.ecmcontact_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; agent.per_num,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; agent.user_role_dsc,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; agent.start_ts,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; artf.create_ts,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; note.history_key_nm,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; cast(agent.start_ts as date) as emp_date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; FROM ecmcontact agent&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; join (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt; SELECT distinct&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.contact_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.duration,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.account_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ahist.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; FROM acct_data ahist&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; where ahist.per_num = 6368) ahist&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; on ahist.contact_id=agent.ecmcontact_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; and ahist.per_num=agent.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; left outer join ecm_account ecm&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; on ecm.account_id=ahist.account_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; left outer join ecmartifact artf&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; on ahist.contact_id=artf.contact_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; and ahist.per_num=artf.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; left outer join citiecmnote note&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; on ahist.per_num=note.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; and note.ecm_artifact_id = artf.ecmartifact_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; ORDER BY ecm.cl_tid, artf.create_ts&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Bookman Old Style','serif'; color: blue;"&gt;&amp;nbsp; quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Dec 2013 21:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-with-WITH-and-CAST-Functions/m-p/166381#M12804</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-12-06T21:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help with:  WITH and CAST Functions</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-with-WITH-and-CAST-Functions/m-p/166382#M12805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can help out with the CAST part at least; in SQL, that's how data conversions are done. So I'm fairly sure your "cast(agent.start_ts as date) as emp_date" is just converting agent.start _ts into whatever Teradata's internal date format is, from where I assume it will be transformed into SAS's date format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Dec 2013 00:47:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-with-WITH-and-CAST-Functions/m-p/166382#M12805</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2013-12-07T00:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help with:  WITH and CAST Functions</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-with-WITH-and-CAST-Functions/m-p/166383#M12806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My Teradata programming friends tell me that you get better performance using GROUP BY instead of SELECT DISTINCT.&lt;/P&gt;&lt;P&gt;So your first sub-query could be re-written as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #000000;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;SELECT &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;ahist.contact_id&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier; color: #000000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , ahist.duration&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier; color: #000000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , ahist.account_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier; color: #000000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , ahist.per_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier; color: #000000;"&gt;FROM acct_data ahist&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier; color: #000000;"&gt;WHERE ahist.per_num = 6368&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier; color: blue;"&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #000000;"&gt;GROUP BY 1,2,3,4&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Dec 2013 01:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-with-WITH-and-CAST-Functions/m-p/166383#M12806</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-12-07T01:29:28Z</dc:date>
    </item>
  </channel>
</rss>

