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
나는 당신이 뭘하려고하는지 생각해. 특정 ID에 대해 최대 seq_no를 가져옵니다. 하지만 "단일 그룹 그룹 절이 아닙니다"라는 오류가 나타납니다.오라클 - 케이스 포함 최대
이 select 문은 더 큰 삽입 부분입니다.
감사합니다.
업데이트 : 이것은 당신이 당신이 전체 반환 설정을 통해 최대 원하는에 의한 경우 문 또는 그룹을 필요가 없습니다 최대 집계 함수가 null 값을 무시합니다
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);
아직 테이블에 ID가없는 경우 실제로는 1을 반환하고 싶습니다. – kralco626
충분히 공정한, 그것을 합병하여 포장하십시오. 내 편집을 참조하십시오. –
coalsce가 무슨 일을하는지 잘 모르겠지만 ... 'coalesce (max (cntrctr_lcns_seq_no) + 1, 1)를 선택하면 nuwmsweb.cntrctr_lcns_info에서 cartrctr_lcns_seq_no로 third_party_id = thirdPartyId'를 메모하십시오.'+ 1'을 적어주세요. – kralco626