I am unable to remove the leading zeros from a column. In this case my SQL query is
x
Select distinct ltrim(rtrim([FGQSHO])) as QTY,ltrim(rtrim([QULOTN])) as Batch,ltrim(rtrim([QUQTSH])) as BatchQtyFROM serhleft join boll on serh.HVSERN = boll.QUSERNleft join bold on boll.QUBOL# = bold.FGBOL# and boll.QUENT# = bold.FGENT#left join bolh on bold.FGBOL# = bolh.FEBOL#left join ocri on bold.fgord# = ocri.ddord# and bold.fgitem = ocri.dditm#where FGBOL# = '761221'The result is
QTY Batch BatchQty30.00000 4615J0003 3Q20 14.0000030.00000 4615J0005 4Q20 16.00000I am looking for this result.
QTY Batch BatchQty30 4615J0003 3Q20 1430 4615J0005 4Q20 16Advertisement
Answer
Use the floor() function:
floor(ltrim(rtrim([FGQSHO]))) as QTY,Why are you storing these values as strings in the first place? You should be storing numbers as numbers. And if they are numbers, you should not be using string functions on them.