SQL Histogram
From: M.W. Stern <M.W.Stern_at_massey.ac.nz>
Date: Sun, 6 Dec 92 22:07:16 GMT
Message-ID: <1992Dec6.220716.16006_at_massey.ac.nz>
GROUP BY LENGTH(SURNAME);
Date: Sun, 6 Dec 92 22:07:16 GMT
Message-ID: <1992Dec6.220716.16006_at_massey.ac.nz>
Just thought I'd post this small piece of SQL that displays a histogram, in case anyone is interested.
This example displays a histogram of the length of surnames in a table called FARMS, but the technique could be used for other applications.
SELECT AVG(LENGTH(SURNAME)) LENGTH,
SUBSTR('****************************************',1,TRUNC(COUNT(*)/20)) HISTFROM FARMS
GROUP BY LENGTH(SURNAME);
Mark Stern | Internet: Analyst/Programmer | M.W.Stern_at_massey.ac.nz Massey University | NEW ZEALAND |Received on Sun Dec 06 1992 - 23:07:16 CET
==================================================