Past Perfect VS. Past Perfect Continuous
First of all have a look at these examples:
I had studied Japanese before I moved to Tokyo.
He had washed the dishes when Julia came.
She had lost her wallet before she came home.
There are two actions in the examples and the sequence of events is clear: one action is completed and it (had studied, had washed, had lost) happened before the other (moved, came) - it's Past Perfect Tense.
She had left when he arrived.

1. Are we talking about the past? (yes)
2. How many actions are there in the past? (two)
3. Did both actions happen at the same time? (no)
4. Did one action happen before the other?(yes)
5. Which action happened first? (She left)
The structure of Past Perfect Tense is the following:
Affirmative: Subject + had + Ved/3
Interrogative: Had + subject + V ed/3?
Negative: No + subject + had + not + V ed/3

We often use contractions (especially when speaking) in Past Perfect by contracting the subject of the sentence:
1. I had I’d – After I’d used the phone, I had lunch.
2. He had He’d / She had She’d / It had It’d – It’d happened so quickly, I didn’t understand anything.
3. We had We’d / You had You’d /They had They’d – We’d just come home, when we heard that noise.
What about Past Perfect Continuous? Look at the examples:
I had been dreaming about true love for years when I finally met my husband!
She had been doing her homework before he came.
We had been eating that delicious pizza when the waiter brought our bill.
What all these sentences have in common? In examples above we have two actions: one action happened first and it took some time (it is important!!!) - had been dreaming, had been doing, had been eating and then the second action happened (met, came, brought). So, we see that something (waiting, doing, eating) started in the past and continued up until another time/action in the past. It has a "duration" and this "duration" is important in every Continuous tense!
They had been swimming in the water for 2hours when they were rescued.

1. When did they start swimming? (at 2pm)
2. What time did they stop swimming? (at 4pm)
3. How long were they swimming? (2 hours)
4. Did they stop swimming when they were rescued? (yes)
Past Perfect has the same meaning as Past Perfect Continuous when the main verb in the sentence is a stative or non-continuous verb and action in the sentence is in progress. In this case even if the first action (which started in the past) continued up until another action in the past, we cannot use Past Perfect Continuous, only Past Perfect!
= 
I had had that car for 5 years before it broke down. (NOT I had been having).
We felt bad about selling our car because we had owned (NOT had been owing) it for 10 years.
Here is the list of the most useful stative (state) verbs:

Past Perfect Continuous is also used to express cause of something in the past:
I was tired because I had been working a lot.
Kate gained weight because she had been overeating.
We missed the plane because we had been waiting our taxi for an hour.
What do we have here? There are two actions (again), both are in the past and they're connected with each other (one action is the result of the second one).

The structure of Past Perfect Continuous Tense as you can see above is the following:
Affirmative: Subject + had + been + Ving
Interrogative: Had + subject + been + V ing?
Negative: No + subject + had + not + been + V ing
The contraction in this case is also possible and it's the same as we use in Past Perfect.
With both tenses we can use adverbs (just, ever, never, only, always etc.) but in Past Perfect they are usually not necessary:
I had only been waiting there for one minute when the bus arrived.
They had (only - ?) had dinner when the concert started.
Wh-questions in this two tenses are formed in the same way:
Wh-question + main question
What had you done before entering the university?
Why had he been waiting for me outside?
Let's summarize!
Both tenses:
are used in the past;
usually have 2 actions in the sentence or specific markers (when, before etc.)
have similar contraction and adverbs;
BUT:
One of the actions in Past Perfect is usually completed (it gives us the answer - What has happened) and in Past Perfect Continuous is in progress (its answer is How long).
When the action is in progress and the main verb is a stative verb - we use Past Perfect (NOT Continuous)
Using the words in parentheses, complete the text below with the appropriate tenses.Начало формы
I'm sorry I left without you last night, but I told you to meet me early because the show started at 9:00. I (try)
to get tickets for that play for months, and I didn't want to miss it. By the time I finally left the coffee shop where we were supposed to meet, I (have)
five cups of coffee and I (wait)
over an hour. I had to leave because I (arrange)
to meet Kathy in front of the theater.
When I arrived at the theater, Kathy (pick, already)
up the tickets and she was waiting for us near the entrance. She was really angry because she (wait)
for more than half an hour. She said she (give, almost)
up and (go)
into the theater without us.
Kathy told me you (be)
late several times in the past and that she would not make plans with you again in the future. She mentioned that she (miss)
several movies because of your late arrivals. I think you owe her an apology. And in the future, I suggest you be on time!