Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.postgresql > #366

Re: (sql beginner) help for request

From Jasen Betts <jasen@xnet.co.nz>
Newsgroups comp.databases.postgresql
Subject Re: (sql beginner) help for request
Date 2012-06-21 07:59 +0000
Organization Dis (not Dat) Organisation
Message-ID <jruk8d$ot6$6@reversiblemaps.ath.cx> (permalink)
References <4fe22af0$0$6485$426a74cc@news.free.fr>

Show all headers | View raw


On 2012-06-20, meta <xyz@abc.fr> wrote:
> Hi
>
> I know postgresql but not enough to solve the following problem:
>
> Here is a table with the fields: name char(20), c1 char(1), c2 char (1)
>
> The goal is to concat these fields after transformation in order to display 
> them on one ligne:
> - c1 and c2 values are Y or N. If 'Y' it will be replaced by 'A', if 'N' it 
> will be replaced by 'B'.
> - name must have 20 characters even if its lenght is less than 20, in order 
> to align the results properly
>
> For example, here are two records: ('apple','Y','N') and 
> ('cranberry','N','N')
>
> Final display wished:
> apple                  A B
> cranberry            B B

postgres isn't capable of guessing the behaviour of variable 
pitch (proportional) fonts like you appear to want with your
example output.

assuming you want it for fixed pich font like this instead:

apple                A B
cranberry            B B

select rpad(name,20) ||' '||translate(c1||' '||c2,'YN','AB');

-- 
⚂⚃ 100% natural

Back to comp.databases.postgresql | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

(sql beginner) help for request "meta" <xyz@abc.fr> - 2012-06-20 21:56 +0200
  Re: (sql beginner) help for request Stuart McGraw <smcg4191@frii.com> - 2012-06-20 16:09 -0600
    Re: (sql beginner) help for request Stuart McGraw <smcg4191@frii.com> - 2012-06-20 16:31 -0600
  Re: (sql beginner) help for request Harry Tuttle <OTPXDAJCSJVU@spammotel.com> - 2012-06-21 08:44 +0200
  Re: (sql beginner) help for request Jasen Betts <jasen@xnet.co.nz> - 2012-06-21 07:59 +0000
  Re: (sql beginner) help for request "meta" <xyz@abc.fr> - 2012-06-22 23:46 +0200

csiph-web