pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedQuery related
4+ messages / 3 participants
[nested] [flat]
* Query related
@ 2009-03-13 07:02 suresh gupta <suresh.g@zensar.com>
0 siblings, 1 reply; 4+ messages in thread
From: suresh gupta @ 2009-03-13 07:02 UTC (permalink / raw)
To: pgsql-admin
Hi Team,
I had a table with 2 fields like First name(FN) and last name(LN). When I give a query for the records of the 2 columns, they are displaying in 2 different columns. My requirement is to combine both the columns in a single one. As per my knowledge there are some operators which combine 2 columns and display together in single columns like |, +, etc. in other databases like Oracle.
For example FN = Suresh and LN=Gupta the output of the query should be Suresh Gupta in single column.
Is there any similar operator or method on postgresql to get my result. Please advice.
Pgsql version is 8.1 and window version software.
Regards,
G. V. Suresh Gupta
--------------------------------------------------------------------------------
GTS - EMEIA, Zensar Technologies
Zensar Knowledge Park, Plot#5, MIDC IT Tower,
Kharadi, Off Nagar Road, Pune - 411014
Landline : +91-20-66453471 | +91-9890898688
Email : suresh.g@zensar.com | website: www.zensar.com
DISCLAIMER:
This email may contain confidential or privileged information for the intended recipient(s) and the views expressed in the same are not necessarily the views of Zensar Technologies Ltd. If you are not the intended recipient or have received this e-mail by error, its use is strictly prohibited, please delete the e-mail and notify the sender. Zensar Technologies Ltd. does not accept any liability for virus infected mails.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Query related
@ 2009-03-13 07:36 Ashish Karalkar <ashishka@synechron.com>
parent: suresh gupta <suresh.g@zensar.com>
0 siblings, 2 replies; 4+ messages in thread
From: Ashish Karalkar @ 2009-03-13 07:36 UTC (permalink / raw)
To: suresh gupta <suresh.g@zensar.com>; +Cc: pgsql-admin
suresh gupta wrote:
> Hi Team,
>
> I had a table with 2 fields like First name(FN) and last name(LN).
> When I give a query for the records of the 2 columns, they are
> displaying in 2 different columns. My requirement is to combine both
> the columns in a single one. As per my knowledge there are some
> operators which combine 2 columns and display together in single
> columns like |, +, etc. in other databases like Oracle.
> For example FN = Suresh and LN=Gupta the output of the query should be
> Suresh Gupta in single column.
>
> Is there any similar operator or method on postgresql to get my
> result. Please advice.
>
> Pgsql version is 8.1 and window version software.
>
>
> Regards,
> *G. V. Suresh Gupta*
> ------------------------------------------------------------------------
> *GTS - EMEIA, Zensar Technologies *
> Zensar Knowledge Park, Plot#5, MIDC IT Tower,
> Kharadi, Off Nagar Road, Pune - 411014
> Landline : +91-20-66453471 | +91-9890898688
> Email : suresh.g@zensar.com <mailto:suresh.g@zensar.com> | website:
> www.zensar.com <http://www.zensar.com;
>
> DISCLAIMER:
> This email may contain confidential or privileged information for the
> intended recipient(s) and the views expressed in the same are not
> necessarily the views of Zensar Technologies Ltd. If you are not the
> intended recipient or have received this e-mail by error, its use is
> strictly prohibited, please delete the e-mail and notify the sender.
> Zensar Technologies Ltd. does not accept any liability for virus
> infected mails.
>
This will help you.
postgres=# create table name(fn text,ln text);
CREATE TABLE
postgres=# insert into name values ('abc','xyz');
INSERT 0 1
postgres=# select * from name;
fn | ln
-----+-----
abc | xyz
(1 row)
postgres=# select fn||' '||ln as name from name;
name
---------
abc xyz
(1 row)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Query related
@ 2009-03-13 07:43 suresh gupta <suresh.g@zensar.com>
parent: Ashish Karalkar <ashishka@synechron.com>
1 sibling, 0 replies; 4+ messages in thread
From: suresh gupta @ 2009-03-13 07:43 UTC (permalink / raw)
To: Ashish Karalkar <ashishka@synechron.com>; +Cc: pgsql-admin
Thanks Ashish, it is working.
Regards,
G. V. Suresh Gupta
--------------------------------------------------------------------------------
GTS - EMEIA, Zensar Technologies Zensar Knowledge Park, Plot#5, MIDC IT
Tower, Kharadi, Off Nagar Road, Pune - 411014 Landline : +91-20-66453471 |
+91-9890898688 Email : suresh.g@zensar.com | website: www.zensar.com
----- Original Message -----
From: "Ashish Karalkar" <ashishka@synechron.com>
To: "suresh gupta" <suresh.g@zensar.com>
Cc: <pgsql-admin@postgresql.org>
Sent: Friday, March 13, 2009 1:06 PM
Subject: Re: [ADMIN] Query related
> suresh gupta wrote:
>> Hi Team,
>> I had a table with 2 fields like First name(FN) and last name(LN). When
>> I give a query for the records of the 2 columns, they are displaying in 2
>> different columns. My requirement is to combine both the columns in a
>> single one. As per my knowledge there are some operators which combine 2
>> columns and display together in single columns like |, +, etc. in other
>> databases like Oracle.
>> For example FN = Suresh and LN=Gupta the output of the query should be
>> Suresh Gupta in single column. Is there any similar operator or method on
>> postgresql to get my result. Please advice.
>> Pgsql version is 8.1 and window version software.
>>
>>
>> Regards,
>> *G. V. Suresh Gupta*
>> ------------------------------------------------------------------------
>> *GTS - EMEIA, Zensar Technologies *
>> Zensar Knowledge Park, Plot#5, MIDC IT Tower,
>> Kharadi, Off Nagar Road, Pune - 411014
>> Landline : +91-20-66453471 | +91-9890898688
>> Email : suresh.g@zensar.com <mailto:suresh.g@zensar.com> | website:
>> www.zensar.com <http://www.zensar.com;
>>
>> DISCLAIMER:
>> This email may contain confidential or privileged information for the
>> intended recipient(s) and the views expressed in the same are not
>> necessarily the views of Zensar Technologies Ltd. If you are not the
>> intended recipient or have received this e-mail by error, its use is
>> strictly prohibited, please delete the e-mail and notify the sender.
>> Zensar Technologies Ltd. does not accept any liability for virus infected
>> mails.
>>
> This will help you.
>
> postgres=# create table name(fn text,ln text);
> CREATE TABLE
> postgres=# insert into name values ('abc','xyz');
> INSERT 0 1
> postgres=# select * from name;
> fn | ln
> -----+-----
> abc | xyz
> (1 row)
>
> postgres=# select fn||' '||ln as name from name;
> name
> ---------
> abc xyz
> (1 row)
>
>
>
DISCLAIMER:
This email may contain confidential or privileged information for the intended recipient(s) and the views expressed in the same are not necessarily the views of Zensar Technologies Ltd. If you are not the intended recipient or have received this e-mail by error, its use is strictly prohibited, please delete the e-mail and notify the sender. Zensar Technologies Ltd. does not accept any liability for virus infected mails.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Query related
@ 2009-03-13 07:52 Julius Tuskenis <julius@nsoft.lt>
parent: Ashish Karalkar <ashishka@synechron.com>
1 sibling, 0 replies; 4+ messages in thread
From: Julius Tuskenis @ 2009-03-13 07:52 UTC (permalink / raw)
To: Ashish Karalkar <ashishka@synechron.com>; +Cc: pgsql-admin; suresh gupta <suresh.g@zensar.com>
Hello
> postgres=# create table name(fn text,ln text);
fn and ln could be nulls, so instead of
> postgres=# select fn||' '||ln as name from name;
SELECT COALESCE(fn,'')||' '||COALESCE(ln,'') from name should be used.
This is because NULL||TEXT = NULL
--
Julius Tuskenis
Programavimo skyriaus vadovas
UAB nSoft
mob. +37068233050
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2009-03-13 07:52 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-03-13 07:02 Query related suresh gupta <suresh.g@zensar.com>
2009-03-13 07:36 ` Ashish Karalkar <ashishka@synechron.com>
2009-03-13 07:43 ` suresh gupta <suresh.g@zensar.com>
2009-03-13 07:52 ` Julius Tuskenis <julius@nsoft.lt>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox