Lets say you have a website, that uses a function to retrieve data from the database and returns the result to be displayed/parsed/etc...
Since the data that is retrieve
Ignoring the fact that you are talking about the DB I think you may be looking for your unit tests to cover every eventuallity where as that can lead to set of diminishing returns. If I were you I'd cover a standard path and then a couple of edge cases. The fact is you cannot pragmatically test everything.
Here's some further reading
http://37signals.com/svn/posts/3159-testing-like-the-tsa
How deep are your unit tests?
http://johnnosnose.blogspot.co.uk/2012/04/re-over-testing.html
http://martinfowler.com/bliki/TestCoverage.html
Looking at your specifc db related problem, to test this function you probably need to create a seam to pre poulate the data so you can cover those cases.