La requête exécutée sur 32 et 64 bits (utilisation de la fonction PIVOT)...
--SET STATISTICS IO ON
--SET STATISTICS PROFILE ON
USE ReadySAProduction
select serverproperty ('MachineName') as " ."
union all
select @@version
union all
select serverproperty ('Edition')
go
SELECT Client_Nom as "Nom du client",
cast(COALESCE(Emp1,0) as numeric(8,2)) as "H. LUTZ",
cast(COALESCE(Emp2,0) as numeric(8,2)) as "A. ANDERS",
cast(COALESCE(Emp3,0) as numeric(8,2)) as "C. CORBEL",
cast(COALESCE(Emp4,0) as numeric(8,2)) as "D. ROUZE",
cast(COALESCE(Emp5,0) as numeric(8,2)) as "O. CARLET",
cast(COALESCE(Emp6,0) as numeric(8,2)) as "K. ROUDIER",
cast(COALESCE(Emp7,0) as numeric(8,2)) as "A. PIROT",
cast(COALESCE(Emp8,0) as numeric(8,2)) as "E. THEODORE"
FROM (
SELECT Commande_ClientID,
[80157] AS Emp1, [50159] AS Emp2, [30107] AS Emp3, [60165] AS Emp4,
[80114] AS Emp5, [20098] AS Emp6, [30091] AS Emp7, [60188] AS Emp8
FROM
(SELECT Commande_MontantTotal, Commande_EmployeID, Commande_ClientID
FROM SchemaReadySA.Commande
WHERE Commande_Datecommande between '01-01-2004' and '03-31-2004') p
PIVOT
( avg ( Commande_MontantTotal )
FOR Commande_EmployeID IN
( [80157],[50159],[30107],[60165],
[80114],[20098],[30091],[60188]
)
) AS pvt
) AS vue
JOIN SchemaReadySA.Client ON Commande_ClientID=Client_ID
WHERE Emp1 is not null or Emp2 is not null or Emp3 is not null or
Emp4 is not null or Emp5 is not null or Emp6 is not null or
Emp7 is not null or Emp8 is not null
order by client_nom asc