Small adjustments of sql cases