Skip to main content
2 de 2
mejor visualización del código
fredyfx
  • 13.2k
  • 11
  • 33
  • 65

Ya quedo resuelto les dejo la consulta por si a alguien mas le interesa. Saludos!!!

SELECT 
     T2.[AcctCode], 
     T2.[AcctName], 
     (SELECT 
           SUM(I.Debit - I.Credit)
      FROM 
           JDT1 I
      WHERE 
           T1.[Account] = I.Account 
           AND I.RefDate < '2017-02-01')
     AS SI, 
     SUM(T1.[Debit]) AS DEBITO, 
     SUM(T1.[Credit]) AS CREDITO, 
     (SELECT 
            SUM(F.Debit - F.Credit)
      FROM 
            JDT1 F
      WHERE 
            T1.[Account] = F.Account 
            AND F.RefDate < '2017-03-01')
     AS SALDO
FROM 
     OJDT T0  
     INNER JOIN JDT1 T1 ON T0.[TransId] = T1.[TransId] 
     INNER JOIN OACT T2 ON T1.[Account] = T2.[AcctCode] 
WHERE 
     T1.[Account] >= '11020000' AND 
     T1.[Account] <='11020105' AND 
     T1.[RefDate] >='2017-02-01' AND 
     T1.[RefDate] <= '2017-02-28' 
GROUP BY 
     T2.[AcctCode], T2.[AcctName], T1.[Account]
ORDER BY 
     T2.[AcctCode]