Пачаны сильно не обассывайте. Нужно найти 8 ошибок задании - запятые, "грамматические".С меня как обычно.select name_r 'Имя', rtpl_id rtpl, count(distinct case when s<153 then subs_id else null end) x153, count(distinct case when 153<=s and s<306 then subs_id else null end) x306, count(distinct case when 305<=s and s<459 then subs_id else null end) x459, count(distinct case when 459<=s and s<612 then subs_id else null end) x612, count(distinct case when 612<=s and s<765 then subs_id else null end) x765, count(distinct case when 765<=s and s<918 then subs_id else null end) x918, count(distinct case when 918<=s and s<1071 then subs_id else null end) x1071, count(distinct case when 1071<=s and s<1224 then subs_id else null end) x1224, count(distinct case when 1224<=s and s<1377 then subs_id else null end) x1377, count(distinct case when 1377<=s and s<1530 then subs_id else null end) x1530, count(distinct case when 1530<=s and s<2294 then subs_id else null end) x2294, count(distinct case when 2294<=s and s<3059 then subs_id else null end) x3059, count(distinct case when 3059<=s then subs_id else null end) y3059,from (select s.subs_id, case when nvl(c.subs_count,0)<>0 then amount_r/c.subs_count else 0 end "s", x.name_r, x.rtpl_id from r_20070730 r, agg.client_d c agg.subs_d s, (select * from bis.rate_plans x where x.end_date='31.12.2999') x where c.d='01/07/2007' and s.d=to_date('01.07.2007','dd.mm.yyyy') and c.client_id=r.clnt_clnt_id and s.client_id=c.client_id-- and s.status_bu in (4,6) and s.sbst_id = 2 and s.status_bu = 4 and s.rtpl_id=x.rtpl_id and x.rtpl_id not in [0,169])group by name_r, rtpl_id rtpl
Добавил номера строк для удобства. В 13, 14 нашел две отсутствующие запятые.1 select name_r 'Имя', rtpl_id rtpl, 2 count(distinct case when s<153 then subs_id else null end) x153,3 count(distinct case when 153<=s and s<306 then subs_id else null end) x306,4 count(distinct case when 305<=s and s<459 then subs_id else null end) x459,5 count(distinct case when 459<=s and s<612 then subs_id else null end) x612,6 count(distinct case when 612<=s and s<765 then subs_id else null end) x765,7 count(distinct case when 765<=s and s<918 then subs_id else null end) x918,8 count(distinct case when 918<=s and s<1071 then subs_id else null end) x1071,9 count(distinct case when 1071<=s and s<1224 then subs_id else null end) x1224,10 count(distinct case when 1224<=s and s<1377 then subs_id else null end) x1377,11 count(distinct case when 1377<=s and s<1530 then subs_id else null end) x1530,12 count(distinct case when 1530<=s and s<2294 then subs_id else null end) x2294,13 count(distinct case when 2294<=s and s<3059 then subs_id else null end) x3059,14 count(distinct case when 3059<=s then subs_id else null end) y3059,15 from (16 select s.subs_id, 17 case when nvl(c.subs_count,0)<>0 then amount_r/c.subs_count else 0 end "s",18 x.name_r, x.rtpl_id19 from r_20070730 r, agg.client_d c agg.subs_d s, (select * from bis.rate_plans x where x.end_date='31.12.2999') x where c.d='01/07/2007'20 and s.d=to_date('01.07.2007','dd.mm.yyyy')21 and c.client_id=r.clnt_clnt_id22 and s.client_id=c.client_id23 -- and s.status_bu in (4,6)24 and s.sbst_id = 2 and s.status_bu = 425 and s.rtpl_id=x.rtpl_id26 and x.rtpl_id not in [0,169]27 )28 group by name_r, rtpl_id rtpl
Открой любой SQL Editor, там тебе подсветят.2017 год на дворе, какие на хуй запятые.