<?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: About SQL in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/About-SQL/m-p/684761#M24239</link>
    <description>&lt;P&gt;Use a HAVING clause:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select min(SAL) as min, ename
from cert.emptt
where job='MANAGER'
having calculated min = sal
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 17 Sep 2020 19:14:14 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-09-17T19:14:14Z</dc:date>
    <item>
      <title>About SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/About-SQL/m-p/684759#M24238</link>
      <description>&lt;P&gt;When I was analyzing table empT using SQL, the table is as following:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jianan_luna_0-1600369662485.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/49510iFFD23FD3F7F7DDC8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jianan_luna_0-1600369662485.png" alt="Jianan_luna_0-1600369662485.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to find the minimum salary of managers, so I wrote the code as following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select min(SAL) as min
from cert.emptt
where job='MANAGER';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I got my answer 2450, but I also want to know the manager's name, thus I wrote code as following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select min(SAL) as min, ename
from cert.emptt
where job='MANAGER';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the I got the results:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jianan_luna_1-1600369769539.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/49511iDCD041C687151A53/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jianan_luna_1-1600369769539.png" alt="Jianan_luna_1-1600369769539.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It shows all manager's name with minimum salary, can you please let me know how can I get the answer of minimum salary with manager's name? Thanks so much&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 19:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/About-SQL/m-p/684759#M24238</guid>
      <dc:creator>Jianan_luna</dc:creator>
      <dc:date>2020-09-17T19:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: About SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/About-SQL/m-p/684761#M24239</link>
      <description>&lt;P&gt;Use a HAVING clause:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select min(SAL) as min, ename
from cert.emptt
where job='MANAGER'
having calculated min = sal
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Sep 2020 19:14:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/About-SQL/m-p/684761#M24239</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-17T19:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: About SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/About-SQL/m-p/684763#M24240</link>
      <description>&lt;P&gt;Thanks so much Sir, I got the right answer, but could you please explain why should I use having clause here? I am still confused&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 19:18:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/About-SQL/m-p/684763#M24240</guid>
      <dc:creator>Jianan_luna</dc:creator>
      <dc:date>2020-09-17T19:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: About SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/About-SQL/m-p/684764#M24241</link>
      <description>&lt;P&gt;You can also do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort
  data=cert.emptt (where=(job = "MANAGER"))
  out=want (obs=1)
;
by sal;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Sep 2020 19:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/About-SQL/m-p/684764#M24241</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-17T19:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: About SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/About-SQL/m-p/684767#M24242</link>
      <description>&lt;P&gt;Maxim 3: Read the Log.&lt;/P&gt;
&lt;P&gt;With your original code, you'll find a NOTE about remerging, so we need to prevent that.&lt;/P&gt;
&lt;P&gt;To subset based on the result of a SQL summary function, you need HAVING, you cannot use it in a WHERE.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 19:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/About-SQL/m-p/684767#M24242</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-17T19:22:54Z</dc:date>
    </item>
  </channel>
</rss>

