Hi members
SELECT Codearticle, Count(Codearticle) AS CompteDeQte, Min(PrixRevient) AS [Min1], Max(PrixRevient) AS [Max1],convert(numeric,Max(PrixRevient))/convert(numeric,Min(PrixRevient)) as coefficient
FROM DetailReceptionFrs WHERE (Numero='st200005')
GROUP BY Codearticle
HAVING (Count(Codearticle)>1)
i want reuse in place of Max(PrixRevient) just put [Max1]
also i want use it in union select query
SELECT "BL" AS Type, dbo_F_DOCLIGNE.DO_Date AS [Date], dbo_F_DOCLIGNE.CT_Num AS Client,
(dbo_F_COMPTET.CT_Intitule) AS Intitule, dbo_F_DOCLIGNE.DO_Piece AS N,
Sum(dbo_F_DOCLIGNE.DL_MontantTTC) AS MontantTTC
FROM dbo_F_DOCLIGNE INNER JOIN dbo_F_COMPTET ON dbo_F_DOCLIGNE.CT_Num = dbo_F_COMPTET.CT_Num
WHERE (((dbo_F_DOCLIGNE.DO_Type)=3) AND ((dbo_F_DOCLIGNE.DO_Date)=Date()))
GROUP BY dbo_F_DOCLIGNE.DO_Date, dbo_F_DOCLIGNE.CT_Num, dbo_F_DOCLIGNE.DO_Piece,dbo_F_COMPTET.CT_Intitule
ORDER BY dbo_F_DOCLIGNE.DO_Piece
union
SELECT "BL: RECAP" AS Type, "" AS [Date], "" AS Client, "" AS Intitule, Count(bl.N) AS N, Sum(bl.MontantTTC) AS MontantTTC
FROM BL
i want reuse BL in second select query but thats not work
please help how i can manage to use every renamed column or row