Someone who prayed the prayer of fear with the Messenger of Allah ﷺ on the day of Dhat ar-Riqa reported that one group lined up behind him while another group faced the enemy. He prayed one cycle with the group that was with him, then remained standing while they completed the prayer for themselves. They then withdrew and took up position facing the enemy. The other group came forward, and he prayed with them the remaining cycle of his prayer, then remained seated while they completed the prayer for themselves. He then concluded the prayer with them by giving the salam.Malik said, "The hadith of Yazid bin Ruman is the most preferable account I have heard on this matter."
حدثنا القعنبي عن مالك عن يزيد بن رومان
عمن صلى مع رسول الله ﷺ يوم ذات الرقاع صلاة الخوف أن طائفة صفت معه وطائفة وجاه العدو فصلى بالتي معه ركعة ثم ثبت قائما وأتموا لأنفسهم ثم انصرفوا وصفوا وجاه العدو وجاءت الطائفة الأخرى فصلى بهم الركعة التي بقيت من صلاته ثم ثبت جالسا وأتموا لأنفسهم ثم سلم بهم قال مالك وحديث يزيد بن رومان أحب ما سمعت إلي
Bukhari narrated it in "The Book of Military Expeditions," chapter on the Battle of Zat al-Riqa, no. 4129, and Muslim, no. 842, both from the hadith of Malik through this same chain, and it is also found in Muwatta (Yahya's recension) 1/183.