Fish can infer their social standing through reasoning!
In one experiment, researchers let two similarly sized male Masked Julies (Julidochromis transcriptus, from Lake Tanganyika, Africa) duke it out in three gallon glass aquariums for 30 minutes. The winner was then paired with another male while the loser was put in an adjacent tank to watch the new battle.
If the newly introduced male won the fight, the loser of the original fight (spectating from an adjacent tank) avoided fighting the new king of the hill. By simply watching one fish beat another fish that had already bested him, the losing fish knew that he stood no chance against the new male even though it never actually fought that fish! This ability to deduce social hierarchy by simply observing social interactions of others in the group is called transitive inference, a cognitive ability that few thought fish capable of until recently.
In another pair of experiments, the researchers found that if two fish physically fought and then were separated into two adjacent glass tanks, the winner would act aggressively (constantly attacking the glass) while the loser swam to the most distant section of his aquarium, staying as far away as possible. However, if two males never physically fought and were simply placed next to each other in adjacent tanks, both displayed almost identical numbers of aggressive actions towards each other because neither fish was able to predict the outcome of the battles by inferring previous experiences, either direct or observed confrontations.
Research continually shows that fish are much smarter than people usually give them credit for.
Journal Reference: http://dx.doi.org/10.3389/fevo.2015.00085