Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index



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: users+help@global.libreoffice.org
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

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.