fix tests to run against a sql server instead of memory
fixed code to pass with jugglingdb tests
use pre-calculated pkids when creating order by