title: oracle - max with case
body: <pre><code>select case when cntrctr_lcns_seq_no is null
                                     then 1
                                     else max(cntrctr_lcns_seq_no)
                                     end as cntrctr_lcns_seq_no
                                     from nuwmsweb.cntrctr_lcns_info
                                      where third_party_id = thirdPartyId
                                      group by third_party_id
  </code></pre>
  
  <p>I think you an see what i'm trying to do. Get the max seq_no for a specific id. But I get the error "not a single group group clause".</p>
  
  <p>This select statement is part of a larger insert.</p>
  
  <p>Thanks!</p>
  
  <p>update: this is the whole statement</p>
  
  <pre><code>insert into nuwmsweb.CNTRCTR_LCNS_INFO
      (third_party_id,cntrctr_lcns_seq_no,cntrctr_lcns_no,
      lcns_st_cd,certfn_level_type_cd,cntrctr_type_cd,cut_tap_authy_ind,
      stat_type_nm)
      VALUES(thirdPartyId,(select max(case when cntrctr_lcns_seq_no is null
                                     then 1
                                     else cntrctr_lcns_seq_no
                                     end) as cntrctr_lcns_seq_no
                                     from nuwmsweb.cntrctr_lcns_info
                                      where third_party_id = thirdPartyId
                                      group by third_party_id
                                      ),
            licenseNumber,licenseState,licenseLevel,licenseType,cutTap,status);
  </code></pre>