I would say the greatest heavyweight of all time was Ali. A record of 56-5 (37 KOs). Three of defeats came in last four bouts, including two in an ill-advised emergence from retirement, against Larry Holmes and Trevor Berbick, at 38. Was banned from the ring in his prime for three years.
Greatest welterweight/middleweight was Sugar Ray Robinson. A record of 175-19-6-2 (109 KOs). Lost just one of first 123 fights, to Jake LaMotta, a defeat he avenged five times.