79436007

Date: 2025-02-13 11:39:57
Score: 1
Natty:
Report link

I've adapted @ThomA answer with the following code (Obviously, this isn't production code):

WITH    CTE_PROMPT AS (
        SELECT  PERSON_NUMBER  
                ,'M' Gender 
        FROM    EMPLOYEES
        )  
        
SELECT  EMPLOYEES.PERSON_NUMBER
        ,SEX                
FROM    EMPLOYEES 
        LEFT OUTER JOIN CTE_PROMPT ON EMPLOYEES.PERSON_NUMBER  = CTE_PROMPT.PERSON_NUMBER
WHERE   SEX = Gender OR Gender = 'ALL'

This works. For some reason it didn't like the CTE_PROMPT query without a table.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @ThomA
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: NiMuSi