I agree with Anthony Grist -- I think many of the ghosts who were at Sir Nicholas's Deathday Party came in from other places.
In Philosopher's Stone, as Harry is waiting to be Sorted, "about twenty" ghosts appear, including the house ghosts (as an FYI, here the Fat Friar confirms he was indeed a Hufflepuff while at Hogwarts -- this is all in chapter 7, The Sorting Hat). However, at Sir Nicholas's Deathday Party, it is described as having "hundreds" of ghosts in attendance, plus Peeves the poltergeist.
Now Peeves would not have been a student anywhere, for poltergeists do not spawn from the spirit of a person who has died, like a traditional ghost; a poltergeist is an evil or malevolent energy that forms from negative or tumultuous feelings or vibes from a living person. Peeves is a bit of an exception, for he is corporeal. Traditionally, poltergeists are not (they knock on things and make scary noises, and seem to exhibit the most activity in relation to one specific person whose energy the poltergeist is feeding off). So Peeves could not have been a spirit that had once been a person.
There may have been ghosts in attendance who were older than Hogwarts and thereby would not have had the chance to attend. Some of the ghosts were nuns. At least one was a knight (with an arrow through his head). One female ghost was a (wailing) widow. Of course the Headless Hunt was made up of the ghosts of those who had been decapitated, who shared a love of hunting (Chamber of Secrets - chapter 8, The Deathday Party). Sir Nicholas was a member of the royal court during his day (Tales of Beedle the Bard) So, there's a brief summary of the occupations of some of the ghosts we meet in the books.