Yes I agree, mine only does it while sleeping. they don't move at all. Just seem to stick in one place. If yours are doing this during the day there may be an issue.
Tank mates? Stress?
I know when I got my first clown it would lie flat on its side for about an hour, under a rock. Then it swam out and was fine.
What kind of fish is it? I've heard that sometimes a fish will orientate itself with a specific point in the tank, If it perceives this point to be the ground it will orientate itself accordingly, even it the point is on the wall.
Who knows though, fish are weird.