For mysql you can do in this way ,but i have no idea how to write it for ADODB
SELECT
hcp_id,
CASE WHEN COALESCE(SUM(`status` ='False')) =0 THEN 1
ELSE 0 END `all_true`
FROM
t
GROUP BY hcp_id
Question
I have a table with the following columns:
id hcp_id status
1 10 True
2 10 False
3 10 True
4 20 True
5 20 True
6 20 True
7 30 False
8 30 True
9 30 True
The results should be:
Results:
hcp_id
10 = 0
20 = 1
30 = 0
Basically, if all entries for a specific hcp_id has no False status, count it as one. After which, sum all the results:
Result = 0 + 1 + 0
Also, it has to work in ADODB with mySQL ODBC for VB6
Is this possible as well as doing it in a single query?
Other things to consider is speed since this will be done in a table with at least 14,000 or more records.
La solution
For mysql you can do in this way ,but i have no idea how to write it for ADODB
SELECT
hcp_id,
CASE WHEN COALESCE(SUM(`status` ='False')) =0 THEN 1
ELSE 0 END `all_true`
FROM
t
GROUP BY hcp_id