View Full Version : Count help


sfairley
04-29-2008, 07:08 AM
Need help
When I try running the query below I get this error.

"Reserved error (-3025); there is no message for this error"

SELECT
totalelectricemergencies_1 = (SELECT Count(electricemergencies_1) FROM Phase_1 WHERE electricemergencies_1 ='Always'),
totalelectricemergencies_2 = (SELECT Count(electricemergencies_2) FROM Phase_1 WHERE electricemergencies_2 ='Always');

Any ideas?

Guus2005
04-29-2008, 08:02 AM
Use the DCount function to solve this problem.
SELECT
dcount("electricemergencies_1", "Phase_1", "electricemergencies_1 ='Always'") as totalelectricemergencies_1 ,
dcount("electricemergencies_2", "Phase_1", "electricemergencies_2 ='Always'") as totalelectricemergencies_2

This code is not tested in any way.
HTH:D

sfairley
04-29-2008, 08:05 AM
Cool it works thanks

sfairley
04-29-2008, 09:22 AM
What if I wanted to add 2 other fields to this? And did a where clause on the name?

SELECT csatraineesname, date
DCount("electricemergencies_1","Phase_1","electricemergencies_1 ='Always'") AS totalelectricemergencies_1,
DCount("electricemergencies_2","Phase_1","electricemergencies_2 ='Always'") AS totalelectricemergencies_2
WHERE (csatraineesname IN (SELECT csatraineesname FROM Phase_2 WHERE (csatraineesname = 'name')))

Guus2005
04-30-2008, 08:42 AM
What if I wanted to add 2 other fields to this? And did a where clause on the name?

SELECT csatraineesname, date
DCount("electricemergencies_1","Phase_1","electricemergencies_1 ='Always'") AS totalelectricemergencies_1,
DCount("electricemergencies_2","Phase_1","electricemergencies_2 ='Always'") AS totalelectricemergencies_2
WHERE (csatraineesname IN (SELECT csatraineesname FROM Phase_2 WHERE (csatraineesname = 'name')))
not quite
SELECT csatraineesname, date
DCount("electricemergencies_1","Phase_1","electricemergencies_1 ='Always' and csatraineesname = 'name'") AS totalelectricemergencies_1,
DCount("electricemergencies_2","Phase_1","electricemergencies_2 ='Always' and csatraineesname = 'name'") AS totalelectricemergencies_2HTH:D