Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Conditional COUNT() ?
Message
De
29/06/2004 15:29:05
 
 
À
29/06/2004 15:21:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00918618
Message ID:
00918620
Vues:
9
>How do I create an SQL statement that has a count of all records, plus a conditional count of the number that meet a specific criteria?
>
>This gives me the count(*) value twice.
>
>SELECT OrderID, COUNT(*), COUNT(Lineitems.Quantity > 500) FROM Orders INNER JOIN Lineitems on Lineitems.orderid = Orders.orderid GROUP BY 1
>
>
>Once that works, will using a view parameter(?vp_bonusamount) work instead of the fixed numeric amount?
>

Chris,

Something like this will work...
SELECT OrderID, COUNT(*), sum(iif(lineItems.quantity > 500, 1, 0)) as bigQuantity ;
   FROM Orders  ;
   INNER JOIN Lineitems on Lineitems.orderid = Orders.orderid ;
   GROUP BY 1
Yes, the 500 can be a view parameter.
Steve Gibson
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform