title: Nested Select errors with ORA-00913: too many values
body: <p>Full Disclosure: absolutely newb coder learning as I go.  I've written the following select routine which throws an ORA-00913: too many values error at Line 13 column 18 (the second nested select statement for address info).  I've searched and read the most simple suggestions (be certain your parentheses match or look for typos) to explicitly looking at the WHERE clause, using AS or other suggestions but no love so far.</p>
  
  <pre><code>select distinct  
     (select u.misc_data 
                from ps_name_miscnmbr u                                       
                where (u.misc_id = 'RFID') and u.name_id = cn.name_id) RFID,
              cn.dflt_id StudentIdNumber,                                  
              cn.first_name FirstName,
              cn.last_name LastName,
              cn.middle_name MiddleName,
              'pot: 100' as CollegeCode,
              to_char (cn.date_birth, 'YYYY-MM-DD') DateOfBirth,
              p.area_code,
              p.phone_no,
              (select  a.line1 StreetAddress1,
                       a.line2 StreetAddress2,
                       a.city City,
                       a.stat_id ST,
                       a.postal Zip
                  from co_v_dflt_addr a
                  where (a.adty_id in ('LOCL','HOME') and a.name_id = cn.name_id)),
              e.email_address Email                       
      from co_name cn,
           sr_v_enroll s,
           co_name_demo d,
           co_v_name_email e,
           co_v_name_phone1 p
      where s.term_id in ('201701', '201702', '201703') 
          and s.name_id = cn.name_id
          and d.name_id = cn.name_id
          and e.name_id = cn.name_id
          and p.name_id = cn.name_id
  order by LastName
  </code></pre>
  
  <p>When I isolate that second nested Select statement for addresses and run it by itself it executes and produces the columns/records that I expected.</p>
  
  <pre><code>(select distinct         cn.name_id,
                       a.line1 StreetAddress1,
                       a.line2 StreetAddress2,
                       a.city City,
                       a.stat_id State,
                       a.postal Zip
                  from co_v_dflt_addr a,
                       co_name cn
                  where (a.adty_id in ('LOCL','HOME') and a.name_id = cn.name_id))
  </code></pre>
  
  <p>When I comment out that entire selection subquery for addresses, the remainder of the routine also executes and produces the columns/records that I expected.</p>
  
  <pre><code>select distinct  
     (select u.misc_data 
                from ps_name_miscnmbr u                                       
                where (u.misc_id = 'RFID') and u.name_id = cn.name_id) RFID,
              cn.dflt_id StudentIdNumber,                                  
              cn.first_name FirstName,
              cn.last_name LastName,
              cn.middle_name MiddleName,
              'pot: 100' as CollegeCode,
              to_char (cn.date_birth, 'YYYY-MM-DD') DateOfBirth,
              p.area_code,
              p.phone_no,
              e.email_address Email                       
      from co_name cn,
           sr_v_enroll s,
           co_name_demo d,
           co_v_name_email e,
           co_v_name_phone1 p
      where s.term_id in ('201701', '201702', '201703') 
          and s.name_id = cn.name_id
          and d.name_id = cn.name_id
          and e.name_id = cn.name_id
          and p.name_id = cn.name_id
  order by LastName
  </code></pre>
  
  <p>Can someone offer a rookie a helpful tip here?  I've been going round and round trying things that aren't getting me to the finish line.</p>
  
  <p>Thanks</p>