Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
[Postgresql] Group and get daily average of multiple columns
Author Summary
X31nar is in Postgresql
Post Body

So I have a water_nutrient (among others) table with a lot of columns with nutrient values. The water nutrient data was ~roughly~ measured every 2 hours. I want to group the data and get the average of x nutrient daily.

I was able to figure out how to group and get the average and it seems to be working fine. My problem is that there are way too many columns to write inside the select statement, so I was wondering if there's a more concise "sql-esque" way that allows me to get the average of all columns without having to write a bazillion of "avg(thing) as avg_thing".

Here's what I have showing only two columns:

select 
    date_trunc('day',datetimestamp), 
    avg(no3f) as avg_no3f, 
    avg(no23f) as avg_no23f,
    station_id
from water_nutrient 
-- where station_id = 2
group by date_trunc('day',datetimestamp), station_id
order by date_trunc

Author
Account Strength
90%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,158
Link Karma
22
Comment Karma
1,136
Profile updated: 3 days ago
Posts updated: 8 months ago

Subreddit

Post Details

Location
We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago