Re: what's wrong with this code? - Mailing list pgsql-novice

From James David Smith
Subject Re: what's wrong with this code?
Date
Msg-id CAMu32ABH9end5EUqYYsNi37G3sWjuZiLAHgyHRNiOCW3sJGPRA@mail.gmail.com
Whole thread Raw
In response to Re: what's wrong with this code?  ("David G. Johnston" <david.g.johnston@gmail.com>)
List 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.g.johnston@gmail.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@panix.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@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice

pgsql-novice by date:

Previous
From: amul sul
Date:
Subject: Re: what's wrong with this code?
Next
From: "Birchall, Austen"
Date:
Subject: PGDATA on Windows