It all depends on how large a building, how it was constructed and how it collapses upon the person. Obviously there is a huge difference between a horrific collapse like the WTC and a single story wooden structure, but even in concrete buildings sometimes a person will get extremely lucky.
I remember a story out of Japan where some poor devil was in a large concrete hospital that came down in a major earthquake. He initially suffered no significant injuries but was still trapped in a small pocket along with a few others, including his wife, whom unlike him were pinned under rubble. He was in there for a week crawling around in the darkness and was the only one left alive when rescuers eventually found him by chance, and they were only digging in the rubble because they were looking for medical supplies.
Point being is that a person can survive quite a while if there is enough oxygen, they have not suffered severe injuries and they are not pinned under heavy rubble, perhaps even weeks if there happens to be a source of drinkable water such as ruptured pipes.
But a person whom is pinned under something heavy will not last nearly as long because crush injuries become more and more lethal as time passes without treatment, even when it is something non-vital like a limb, as toxins will build up in the blood from dying tissues. Also keep in mind that a person whom has lost a lot of blood will dehydrate a lot quicker than someone whom hasn't.