Re: How to right justify text in psql? - Mailing list pgsql-sql

From Ian Lawrence Barwick
Subject Re: How to right justify text in psql?
Date
Msg-id CAB8KJ=hQ+m-dStL6NQm1-phjPX1cZ9TMVqgKORGAA=6SeL+4Dg@mail.gmail.com
Whole thread Raw
In response to How to right justify text in psql?  (Brian Sherwood <bdsher@gmail.com>)
List pgsql-sql
2013/5/18 Brian Sherwood <bdsher@gmail.com>:
> I am running postgresql 9.2.
>
> I am assuming it would be a function of psql to right justify text, but I
> can't find any way to do this.
>
> Is there a way to right justify just one text column?

If you mean have the psql client right-justify a particular text column, no I
don't think there's a way to do that.

Assuming the column contains single-width characters with no line breaks,
you could do something with LPAD along these lines:

SELECT LPAD(txtcol, (SELECT MAX(LENGTH(txtcol)) FROM tbl)) FROM tbl

HTH

Ian Barwick



pgsql-sql by date:

Previous
From: Jov
Date:
Subject: Re: How to right justify text in psql?
Next
From: JORGE MALDONADO
Date:
Subject: Select statement with except clause