Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with recursive SQL Statement
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01021429
Message ID:
01021547
Vues:
23
This query should give you all main accounts.
SELECT dt1.Descarga, SUM(Balance) FROM 
(
Select A.Cuenta,A.Descripcion,
Isnull((Select Balance From CNTBal03 Where Cuenta=A.Cuenta And Periodo=12 and Fiscal='2003' ),0)
+Isnull((Select Sum(Debito-Credito) From CNTDET02 Where Cuenta=A.Cuenta And Periodo=1 And Fiscal='2004'),0)+
Isnull((Select Sum(Debito-Credito) From CNTDET02
Where Cuenta IN (Select Cuenta From CNTCuentas Where lTrim(rTrim(Descarga)) =
lTrim(rTrim(A.Cuenta)) And Periodo=1 And Fiscal='2004')),0)
As Balance, A.Descarga
From cntCuentas A Order By rTrim(lTrim(A.Cuenta))
) dt1
GROUP BY dt1.Descarga
>Can you give me an example? I'm sorry, new to SQL syntax :)
>
>>Try to run select using your previous result as derived table, SUM(Balance) and GROUP BY A.Descarga.
>>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform