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

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

Юноши до 19 години - Елитна дивизия
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='2844') or (kod_potbor='2844')) and sezon='2022'
Домакин Гост Т. дом. Т. гост Дата Град Зала Час Мач
Доростол СБКЧардафон ОБК95562022-10-09СилистраДръстър12:00-14:00 2967
Чардафон ОБКДелфин СБК108562022-10-23ГабровоОрловец12:00-14:00 2969
Дунав - Русе 2016 ССКБЧардафон ОБК87692022-11-24РусеДунав12:00-14:00 2970
Чардафон ОБКЧерно море Тича СБК67792022-12-09ГабровоОрловец12:00-14:00 2975
Чардафон ОБКДоростол СБК002022-12-19ГабровоОрловец13:00-15:00 2978
Чардафон ОБКДунав - Русе 2016 ССКБ60712023-01-22ГабровоОрловец13:00-15:00 2981
Делфин СБКЧардафон ОБК002023-01-27БургасБойчо Брънзов13:00-15:00 2980

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

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='152'
Отбор Мачове Поб. Равни Загуби Вкарани Допуснати с/у Разлика Точки
Черно море Тича СБК5401417333849
Дунав - Русе 2016 ССКБ5401379310699
Доростол СБК4301338259797
Чардафон ОБК5104360388-286
Делфин СБК5005283487-2045