Sie trägt immer dasselbe Kleid.
She always wears the same dress.
Ich habe das gleiche Kleid wie du.
I have the (exact) same dress!
I have a dress just like yours!
Ich möchte die gleiche Suppe wie er bestellen.
I would like to order the same soup as him.
It's important to make this distinction between derselbe and der gleiche in German, if not, it will not make sense. For example if you said instead Ich möchte dieselbe Suppe wie er bestellen, then that means you would have to share the same bowl of soup, since you want to have that specific bowl of soup.
How to Remember Which is Which
Here are two easy ways to remember:
- Related to der gleiche is the verb gleichen, which means to look similar. Derselbe does not have a related verb. So, when you are trying to figure out whether to use der gleiche or derselbe, tell yourself the following line: Die beiden (thing you are comparing) gleichen sich, aber sie können sich nicht "selben". For example, if two people were wearing the same shirt, you would say: Die beiden Hemden gleichen sich, aber sie können sich nicht "selben".
- "Like" rhymes much more with gleich than with derselbe.
Derselbe, dasselbe, dieselbe
When building sentences with derselbe, the same grammar case rules apply, namely you decline derselbe as an indefinite article and derselbe as an adjective:
Wir wohnen in demselben Gebäude wie ihr.
We live in the same building as you.
However, when contracting the preposition with the definite article, you separate demselben as follows: Wir wohnen im selben Gebäude wie ihr.

