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
| DECLARE @Titre varchar(9)
DECLARE @Sens varchar(1)
DECLARE @Qte int
DECLARE Curs_TOPS CURSOR FOR
--Séléction des instructions
SELECT T_Titres.CodeValeur, SUM(CONVERT(decimal, REPLACE(T_Operations.Quantite, ',', '.'))) as Qte,T_Operations.Sens
FROM T_Contreparties INNER JOIN
T_Operations ON T_Contreparties.CodeCtpie = T_Operations.CodeCtpie RIGHT OUTER JOIN
T_Titres ON T_Operations.CodeValeur = T_Titres.CodeValeur
GROUP BY T_Operations.Sens, T_Titres.CodeValeur
BEGIN
OPEN Curs_TOPS
END
FETCH Curs_TOPS INTO @Titre,@Qte,@Sens
WHILE @@FETCH_STATUS<>-1
BEGIN
if @Sens='A'
set @Qte=@Qte
IF @Sens='V'
set @Qte=@Qte*-1
FETCH Curs_TOPS INTO @Titre,@Qte,@Sens
END
CLOSE Curs_TOPS
DEALLOCATE Curs_TOPS |
Partager