Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Basic SQL clause question
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00700804
Message ID:
00700833
Vues:
10
Yes, you can.
...
    ROUND(Sum(IIF(BETWEEN(Reservations.date, OldFrom, OldTo), 1, 0)*100/ ;
        Sum(IIF(BETWEEN(Reservations.date, ReportFrom, ReportTo), 1, 0), 2) AS percent, ; 
...
However, it would be simplier to use second select for that.

>Thx Sergey, you nailed it again.
>Do you think i can also retrieve in this same SELECT the percentage growth ( or reduction ) between CurRes and OldRes?
>
>
>>Try
SELECT ;
>>    Clients.ClientName, ;
>>    Sum(IIF(BETWEEN(Reservations.date, ReportFrom, ReportTo), 1, 0) as CurRes,;
>>    Sum(IIF(BETWEEN(Reservations.date, ReportFrom, ReportTo), Reservations.Amount, 0) as CurAmount, ;
>>    Sum(IIF(BETWEEN(Reservations.date, OldFrom, OldTo), 1, 0) as OldRes,;
>>    Sum(IIF(BETWEEN(Reservations.date, OldFrom, OldTo), Reservations.Amount, 0) as OldAmount, ;
>>  FROM Reservations JOIN Clients ;
>>        ON Reservations.ClientCode=Clients.Code  ;
>>  WHERE between( Reservations.date, ReportFrom, ReportTo ) ;
>>         OR between( Reservations.date, OldFrom, OldTo ) ;
>>  GROUP BY Clients.Code ;
>>INTO CURSOR crsResult	
>>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform