Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Statement
Message
 
À
11/02/2007 09:53:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
01194505
Message ID:
01194544
Vues:
4
>Hi Borislav
>
>>Can you post some example data and desired result from it?
>
>
>  date      CustomerID  DocType   debcre  ammount
>01.01.2005       0001   Invoice      +     100.00
>01.02.2005       0001   Payment      -      20.00
>01.03.2005       0001   Invoice      +      50.00
>01.01.2006       0001   Payment      -      30.00
>01.02.2006       0001   Invoice      +     100.00
>
>....             0002
>....             0003.....
>.....all Customers Movements
>
>Result:
>
>   Customer 0001
>
>   date                 deb      cre
>         Last Years     150       20
>01.01.2006   Payment              30
>01.02.2006   Invoice    100
>
>   Customer 0002....
>
>These result can by filtered between dates and customers
>
>
>João Batista
SELECT CustomerID, 
      'Last years'  AS DocType,
      SUM(CASE WHEN debcre  = '+' THEN ammount ELSE 0 END) AS Deb,
      SUM(CASE WHEN debcre  = '-' THEN ammount ELSE 0 END) AS Cre
GROUP BY CustomerID
WHERE YEAR(Date) < ????????????
UNION ALL
SELECT CustomerID, 
      DocType,
      CASE WHEN debcre  = '+' THEN ammount ELSE 0 END AS Deb,
      CASE WHEN debcre  = '-' THEN ammount ELSE 0 END AS Cre
WHERE CustomerID = ?????? AND
      Date = ?????
ORDER BY CustomerID
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform