Важен е пътят не целта!
select kart_nomer, sezon, ime, kod_otbor, teamnumber, vid_champ, kod_trenjor, kod_trenjor1, kod_lekar, kod_manager, kod_regmanager, f_kod, club, grad, kod_champ, ligaf_kod, team_img, team_img1,recnum from (select *, (select name from b_teams where b_teams.teamnumber=kartoteka.teamnumber) as club, (select grad from k_adress where to_date is null and k_adress.f_kod_a=(select f_kod from b_teams where b_teams.teamnumber=kartoteka.teamnumber)) as grad, (select f_kod from kontragenti where kontragenti.f_kod=(select f_kod from b_teams where b_teams.teamnumber=kartoteka.teamnumber)) as f_kod,(select sezon from b_champ where kartoteka.kod_champ=b_champ.kod_champ) as sezon, (select kod_otbor from b_champ where kartoteka.kod_champ=b_champ.kod_champ) as kod_otbor, (select vid_champ from b_champ where kartoteka.kod_champ=b_champ.kod_champ) as vid_champ, (select ligaf_kod from b_champ where kartoteka.kod_champ=b_champ.kod_champ) as ligaf_kod, (select ime from b_champ where kartoteka.kod_champ=b_champ.kod_champ) as ime from kartoteka) kartoteka where kod_otbor = '3' and sezon='2022' and f_kod=111346 and true and ligaf_kod='111347' order by kod_otbor asc

Програма за сезон 2022

Момчета до 14 години - Дивизия ИЗТОК, зона "Мизия"
select dotbor, potbor, score_dotbor, score_potbor, kod_mach, vid_mach, kod_turnir, data, chas, grad, zala, kod_dotbor, kod_potbor, sezon, kod_otbor, kod_champ, champ, vid_champ, ligaf_kod, recnum, (select name from nomenklaturi where kat_kod=26 and podkat_kod=1 and cast(nomenklaturi.kod as integer)=t1.kod_otbor) as name, (select ime from b_turniri where kod_turnir=t1.kod_turnir) as turnir, plist from (select substring((select name from b_teams where b_teams.teamnumber=kod_dotbor) from 1 for 30) as dotbor, substring((select name from b_teams where b_teams.teamnumber=kod_potbor) from 1 for 30) as potbor, (select kod_otbor from b_champ where kod_champ in (Select kod_champ from b_turniri where b_turniri.kod_turnir=b_machove.kod_turnir)) as kod_otbor,(select sezon from b_champ where kod_champ in (Select kod_champ from b_turniri where b_turniri.kod_turnir=b_machove.kod_turnir)) as sezon,(select kod_champ from b_champ where kod_champ in (Select kod_champ from b_turniri where b_turniri.kod_turnir=b_machove.kod_turnir)) as kod_champ,(select ime from b_champ where kod_champ in (Select kod_champ from b_turniri where b_turniri.kod_turnir=b_machove.kod_turnir)) as champ,(select vid_champ from b_champ where kod_champ in (Select kod_champ from b_turniri where b_turniri.kod_turnir=b_machove.kod_turnir)) as vid_champ,(select ligaf_kod from b_champ where kod_champ in (Select kod_champ from b_turniri where b_turniri.kod_turnir=b_machove.kod_turnir)) as ligaf_kod,* from b_machove order by data, chas) t1 where ligaf_kod='111347' and ((kod_dotbor='2841') or (kod_potbor='2841')) and sezon='2022'
Домакин Гост Т. дом. Т. гост Дата Град Зала Час Мач
Чардафон ОБКЕтър 49 СБК70392022-10-29ТроянЧавдар11:15-13:00 3050
Дунав 2007 ССКБЧардафон ОБК76542022-10-29ТроянЧавдар16:15-18:00 3053
Раковски СБКЧардафон ОБК27702022-11-06СевлиевоДан Колов09:30-11:00 3054
Чавдар-Троян СБКЧардафон ОБК75612022-11-06СевлиевоДан Колов13:00-14:45 3056
Чардафон ОБКРаковски СБК64192022-12-18Велико ТърновоИвайло11:15-13:00 3066
Чардафон ОБКЧавдар-Троян СБК57582022-12-18Велико ТърновоИвайло16:15-18:00 3069
Чардафон ОБКДунав 2007 ССКБ52482023-01-07ГабровоОрловец11:15-13:00 3061
Етър 49 СБКЧардафон ОБК46572023-01-07ГабровоОрловец14:45-16:15 3063
Дунав 2007 ССКБЧардафон ОБК002023-01-14РусеДунав09:30-11:15 3070
Раковски СБКЧардафон ОБК002023-01-14РусеДунав11:15-13:00 3071
Етър 49 СБКЧардафон ОБК002023-01-14РусеДунав14:45-16:15 3073

КЛАСИРАНЕ В ШАМПИОНАТА

select * from (SELECT clubs.name as ime, klasir.played, klasir.wins, klasir.Drew, klasir.Lost, klasir.score_dotbor, klasir.score_potbor, klasir.goal_diff, 2*klasir.wins + klasir.lost AS TotalPoints, klasir.kod_champ FROM (select * from ( (SELECT TeamID, sum(wins+drew+lost) as Played, SUM(wins) AS wins, SUM(Drew) AS Drew, SUM(Lost) AS Lost, SUM(score_dotbor) AS score_dotbor, SUM(score_potbor) AS score_potbor, sum(goal_diff) as goal_diff, kod_champ FROM (SELECT kod_dotbor AS TeamId, COUNT(*) AS played, SUM(CASE WHEN score_dotbor > score_potbor THEN 1 ELSE 0 END) AS wins, SUM(CASE WHEN score_dotbor = score_potbor THEN 0 ELSE 0 END) AS Drew, SUM(CASE WHEN score_dotbor < score_potbor THEN 1 ELSE 0 END) AS Lost, SUM(score_dotbor) AS score_dotbor, SUM(score_potbor) AS score_potbor, sum(score_dotbor) - sum(score_potbor) as goal_diff,(Select kod_champ from b_turniri where b_turniri.kod_turnir=b_Machove.kod_Turnir) as kod_champ FROM b_machove group by TeamId, kod_champ UNION ALL SELECT kod_potbor AS TeamId, COUNT(*) AS played,SUM(CASE WHEN score_dotbor < score_potbor THEN 1 ELSE 0 END) AS wins, SUM(CASE WHEN score_dotbor = score_potbor THEN 0 ELSE 0 END) AS Drew, SUM(CASE WHEN score_dotbor > score_potbor THEN 1 ELSE 0 END) AS Lost, SUM(score_potbor) AS score_dotbor, SUM(score_dotbor) AS score_potbor, sum(score_potbor) - sum(score_dotbor) as goal_diff, (Select kod_champ from b_turniri where b_turniri.kod_turnir=b_Machove.kod_Turnir) as kod_champ FROM b_machove group by teamID, kod_champ) as allmachove group by allmachove.teamid, kod_champ order by allmachove.teamid)) as t2) as klasir JOIN b_teams clubs ON klasir.teamid = clubs.teamnumber order by TotalPoints desc, (score_dotbor-score_potbor) desc) t1 where t1.kod_champ='149'
Отбор Мачове Поб. Равни Загуби Вкарани Допуснати с/у Разлика Точки
Чавдар-Троян СБК880059735224516
Чардафон ОБК85034853889713
Дунав 2007 ССКБ85034774086913
Етър 49 СБК8206400462-6210
Раковски СБК8008223572-3498