Michael Swierczek wrote:
> On 4/25/07, Michael Swierczek <mike(dot)swierczek(at)gmail(dot)com> wrote:
>> That's exactly what I needed. I completely missed that it would
>> be possible with the tablefunc/crosstab. Since you're the main
>> (only?) name I see associated with that code, I'm sure you would know.
> I spoke too soon, there's an additional factor at play that
> complicates things.
> Most of the questions take a single answer, but the multiple select
> questions can have several answers. So for a regular question with
> code 'drug', a given survey_event can have 0 or 1 entries in the
> answer table with question_code 'drug'. For a multiple select
> question like, 'health', 0-7 entries are possible in the answer table,
> and we want them exported as columns 'health0', 'health1', 'health2'
> through 'health7' and each column populated according to whether that
> section of the multiple select was chosen.
It seems to me that if you really want health0 and health1 tracked
independently, they should each be considered separate questions. Then
the existing code would "just work". Perhaps if it is important to tie
those "healthN" questions together, you could have some other attribute
for questions that allows grouping. So, for example, grp_id = 0 means
this question is "stand alone" and grp_id > 0 is a grouped question.
create table survey_question_grps (
insert into survey_question_grps values
(0, 'stand alone question'),
create table survey_question (
insert into survey_question values
In response to
pgsql-novice by date
|Next:||From: Lukas||Date: 2007-04-26 10:21:47|
|Subject: pg_dump slave DB|
|Previous:||From: Reinhard Hnat||Date: 2007-04-26 10:08:08|
|Subject: How long does commit take?|