fix join statements for ordering, make sure we dont retur early if no wh...

Fixing issue 22

https://github.com/project-imas/encrypted-core-data/issues/22