Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with recursive SQL Statement
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01021429
Message ID:
01021537
Views:
17
Try to run select using your previous result as derived table, SUM(Balance) and GROUP BY A.Descarga.

>Sorry I realized that after I hit the send button. In reality I changed my spanish field names to english in the original msg and forgot to do it again in the last one.
>
>What I'm trying to accomplish here (as you might have guessed) is an accounting balance sheet. I want all the accounts.
>
>
>>You just switched field names on me. Are you trying to confuse me? :)
>>BTW, do you want to include all acounts or only main accounts?
>>
>>>That's correct! I've modified the statement and now it looks like this but for some reason I still don't get all the correct balances.
>>>
>>>
>>>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))
>>>
>>>
>>>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform