Re: counting no. of records matching condition.

2001-09-04 Thread wsheldah
I think you can do this in two queries and a little perl. For the first two: select type, count(*) from mytable group by type That will give you a row for each type with the number in that type. Use perl to add them up to get the total number. Watch out for rows where type is null. For

RE: counting no. of records matching condition.

2001-09-01 Thread Steve Howard
Unless I'm missing something, you cannot do this all with one query. You can do it with two queries, but I'm not sure that would be any more efficient than handling each with a separate query. The reason you can't get it all in one query is that one of these will require a Group by clause, and

RE: counting no. of records matching condition.

2001-09-01 Thread Robert Goff
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 SELECT COUNT(*) as TOTAL, (SELECT COUNT(*) FROM Table WHERE status = 'P') as PRESENT, (SELECT COUNT(*) FROM Table WHERE STATUS IN ('L', 'A', 'O')) AS ABSENT FROM Table I don't think sub-selects are suppored in MySQL, unless