sql - Not a single-group group function while using case when statements -
in query trying use case when keywords. have check 3 conditions there. getting not single-group group function error. syntax error in query? please guide.
query
select case when dist_type_id in (5033,5034,5035,5036) min (b2b_start_dt +nvl(access_lead_days,0)) else case when max(overridden) = 0 nvl (min (src_start_dt), min (b2b_start_dt)) else max(b2b_start_dt) end end start_date prog_access_movie_v trunc(sysdate) between b2b_start_dt , b2b_end_dt , (user_id not null or group_id not null) , dist_type_id in (5034) , prog_id = (432899)
this select
:
select (case when dist_type_id in (5033, 5034, 5035, 5036) min(b2b_start_dt + nvl(access_lead_days, 0)) else (case when max(overridden) = 0 nvl(min(src_start_dt), min(b2b_start_dt)) else max(b2b_start_dt) end) end) start_date
in terms of aggregation, fine except condition on dist_type_id
. if had:
select (case when max(dist_type_id) in (5033, 5034, 5035, 5036) min(b2b_start_dt + nvl(access_lead_days, 0)) else (case when max(overridden) = 0 nvl(min(src_start_dt), min(b2b_start_dt)) else max(b2b_start_dt) end) end) start_date
or:
select (case when sum(case when dist_type_id in (5033, 5034, 5035, 5036) 1 else 0 end) > 0 min(b2b_start_dt + nvl(access_lead_days, 0)) else (case when max(overridden) = 0 nvl(min(src_start_dt), min(b2b_start_dt)) else max(b2b_start_dt) end) end) start_date
or myriad of other possibilities, query should parse , execute.
Comments
Post a Comment