Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Oracle [игнор отключен] [закрыт для гостей] / Помогите с тестовым / 11 сообщений из 11, страница 1 из 1
22.06.2017, 10:34
    #39476009
pronect
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Помогите с тестовым
Понимаю, что для опытных людей вопрос покажется наглым и не уместным. Есть тестовое задание для практики, в котором нужно найти "грамматические" ошибки в коде. Всего ошибок 8.
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
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
...
Рейтинг: 0 / 0
22.06.2017, 10:46
    #39476023
MaximaXXL
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Помогите с тестовым
pronect,

ну я 8 нашел, не врут наверно =)
...
Рейтинг: 0 / 0
22.06.2017, 10:53
    #39476036
env
env
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Помогите с тестовым
MaximaXXL,

С какими допущениями относительно типов данных и названий полей в исходных объектах запроса?

От 7 и больше.
...
Рейтинг: 0 / 0
22.06.2017, 10:56
    #39476043
AmKad
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Помогите с тестовым
В куске кода, где считаются count-ы, не хватает строки типа
Код: plsql
1.
count(distinct case when 4000<=s            then subs_id else null end) й4000
...
Рейтинг: 0 / 0
22.06.2017, 11:12
    #39476055
MaximaXXL
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Помогите с тестовым
AmKad,

чтоб добавить ошибок?
...
Рейтинг: 0 / 0
22.06.2017, 11:20
    #39476059
Dshedoo
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Помогите с тестовым
MaximaXXL,

Я нашёл только 5, без исправления которых, селект при любых форматах данных не отработает.

Где же остальные 3?
...
Рейтинг: 0 / 0
22.06.2017, 11:22
    #39476061
trace.log
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Помогите с тестовым
цветом выделяйте ошибки
...
Рейтинг: 0 / 0
22.06.2017, 11:25
    #39476066
georgy_g
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Помогите с тестовым
Нужно просто найти и пойти пить чай или назвать их в теме? )
...
Рейтинг: 0 / 0
22.06.2017, 11:44
    #39476081
andrey_anonymous
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Помогите с тестовым
Если очень бегло:
pronect
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
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]
join-предикат для x?
)
group by name_r, rtpl_id  rtpl
...
Рейтинг: 0 / 0
22.06.2017, 12:12
    #39476098
Dshedoo
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Помогите с тестовым
pronectПонимаю, что для опытных людей вопрос покажется наглым и не уместным. Есть тестовое задание для практики, в котором нужно найти "грамматические" ошибки в коде. Всего ошибок 8.
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
select name_r [color=red]'Имя'[/color], rtpl_id rtpl, 
  count(distinct case when             s<153  then subs_id else null end) x153,
  count(distinct case when 153[color=yellow]<=[/color]s  and s<306  then subs_id else null end) x306,
  count(distinct case when [color=yellow]305[/color][color=yellow]<=[/color]s  and s<459  then subs_id else null end) x459,
  count(distinct case when 459[color=yellow]<=[/color]s  and s<612  then subs_id else null end) x612,
  count(distinct case when 612[color=yellow]<=[/color]s  and s<765  then subs_id else null end) x765,
  count(distinct case when 765[color=yellow]<=[/color]s  and s<918  then subs_id else null end) x918,
  count(distinct case when 918[color=yellow]<=[/color]s  and s<1071 then subs_id else null end) x1071,
  count(distinct case when 1071[color=yellow]<=[/color]s and s<1224 then subs_id else null end) x1224,
  count(distinct case when 1224[color=yellow]<=[/color]s and s<1377 then subs_id else null end) x1377,
  count(distinct case when 1377[color=yellow]<=[/color]s and s<1530 then subs_id else null end) x1530,
  count(distinct case when 1530[color=yellow]<=[/color]s and s<2294 then subs_id else null end) x2294,
  count(distinct case when 2294[color=yellow]<=[/color]s and s<3059 then subs_id else null end) x3059[color=red] [/color]
  count(distinct case when 3059[color=yellow]<=[/color]s            then subs_id else null end) y3059
from (
select s.subs_id, 
       case when nvl(c.subs_count,0)<>0 then [color=yellow] [/color]amount_r/c.subs_count else 0 end [color=yellow]"s"[/color] ,
       x.name_r, x.rtpl_id
 from r_20070730 r, agg.client_d c[color=red] [/color]agg.subs_d s, (select * from bis.rate_plans x where x.end_date=[color=yellow]'31.12.2999'[/color]) x where c.d=[color=yellow]'01/07/2007'[/color]
  and s.d=[color=yellow]to_date('01.07.2007','dd.mm.yyyy')[/color]
  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 [color=red][0,169][/color]
)
group by name_r, rtpl_id[color=red] rtpl[/color]


Красным - ошибки
Жёлтым - возможные ошибки.
...
Рейтинг: 0 / 0
22.06.2017, 12:22
    #39476105
Dshedoo
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Помогите с тестовым
Dshedoo,

P.S. версия для дальтоников и ЧБ мониторов.
...
Рейтинг: 0 / 0
Форумы / Oracle [игнор отключен] [закрыт для гостей] / Помогите с тестовым / 11 сообщений из 11, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]