Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Compute Balance In Query
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01379592
Message ID:
01379662
Vues:
33
I'm confused at your question. This is a checkbook register. The balance is the remainder of the money in the account after deposits are added and payments subtracted. Your query returns the value of the Payment or Deposit columns, whichever is not null. It's NOT doing the math.

Notice the should be column as opposed to the Balance column:
Payment               Deposit               Balance           Should be  
--------------------- --------------------- ----------        ------------
                      750.00                750.00		750.00
18.52                 			    18.52               731.48  
74.28                                       74.28		657.20		
42.16                                       42.16		615.04
100.00                                      100.00		515.04
NULL                  150.00                150.00		665.04
112.25                                      112.25		552.79
>>I'm not sure if I'm explaing what I want. This query does not return the results I want:
>>
>>
>>Payment               Deposit               Reconciled Balance
>>--------------------- --------------------- ---------- ------------
>>NULL                  750.00              NULL       750.00
>>18.52                 NULL                  NULL       18.52
>>74.28                 NULL                  NULL       74.28
>>42.16                 NULL                  NULL       42.16
>>100.00                NULL                  NULL       100.00
>>NULL                  150.00               NULL       150.00
>>112.25                NULL                  NULL       112.25
>>
>>
>>The last column should be have the balance, not the value of the despoit or payment column.
>
>How the balance should be calculated?
>
>Can you post some sample data and what exactly do you want to get?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform