Re: String Right justification
Posted in 2006
Topics: General Discussion
Does the LPAD function do what you are after? http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.sqls.doc/sqls1037.htm for example to right justify to 50 characters (padding with spaces): SELECT LPAD(myfield,50,' ') FROM mytable or dynamically based on lengthiest field SELECT LPAD(myfield,(SELECT max(length(myfield)) FROM mytable),' ') FROM mytable Not sure how optimal that last statement would be on a large table. Not really sure what you are after from your original question. amg. Nirmala Kesavan wrote: > Hi, > Can anyone tell me how right justification can be done in string
LPAD is a nice way to do it. You can substitute in my code the lpad command. macgillivary wrote: > Does the LPAD function do what you are after? > http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.sqls.doc/sqls1037.htm > > for example to right justify to 50 characters (padding with spaces): > SELECT LPAD(myfield,50,' ') > FROM mytable > > or dynamically based on lengthiest field > SELECT LPAD(myfield,(SELECT max(length(myfield)) FROM mytable),' ') > FROM mytable > > Not sure how optimal that last statement would be on a large table. > > Not really sure what you are after from your original question. > > amg. > > > Nirmala Kesavan wrote: > > Hi, > > Can anyone tell me how right justification can be done in string