Re: what's wrong with this code?

From: James David Smith <james(dot)david(dot)smith(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Jude DaShiell <jdashiel(at)panix(dot)com>
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: what's wrong with this code?
Date: 2015-06-16 12:52:17
Message-ID: CAMu32ABH9end5EUqYYsNi37G3sWjuZiLAHgyHRNiOCW3sJGPRA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

What is even the error you are getting? What doesn't run?

I'd start with sorting out your aliases of the column names. For example
instead of:

pop_stdev(blood_sugar) as "population deviation blood sugar: "

I'd use:

pop_stdev(blood_sugar) AS pop_dev_blood_sugar

Though this probably isn't returning an error, it's not good practice.

On Tue, 16 Jun 2015 at 13:49 David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
wrote:

> Do you truly expect someone to help given a long query they cannot run and
> no other information?
>
> On Tuesday, June 16, 2015, Jude DaShiell <jdashiel(at)panix(dot)com> wrote:
>
>> cut here.
>> --- query: phealth.sql
>> --- by Jude DaShiell & Tim Chase
>> --- Last Updated: 2014-10-08 12:24
>> select
>> min(date) as "starting date:",
>> max(date) as "ending date:",
>> count(cystalic_pressure) as "Cystalic sample size:",
>> round(avg(cystalic_pressure),1) as "Average Cystalic Pressure:",
>> min(cystalic_pressure) as "Min Cystalic Pressure:",
>> max(cystalic_pressure) as "Max cystalic Pressure:",
>> pop_stdev(cystalic_pressure) as "population deviation cystalic pressure:
>> ",
>> (select cystalic_pressure
>> from health
>> group by cystalic_pressure
>> order by count(cystalic_pressure) desc, cystalic_pressure
>> limit 1) as "Mode Cystalic Pressure:",
>> count(dyastalic_pressure) as "dyastalic sample size:",
>> round(avg(dyastalic_pressure),1) as "Average Dyastalic Pressure:",
>> min(dyastalic_pressure) as "Min Dyastalic Pressure:",
>> Max(dyastalic_pressure) as "Max Dyastalic Pressure:",
>> pop_stdev(dyastalic_pressure) as "population deviation dyastalic
>> pressure: ",
>> (select dyastalic_pressure
>> from health
>> group by dyastalic_pressure
>> order by count(dyastalic_pressure) desc, dyastalic_pressure
>> limit 1) as "Mode Dyastalic Pressure:",
>> count(pulse) as "Pulse Sample Size:",
>> round(avg(pulse),1) as "Average Pulse:",
>> min(pulse) as "Min Pulse:",
>> max(pulse) as "Max Pulse:",
>> pop_stdev(pulse) as "population deviation pulse: ",
>> (select pulse
>> from health
>> group by pulse
>> order by count(pulse) desc, pulse
>> limit 1) as "Mode Pulse:",
>> count(blood_sugar) as "Sugar Sample Size:",
>> round(avg(blood_sugar),1) as "Average Sugar:",
>> min(blood_sugar) as "Min Sugar:",
>> max(blood_sugar) as "Max Sugar:",
>> pop_stdev(blood_sugar) as "population deviation blood sugar: ",
>> (select blood_sugar
>> from health
>> group by blood_sugar
>> order by count(blood_sugar) desc, blood_sugar
>> limit 1) as "Mode Sugar:"
>> from health;
>>
>> --
>>
>>
>>
>> --
>> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-novice
>>
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message amul sul 2015-06-16 12:53:10 Re: what's wrong with this code?
Previous Message David G. Johnston 2015-06-16 12:48:47 Re: what's wrong with this code?