Why do people try to make themselves feel better by treating others poorly? I'm looking for an explanation for why people will try to make themselves feel better by treating others poorly.

For example, imagine a group of girls are sitting in a cafe. Within that group are two girls in particular, Sally and Anne. Sally is beautiful, intelligent, and popular. Sally knows she's blessed, but she doesn't like to highlight that fact. She shies from attention and deflects most compliments. Anne on the other hand, is normal, at least she thinks of herself as normal. Anne doesn't often receive compliments like Sally does. As the group of girls sit in the cafe sipping latte's and chatting, the conversation makes its way to Sally's recent success at school. Sally scored top of the class in the last bout of exams. This angers Anne, she herself didn't do so well on her exams. She feels ashamed. Suddenly she blurts "Oh Sally its great that you did well on your exams, I'm surprised you had so much time to study, I thought you'd be too busy with Jack?". Jack was Sally's fiance, they recently split up when Sally caught Jack with another woman. At this, Sally cowers like a wounded animal. She quickly mumbles something and excuses herself from the table. The conversation falls flat. Everyone at the table knew what happened between Sally and Jack. The other girls stare awkwardly at their mugs, shooting furtive looks at Anne. Anne knows what she did was wrong, evil even. But hurting Sally felt good, real good.

To rephrase the question in the context of the scene: Is there a name for Anne's behaviour at the cafe?

I'm not just looking for a word that would describe Anne's behaviour. Depending on how you interpret the story, Anne's behaviour can be described with many words (bullying, jealousy, spitefulness etc.). What I'm looking for is an explanation of Anne's behaviour in terms of psychoanalytic theory.
What I'm looking for is an explanation of Anne's behaviour in terms of
psychoanalytic theory.


In Freudian psychology this is called Displacement:


  ... an unconscious defense mechanism whereby the mind substitutes
  either a new aim or a new object for goals felt in their original form
  to be dangerous or unacceptable.


For example:


  ... a college student may snap at his or her roommate when upset about
  an exam grade.


Note that psychoanalytic theory is outdated, and for the most part considered pseudoscience.  The concept of defence mechanisms in general has largely been superseded by cognitive dissonance theory.

Not related, but you may also be interested in Schadenfreude.