A condition that was not met
The periodo ipotetico dell'irrealtà talks about a condition in the past that was not met, and about the result that therefore never happened. I did not study, so I did not pass the exam. Both are over and cannot be changed. This is what English calls the third conditional: if I had studied, I would have passed.
How the pattern sounds
Se me lo aveste detto, sarei venuto anch'io.
If you had told me, I would have come too.
Se fossimo partiti prima, non avremmo perso il treno.
If we had left earlier, we wouldn't have missed the train.
Second type against third type
2° tipo: present, still open
Se + Congiuntivo imperfetto, main clause in the condizionale presente.
Se studiassi di più, passerei l'esame.
If I studied more, I would pass the exam. (It has not been taken yet.)
3° tipo: past, settled for good
Se + Congiuntivo trapassato, main clause in the condizionale passato.
Se avessi studiato, avrei passato l'esame.
If I had studied, I would have passed the exam. (It is over, I failed.)
What is it used for?
Regret
The most common case: you look back and wish it had gone differently.
Se avessi accettato quel lavoro, saremmo andati a vivere a Milano.
If I had taken that job, we would have moved to Milan.
Se avessi ascoltato mio padre, non avrei venduto la casa.
If I had listened to my father, I wouldn't have sold the house.
Reproach
In the second person the same construction quickly turns into a reproach, in Italian just as in English.
Se mi avessi chiamato, ti avrei aiutato.
If you had called me, I would have helped you.
Se aveste guardato l'orario, non sareste rimasti a piedi.
If you had checked the timetable, you wouldn't have been left stranded.
What would have happened otherwise
You show what would have happened if the condition had come true. This explains a decision or expresses relief. The se-clause can also come last.
Se fossi uscito dieci minuti prima, sarei finito nell'incidente.
If I had left ten minutes earlier, I would have ended up in the accident.
Non ti avrei scritto se non fosse stato importante.
I wouldn't have written to you if it hadn't been important.