I'd give them practical advise and do whatever I could to attempt to remedy the situation. If nothing happened. I'd just sit with them and spend time with them until they forgot whatever was making them feel sad または got better overall.
I'm that type of person that will hug あなた and try awkardly to make あなた laugh...and usually fail but try so hard that あなた end up laughing anyways...that's me...
do my pest to comfort them sometimes is better to leave them alone... to be honest for me personally when i get sad i prefer to be alone its faster for me to get over it this way without anyone interfering,it actually gives me time to relax and think straight