| From: | Ron <ronljohnsonjr(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: computing z-scores |
| Date: | 2018-05-24 15:26:44 |
| Message-ID: | a220c1bf-ab2b-d230-7526-442716f3db5f@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-hackers |
On 05/24/2018 10:15 AM, Martin Mueller wrote:
> You construct a z-score for a set of values by subtracting the average from the value and dividing the result by the standard deviation. I know how to do this in a two-step procedure. First, I compute the average and standard deviation. In a second run I use the formula and apply it to each value.
>
> Is there a way of doing this in a single-step procedure or can you chain the two parts together in one query? This goes beyond my SQL competence.
What about this?
SELECT value, (value - AVG(value))/stddev(value) as zvalue
FROM sometable
WHERE some conditions
GROUP by value
--
Angular momentum makes the world go 'round.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2018-05-24 15:30:24 | Re: computing z-scores |
| Previous Message | David G. Johnston | 2018-05-24 15:22:26 | Re: computing z-scores |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2018-05-24 15:30:24 | Re: computing z-scores |
| Previous Message | David G. Johnston | 2018-05-24 15:22:26 | Re: computing z-scores |