It is narrated from Sayyiduna Abu Hurayrah (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) urinated while standing because of a wound that he (peace and blessings be upon him) had in his knees.
(b) Imam Ahmad (may Allah have mercy on him) said: One view is that the Arabs used to urinate standing to seek a cure for back pain, so it is possible that he (peace and blessings be upon him) also had this pain. Imam al-Shafi'i (may Allah have mercy on him) has given the same meaning. Another view is that he (peace and blessings be upon him) did so because there was no place there to sit. And Allah knows best.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الطهارة / 489