Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Counting in an SQL statement
Versions des environnements
Hi,
I have an SQL select statement where I am joining two tables. I want to be able to count for a field equaling a certain value. I've tried many variations of the COUNT and SUM functions in my SQL statement but I haven't got it to work. here is my SQL select statement:
SELECT customerorder.jobnumbercode , Sum(Customerlineitem.packageindicatorquantity) AS PkgCount,;
Sum(Customerlineitem.packageindicatorretouchflag) AS Retouch,;
Sum(Customerlineitem.packageindicatorsoftfocusflag) AS SoftFocus,;
Sum(Customerlineitem.packageindicatoreffectflag) AS Effects,;
**Sum(Customerlineitem.packageindicatorcolortypecode="COLOR") As ColorType;
FROM customerorder ;
INNER JOIN customerlineitem ;
ON Customerorder.orderkey = Customerlineitem.orderkey;
WHERE Customerorder.ordercanceledflag = 0;
GROUP BY customerorder.jobnumbercode
I've indicated what line doesn't work (**). IF anyone has any ideas on how to fix this, I would very much appreciate it.
Thanks!
Tim
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement