0

I am joining two tables, case and user. My problem is that I want to sensor the user's name and location if he/she is working at location B-D.

I want this

Default

To look like this

Censored

This is my code so far, but the name is not censored:

SELECT 
c.CaseID, 
c.Category, 
u.User, 
CASE 
    WHEN u.Location != "A" THEN null
    ELSE u.Location
END as Location

FROM cases c

JOIN c.userID on u.userID
1
  • 1
    amazing how the edit made that post so much easier to answer @GMB Commented Dec 13, 2019 at 14:39

1 Answer 1

5

Use the same case statement for user column too.

SELECT 
c.CaseID, 
c.Category, 
CASE 
    WHEN u.Location != "A" THEN null
    ELSE u.User
END as User,
CASE 
    WHEN u.Location != "A" THEN null
    ELSE u.Location
END as Location
FROM cases c...... <Your remaining query>
Sign up to request clarification or add additional context in comments.

1 Comment

case expression.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.