<?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 Update: ERROR: Subquery evaluated to more than one row. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SQL-Update-ERROR-Subquery-evaluated-to-more-than-one-row/m-p/378760#M91091</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I encountered the same issue when I tried to update using the syntax below, and got an error message:&lt;/P&gt;
&lt;P&gt;ERROR: Subquery evaluated to more than one row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could someone look at my code and see if&amp;nbsp;this is a syntax error and help me correct it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;update lgddata.lgd_data_auto new&lt;BR /&gt; set auto_dfrt_other = &lt;BR /&gt; (select dfrt_other &lt;BR /&gt; from lgd2014.lgd_data_auto &lt;BR /&gt; where new.proc_yymm_dt = proc_yymm_dt);&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jul 2017 18:43:08 GMT</pubDate>
    <dc:creator>Bankshot</dc:creator>
    <dc:date>2017-07-24T18:43:08Z</dc:date>
    <item>
      <title>SQL Update: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Update-ERROR-Subquery-evaluated-to-more-than-one-row/m-p/378760#M91091</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I encountered the same issue when I tried to update using the syntax below, and got an error message:&lt;/P&gt;
&lt;P&gt;ERROR: Subquery evaluated to more than one row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could someone look at my code and see if&amp;nbsp;this is a syntax error and help me correct it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;update lgddata.lgd_data_auto new&lt;BR /&gt; set auto_dfrt_other = &lt;BR /&gt; (select dfrt_other &lt;BR /&gt; from lgd2014.lgd_data_auto &lt;BR /&gt; where new.proc_yymm_dt = proc_yymm_dt);&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 18:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Update-ERROR-Subquery-evaluated-to-more-than-one-row/m-p/378760#M91091</guid>
      <dc:creator>Bankshot</dc:creator>
      <dc:date>2017-07-24T18:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Update: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Update-ERROR-Subquery-evaluated-to-more-than-one-row/m-p/378764#M91092</link>
      <description>&lt;P&gt;It's not a syntax error, but a runtime problem because your subquery (apparently) yields more than one record, and the UPDATE assignment needs exactly one value to put in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See what just this clause yields:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select dfrt_other 
from lgd2014.lgd_data_auto 
where new.proc_yymm_dt = proc_yymm_dt&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jul 2017 18:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Update-ERROR-Subquery-evaluated-to-more-than-one-row/m-p/378764#M91092</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-07-24T18:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Update: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Update-ERROR-Subquery-evaluated-to-more-than-one-row/m-p/378782#M91098</link>
      <description>&lt;P&gt;I suspect you are missing a condition in your where clause. Get the problematic dates with the query:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select a.proc_yymm_dt, count(*) as n
from 
	lgddata.lgd_data_auto as a inner join
	lgd2014.lgd_data_auto as b on a.proc_yymm_dt = b.proc_yymm_dt
group by a.proc_yymm_dt
having count(*) &amp;gt; 1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 19:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Update-ERROR-Subquery-evaluated-to-more-than-one-row/m-p/378782#M91098</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-07-24T19:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Update: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Update-ERROR-Subquery-evaluated-to-more-than-one-row/m-p/378790#M91100</link>
      <description>&lt;P&gt;Thanks Chris. When you say "&lt;SPAN&gt;subquery (apparently) yields more than one record&lt;/SPAN&gt;", are you&amp;nbsp;referring to the number of unique value (in this case dfrt_other)? I just did a check on the number of unique values by each date, it seems all dates have unique rate values:&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select&lt;BR /&gt; proc_yymm_dt, count(distinct dfrt_other)&lt;BR /&gt;from lgd2014.lgd_data_auto&lt;BR /&gt;group by proc_yymm_dt&lt;BR /&gt;having count(distinct dfrt_other) &amp;gt; 1;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;The above code yields to a blank result&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 20:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Update-ERROR-Subquery-evaluated-to-more-than-one-row/m-p/378790#M91100</guid>
      <dc:creator>Bankshot</dc:creator>
      <dc:date>2017-07-24T20:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Update: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Update-ERROR-Subquery-evaluated-to-more-than-one-row/m-p/378811#M91102</link>
      <description>&lt;P&gt;As said in the error message, it is the number of rows that must be less than or equal to one. Rows with duplicate &lt;SPAN&gt;dfrt_other values are a problem too.&amp;nbsp;&lt;/SPAN&gt;Replace count(&lt;SPAN&gt;distinct dfrt_other) with count(*) to check the number of rows.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 22:37:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Update-ERROR-Subquery-evaluated-to-more-than-one-row/m-p/378811#M91102</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-07-24T22:37:52Z</dc:date>
    </item>
  </channel>
</rss>

