Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XyIof-0005IM-0N for pgsql-admin@arkaria.postgresql.org; Tue, 09 Dec 2014 11:18:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XyIod-0006TE-So for pgsql-admin@arkaria.postgresql.org; Tue, 09 Dec 2014 11:18:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XyIoc-0006T7-M0 for pgsql-admin@postgresql.org; Tue, 09 Dec 2014 11:18:50 +0000 Received: from eu1sys200aog119.obsmtp.com ([207.126.144.147]) by makus.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XyIoZ-0005d0-8t for pgsql-admin@postgresql.org; Tue, 09 Dec 2014 11:18:48 +0000 Received: from mail-wg0-f44.google.com ([74.125.82.44]) (using TLSv1) by eu1sys200aob119.postini.com ([207.126.147.11]) with SMTP ID DSNKVIbalUQbK9tn1gSF+SInXYMPmaXqY4Oc@postini.com; Tue, 09 Dec 2014 11:18:47 UTC Received: by mail-wg0-f44.google.com with SMTP id b13so514840wgh.17 for ; Tue, 09 Dec 2014 03:18:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:thread-index:date:message-id :subject:to:content-type; bh=/TlZ/896qzJH9G2cBeDPiMcrFZNtC4OKvTS2jut82gk=; b=dixhBaLExneJPf1g59VN/xDRM1r/rWUnTJkIRO5PQYjeKHwNkhmDTuYA1UjeAvkgDz Tn7opNdudsKA3aqq6BThfcFGhDb8fi0rvz1YNPQ8i4GU2DD/tVgH68sNqsHNAv/65CoA QMp7sJM5WBT2R4Cyt6DJ+q7ZIi2uqu7Ei+IxEustCUMbtI3s3KgqePbI+8LhmvI8p1zF HF1WGPxLTDXRuvfaRCHR3xCivCX2TizhPKrul6doNygT3CDrgOWW5ng2GNeiMmyP+2Nq 2iqPqLKQAZXsY+bIMZUDexZpHoy5V2U23TuzB4wIzkHFQ7n57XRKjwfyXqrSBH1qEavk m1dw== X-Gm-Message-State: ALoCoQmNF0Ics7YNYXvu8d/EbqE89mtiqt5HSXzJr7qsuEjLdjKuLpuxCQSPMDp/Ddyz0E7M5TdVPNM4Ecv00klkiy30mfdyymwMc742SeQnyw+EEOZ7wKyWjF6+znGR1MO5X4Ij4WRmGg71QoZlc/IciX7xcjQxag== X-Received: by 10.180.76.7 with SMTP id g7mr3604706wiw.38.1418123925450; Tue, 09 Dec 2014 03:18:45 -0800 (PST) X-Received: by 10.180.76.7 with SMTP id g7mr3604612wiw.38.1418123924721; Tue, 09 Dec 2014 03:18:44 -0800 (PST) From: Khangelani Gama MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AdAToSLmZWe90gu8TOuCqVaG3ZcrZA== Date: Tue, 9 Dec 2014 13:18:43 +0200 Message-ID: Subject: Group by clause - Postgres 9.2.4 To: pgsql-admin@postgresql.org Content-Type: multipart/alternative; boundary=f46d043893c7c7e6120509c6b445 X-Pg-Spam-Score: -4.2 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org --f46d043893c7c7e6120509c6b445 Content-Type: text/plain; charset=UTF-8 I need some help I was given the SQL called as insert into usr_role (select usr_id, '501~734' from usr_role where role_id = '501~703' group by usr_id); to be run in a server which will work fine but I need to construct another one to work the same way for the master table called corp_usr_role. Given the following 2 tables, is it correct to have the SQL as insert into corp_usr_role (select usr_id,ctry_cde,grp_cde, '501~734' from corp_usr_role where role_id = '501~703' group by usr_id,ctry_cde,grp_cde,role_id); *First table :* *Table "public.corp_usr_role"* Column | Type | Modifiers ----------+------+----------- ctry_cde | text | not null grp_cde | text | not null usr_id | text | not null role_id | text | not null Indexes: "pk_cur" PRIMARY KEY, btree (ctry_cde, grp_cde, usr_id, role_id) *2nd table : * *Table "public.usr_role"* Column | Type | Modifiers ---------+------+----------- usr_id | text | role_id | text | Indexes: "idx_usr_role_role" btree (role_id) "idx_usr_role_usr" btree (usr_id) CONFIDENTIALITY NOTICE The contents of and attachments to this e-mail are intended for the addressee only, and may contain the confidential information of Argility (Proprietary) Limited and/or its subsidiaries. Any review, use or dissemination thereof by anyone other than the intended addressee is prohibited.If you are not the intended addressee please notify the writer immediately and destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries distance themselves from and accept no liability for unauthorised use of their e-mail facilities or e-mails sent other than strictly for business purposes. --f46d043893c7c7e6120509c6b445 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

I need some help

=C2=A0

I was given the SQL called = as =C2=A0insert into usr_role (select usr_id, '501~734'= from usr_role where role_id =3D '501~703' group by usr_id); =C2=A0= to be run in a server which will work fine but I need to construct another = one to work the same way for the master table called corp_usr_role. Given t= he following 2 tables, is it correct to have the SQL as insert into = corp_usr_role (select usr_id,ctry_cde,grp_cde, '501~734'= ; =C2=A0from corp_usr_role where role_id =3D '501~703' group= by usr_id,ctry_cde,grp_cde,role_id);

=

=C2=A0

First table :

=C2=A0

Tabl= e "public.corp_usr_role"

=C2=A0<= /b>

=C2=A0 Column=C2=A0 | Type | Modifiers

----------+------+-----------

ctry_cde | text | not null

grp_cde=C2=A0 | tex= t | not null

usr_id=C2=A0=C2=A0 | text | not nul= l

role_id=C2=A0 | text | not null

Indexes:

=C2=A0=C2=A0=C2=A0 "pk_= cur" PRIMARY KEY, btree (ctry_cde, grp_cde, usr_id, role_id)

=C2=A0

=C2=A0

<= p class=3D"MsoNormal">2nd table :

=C2=A0

Table "public.usr_role&= quot;

=C2=A0

Column=C2=A0 | Type | Modifiers

---------+-----= -+-----------

usr_id=C2=A0 | text |

role_id | text |

Indexes:

=C2=A0=C2=A0=C2=A0 "idx_usr_role_role" btree (= role_id)

=C2=A0=C2=A0=C2=A0 "idx_usr_role_us= r" btree (usr_id)

=C2=A0

=C2=A0

=C2=A0


CONFIDENTIALITY NOTICE
The contents of and attachments to this e-mail are intended for the addre=
ssee only, and may contain the confidential
information of Argility (Proprietary) Limited and/or its subsidiaries. An=
y review, use or dissemination thereof by anyone
other than the intended addressee is prohibited.If you are not the intend=
ed addressee please notify the writer immediately
and destroy the e-mail. Argility (Proprietary) Limited and its subsidiari=
es distance themselves from and accept no liability
for unauthorised use of their e-mail facilities or e-mails sent other tha=
n strictly for business purposes.
=0D
--f46d043893c7c7e6120509c6b445--