Create a table B with data coming from table A - Mailing list pgsql-general

From lhaj.merigh@gmail.com
Subject Create a table B with data coming from table A
Date
Msg-id 1181597039.682005.104060@k79g2000hse.googlegroups.com
Whole thread Raw
Responses Re: Create a table B with data coming from table A  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
List pgsql-general
My original table is like that:

ID    A1    A2    A3    cnt
1234    1    0    0    4
1234    1    0    1    8
1234    1    1    1    5
1235    1    0    0    6
1235    1    0    1    7
1235    1    1    1    12

I have to create a new table B:

ID    B1    B2    B3    S
1234    4    8    5    17
1235    6    7    12    25

The combination (A1=1,A2=0,A3=0) gives B1
The combination (A1=1,A2=0,A3=0) gives B2
The combination (A1=1,A2=1,A3=1) gives B3

S = B1+B2+B3

I think it's a classical problem, but i can't see to problem key

Thx,
Lhaj


pgsql-general by date:

Previous
From: Johannes Konert
Date:
Subject: Re: Suppress checking of chmod 700 on data-dir?
Next
From: "A. Kretschmer"
Date:
Subject: Re: Create a table B with data coming from table A