Code: Select all
SELECT RDT, RDTAB, COUNT(EI) AS SOMMAMD FROM L0928 GROUP BY RDT, RDTAB
how to?
Code: Select all
SELECT RDT, RDTAB, COUNT(EI) AS SOMMAMD FROM L0928 GROUP BY RDT, RDTAB
???, sorryHansV wrote:Just add a comma and COUNT(fieldname) for each field that you want to count.
Keep in mind that COUNT(fieldname) will return the number of records with non-blank values in that field. If the fields are all filled in, the count will be the same for all fields.
Code: Select all
SELECT L0928.RDT, L0928.RDTAB, Count(L0928.EI) AS SOMMAMDEI, Count(L0928.UP) AS SOMMAMDUP, Count(L0928.CI) AS SOMMAMDCI, Count(L0928.EP) AS SOMMAMDEP
FROM L0928
GROUP BY L0928.RDT, L0928.RDTAB;
HansV wrote:Here is the SQL for a query based on the Orders table in the Northwind database that counts three fields by employee:
SELECT fkeyEmployeeID, Count(fkeyCustomerID) AS CountCustomers, Count(fkeyShipVia) AS CountShipVia, Count(curFreight) AS CountFreight
FROM tblOrders
GROUP BY fkeyEmployeeID;
Here is the query in design view:
And in datasheet view:
As you see, the three count fields have the same numbers in the first row, and also the same numbers in the second row, etc.