SQL output based on environment