Важен е пътят не целта!
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 = '7' and sezon='2022' and f_kod=111346 and true and ligaf_kod='111347' order by kod_otbor asc

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

ББЛ "А" група Център
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='2845') or (kod_potbor='2845')) and sezon='2022'
Домакин Гост Т. дом. Т. гост Дата Град Зала Час Мач
Чавдар-Троян СБКЧардафон ОБК002022-03-19ТроянЧавдар16:00-18:00 3014
Чардафон ОБКВидабаскет СБК78562022-10-16ТроянЧавдар14:00-16:00 2985
Локомотив 99 СБКЧардафон ОБК65752022-11-06Горна ОряховицаНикола Петров16:00-18:00 2988
Чардафон ОБКДунав - Русе 2016 ССКБ83862022-11-06ГабровоОрловец16:00-18:00 2990
Чавдар-Троян СБКЧардафон ОБК87542022-11-20ГабровоОрловец17:00-19:00 2993
Видабаскет СБКЧардафон ОБК56582022-12-18Горна ОряховицаНикола Петров14:00-16:00 2996
Чардафон ОБКЛокомотив 99 СБК79602023-01-08ГабровоОрловец16:00-18:00 2999
Дунав - Русе 2016 ССКБЧардафон ОБК101662023-01-15РусеДунав14:00-16:00 3000
Чардафон ОБКЧавдар-Троян СБК002023-01-29ТроянЧавдар16:00-18:00 3003
Чардафон ОБКВидабаскет СБК002023-02-19ГабровоОрловец16:00-18:00 3007
Локомотив 99 СБКЧардафон ОБК002023-02-26РусеДунав14:00-16:00 3008
Чардафон ОБКДунав - Русе 2016 ССКБ002023-03-12Горна ОряховицаНикола Петров16:00-18:00 3011

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

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='157'
Отбор Мачове Поб. Равни Загуби Вкарани Допуснати с/у Разлика Точки
Чавдар-Троян СБК75025374835412
Дунав - Русе 2016 ССКБ65015094307911
Чардафон ОБК7403493511-1811
Видабаскет СБК6303428380489
Локомотив 99 СБК8008502665-1638