Skip site navigation (1) Skip section navigation (2)

avg() from multiple columns

From: Miia Uski <miia(dot)uski(dot)155(at)student(dot)lu(dot)se>
To: pgsql-novice(at)postgresql(dot)org
Subject: avg() from multiple columns
Date: 2001-09-02 14:43:04
Message-ID: 3B924578.6FFD5A65@student.lu.se (view raw or flat)
Thread:
Lists: pgsql-novice
I have a question regarding taking the average value from several
columns.

I am trying to evaluate a survey with sql. I have one column per
question, and one row per answered survey. The answers can have values 1

- 4, unanswered questions have 0. I want to take the average from the
answers of several questions that belong to the same category. For one
question I can do like this:

igv=> select avg("1.2") from igvdata
igv-> where "1.2" > 0;

How do I go about to have averages for several columns? Do I have to
create views in order to avoid the "no answer"-values for each column?


Thanks in advance,

Miia




Responses

pgsql-novice by date

Next:From: Mark Tessier and Martine VeilleuxDate: 2001-09-02 15:54:18
Subject: installing postgres on SunOS 5.7 as non-priviledged user
Previous:From: Justin CliftDate: 2001-09-02 03:59:12
Subject: Re: SunOS 5.7 install

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group