Advertisement
asahraoui

7) Lister pour chaque Equipe le Nombre de point

Oct 23rd, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.14 KB | None | 0 0
  1. select E.CodeEquipe, E.NomEquipe, Sum([Nombre de point]) as [Nombre de point]
  2. from    (
  3.         select CodeEquipe, Sum(NombreMatcheGagnée*3) as [Nombre de point]
  4.         from    (
  5.                 select CodeEquipeLocale as CodeEquipe, Count(*) as NombreMatcheGagnée
  6.                 from Matche
  7.                 where NombreButLocale>NombreButVisiteure
  8.                 group by CodeEquipeLocale
  9.                 union
  10.                 select CodeEquipeVisiteure as CodeEquipe, Count(*) as NombreMatcheGagnée
  11.                 from Matche
  12.                 where NombreButLocale<NombreButVisiteure
  13.                 group by CodeEquipeVisiteure
  14.                 ) MatcheGagnée
  15.         group by CodeEquipe
  16.         union
  17.         select CodeEquipe, Sum(NombreMatcheEgalité) as [Nombre de point]
  18.         from    (
  19.                 select CodeEquipeLocale as CodeEquipe, Count(*) as NombreMatcheEgalité
  20.                 from Matche
  21.                 where NombreButLocale=NombreButVisiteure
  22.                 group by CodeEquipeLocale
  23.                 union
  24.                 select CodeEquipeVisiteure as CodeEquipe, Count(*) as NombreMatcheEgalité
  25.                 from Matche
  26.                 where NombreButLocale=NombreButVisiteure
  27.                 group by CodeEquipeVisiteure
  28.                 ) MatcheEgalité
  29.         group by CodeEquipe
  30.         ) Resultat inner join Equipe E on Resultat.CodeEquipe=E.CodeEquipe
  31. group by E.CodeEquipe, E.NomEquipe
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement