1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
Select DISTINCT
Pdt.IDMERCURIALE as ID,
Pdt.Designation as LIB,
Four_Pdt_Moins.rs as RS_Moins,
Four_Pdt_Moins.Prix_Moins as P_moins,
Four_Pdt_Plus.rs as RS_Plus,
Four_Pdt_Plus.Prix_Plus as P_Plus
From
mercuriale Pdt inner join
(Select
rs,
id_Pdt,
Min(Prix) as Prix_Moins
From
(Select
Four.Raison_Sociale as RS
,Pdt_Four.IDMERCURIALE as Id_Pdt
,Pdt_Four.Prix as Prix
From
mercuriale Pdt join MERCURIALE_FOURNISSEUR Pdt_Four On Pdt_Four.IDMERCURIALE = Pdt.IDMERCURIALE
JOIN FOURNISSEUR Four On Four.IDFOURNISSEUR = Pdt_Four.IDFOURNISSEUR
) Four_Pdt
Group By rs, Id_Pdt
) Four_Pdt_Moins On Four_Pdt_Moins.Id_pdt = Pdt.IDMERCURIALE
Left outer join
(Select
rs,
Id_Pdt,
Max(Prix) as Prix_Plus
From
(Select
Four.Raison_Sociale as RS
,Pdt_Four.IDMERCURIALE as Id_Pdt
,Pdt_Four.Prix as Prix
From
mercuriale Pdt join MERCURIALE_FOURNISSEUR Pdt_Four On Pdt_Four.IDMERCURIALE = Pdt.IDMERCURIALE
JOIN FOURNISSEUR Four On Four.IDFOURNISSEUR = Pdt_Four.IDFOURNISSEUR
) Four_Pdt
Group By rs, Id_Pdt
) Four_Pdt_Plus On Four_Pdt_Plus.Id_pdt = Pdt.IDMERCURIALE
where
Pdt.Desactive = 0
and Pdt.IDMERCURIALE in(3,15) |