Re: Looks are important

From: "Louise Cofield" <lcofield(at)box-works(dot)com>
To: "'George Weaver'" <georgew1(at)mts(dot)net>, "'Josh Berkus'" <josh(at)agliodbs(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Looks are important
Date: 2003-11-13 15:22:33
Message-ID: 003401c3a9f9$f63fe800$7801a8c0@Louise
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Using a fixed-width font as Tom suggests, concatenate an additional
space between the no field and the kind field:

SELECT RPAD(no,30,' ') || ' ' || TRIM(tableb.kind) FROM tablea
WHERE tablea.kind = tableb.kind

Louise

-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of George Weaver
Sent: Wednesday, November 12, 2003 8:15 PM
To: Josh Berkus; pgsql-sql(at)postgresql(dot)org; Louise Cofield
Subject: Re: [SQL] Looks are important

Hi Louise, Josh,

Thanks for the suggestions.

What I'm trying to accomplish is to have a space between no and kind.
Length(no) can vary. I would like all the kinds to line up evenly when
displayed, with a space between no and kind. But when I RPAD no (to try
and get an even starting point for kind), the ' 's are not quite the
same width as an ordinary number or letter. Thus the physical display
length of "30 characters" (padded) can vary from row to row. The result
is that the kinds don't necessary line up neatly. I need to concatenate
the two as they are being displayed as one column in a drop down
combobox.

Is what I'm trying to do possible???

George

----- Original Message -----
From: Louise <mailto:lcofield(at)box-works(dot)com> Cofield
To: 'George Weaver' <mailto:georgew1(at)mts(dot)net> ;
pgsql-sql(at)postgresql(dot)org
Sent: Wednesday, November 12, 2003 5:19 PM
Subject: RE: [SQL] Looks are important

Try the TRIM function or the LTRIM function:

SELECT RPAD(no,30,' ') || TRIM(tableb.kind) FROM tablea
WHERE tablea.kind = tableb.kind

Louise

-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of George Weaver
Sent: Wednesday, November 12, 2003 3:12 PM
To: pgsql-sql(at)postgresql(dot)org
Subject: [SQL] Looks are important

Hi Everyone,

I am trying to concatenate two fields through a query:

SELECT RPAD(no,30,' ') || tableb.kind FROM tablea
WHERE tablea.kind = tableb.kind

The result gives (for example):

4595448 Green
5966 Yellow
106-60033 Green
15-94-387 Red
217-991173 Blue

What I would like to have is better alignment:

4595448 Green
5966 Yellow
106-60033 Green
15-94-387 Red
217-991173 Blue

Is there some kind of encoding or other string options that will result
in better alignment than what I've tried with Rpad?

Thanks in advance,
George



In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Alexander M. Pravking 2003-11-13 16:08:00 STRICT function returning a composite type
Previous Message Christoph Haller 2003-11-13 15:06:05 Re: Conversion Problem