Select A.Code, Count(Iif(A.SB="B", a.code,000000000)) As sbbtm, ; count(Iif(A.SB="S", A.code,000000000)) As sbstm; FROM M_070219 A ; where !EMPTY(A.CODE) ; ORDER By A.Code ; group By A.Code ; INTO Cursor cSb_1 ReadwriteIn the case I get the same count for A.SB = "B" and A.SB="S" where infact they shoud have different counts.