Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trimming a COUNT column 1

Status
Not open for further replies.

DayLaborer

Programmer
Jan 3, 2006
347
US
This line (obviously) works:
Code:
select (count (*)) from crdcrm.employee where firstname = 'John'
but this one does not:
Code:
select [b]ltrim[/b](count (*)) from crdcrm.employee where firstname = 'John'
I get the error message:
SQL0171N The data type, length or value of argument "1" of routine "LTRIM" is incorrect. SQLSTATE=42815
What can I do to trim the column that reports the count?

Thanks,
Eliezer
 
Frederico,

Thanks for replying. When I tried exactly what you posted, I get this:
SQL0199N The use of the reserved word "FROM" following "" is not valid. Expected tokens may include: "+ - AS ORDER".
Eliezer
 



Try adding the missing RIGHT PARENTHESIS
Code:
select ltrim(cast(count (*) as char(20))[red][b])[/b][/red] from crdcrm.employee where firstname = 'John'


Skip,

[glasses]Did you hear what happened when the OO programmer lost his library?...
He's now living in OBJECT poverty![tongue]
 
Mercury, how many CHARs does that allot? i.e. does it trim? If so, what/how?

Thanks,
Eliezer
 
Eliezer,

If you still want it to be left justified (ie you are trying to get rid of some of the leading zeros, you could use:

select substr(digits(count(*)),6,5) from crdcrm.employee where firstname = 'John'

Brian
 
Sory - my age is showing. It should be 'right justified' in the previous post

Brian :<(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top