Re: weekdays display in postgresql

From: Jude DaShiell <jdashiel(at)panix(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: weekdays display in postgresql
Date: 2014-08-30 10:11:21
Message-ID: alpine.NEB.2.00.1408300600180.1596@panix1.panix.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

My reason for putting the weekday number as the last field in chealth.sql
shared earlier is that whenever I put it just after date, the phealth.sql
script I'll share with the list now always threw an error and wouldn't
provide output for me.
cut here.
--- query: phealth.sql
--- by Jude DaShiell & Tim Chase
--- Last Updated: 2014-07-31 06:51
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:",
(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:",
(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:",
(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:",
(select blood_sugar
from health
group by blood_sugar
order by count(blood_sugar) desc, blood_sugar
limit 1) as "Mode Sugar:"
from health;

The last script used to actually populate the health table is made by
using the uhealth.sh script I shared earlier. So for weekdays in this
context to really be useful, as soon as a date is keyed into the system a
field adjacent to date would have to take the date as input and generate
the weekday and populate the adjacent weekday field. Where to do this and
with what code I do not yet know.

Browse pgsql-novice by date

  From Date Subject
Next Message mkohls 2014-09-02 20:57:08 C partition management
Previous Message David G Johnston 2014-08-30 01:00:22 Re: logical fields with defaults