COUNT a total for each diagnosis present, not just where diagnosis=ptsd.

SELECT "Diagnosis", COUNT (*) AS "Count Patients" 
FROM "Patients" 
GROUP BY "Diagnosis"
HAVING COUNT(*)> 10
ORDER BY "Count Patients" DESC

Selects the count for each type of diagnosis.
The last 2 clauses are optional.
HAVING does the same with the outgoing results like the WHERE clause does
with the incoming table data.
ORDER BY can order by arbitrary columns, even when they are not in the
SELECT.

Each SELECTed field that is not an aggregation (sum,count,min,max,,...)
needs to  be repeated in the group clause. 
Each unique combination of the grouped fields gets the function results.
SELECT A,B,C,  SUM(X),COUNT(Y),MAX(Z)
FROM BLAH
GROUP BY A,B,C
gets the sum(x), count(y), max(z) for each combination of A,B,C



--
View this message in context: 
http://nabble.documentfoundation.org/BASE-Query-Report-tp3298830p3300701.html
Sent from the Users mailing list archive at Nabble.com.

-- 
For unsubscribe instructions e-mail to: [email protected]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Reply via email to