Re: Not able to understand how to write group by - Mailing list pgsql-general

From Arup Rakshit
Subject Re: Not able to understand how to write group by
Date
Msg-id 6503549.8QC24WY2Zc@linux-wzza.site
Whole thread Raw
In response to Re: Not able to understand how to write group by  (David G Johnston <david.g.johnston@gmail.com>)
List pgsql-general
On Wednesday, July 02, 2014 12:28:04 PM David G Johnston wrote:
> Steve Crawford wrote
>

>
> Are you sure this is what you want?
>
> Since there are two columns you will have to either use a CASE or a select
> to facilitate calculating the values for each of the columns.
>
> SELECT gender, answer1_avg, answer2_avg
> FROM (SELECT DISTINCT gender FROM ...) gn
> LEFT JOIN (SELECT gender, answer1_avg FROM ...) ans1 USING (gender)
> LEFT JOIN (SELECT gender, answer2_avg FROM ...) ans2 USING (gender)
>
> You could also try learning "crosstab" from the "tablefunc" extension:
>
> http://www.postgresql.org/docs/9.3/interactive/tablefunc.html
>
> I do not see how a single "participant count" column will provide a
> meaningful piece of data...
>
> David J.
>

This is a summary report of a specific questions answers gender wise.

Q is "How much you learned today?"

how many female participants in answering the question Q. If they answers,
then average of A1 and average of A2 ( A1. A2 means two types of answers).
They put the numbers in those 2 types. They are allowed to choose either of
the answer type, but not the both. So, if any female F1 provides 80 to A2, in
that day, she wouldn't be allowed to answer for A1.

Same stands for male and <non-gender> also.

--
================
Regards,
Arup Rakshit
================
Debugging is twice as hard as writing the code in the first place. Therefore,
if you write the code as cleverly as possible, you are, by definition, not
smart enough to debug it.

--Brian Kernighan


pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: how to create multiple databases running in different dirs
Next
From: David G Johnston
Date:
Subject: Re: Not able to understand how to write group by