1

I am new to SQL and facing the problem for the while. The question is how to create such Label column in SQL?

Goal: When group count is more than 1 it should be 'Y' otherwise 'N'

Here is what I do in Excel (please see screenshot).

Screenshot

2
  • Which dbms are you using? Commented Oct 27, 2020 at 10:54
  • I am using Exasol Commented Oct 27, 2020 at 10:58

1 Answer 1

1

I think you want case with a window function:

select (case when count(*) over (partition by item) > 1 then 'Y' else 'N' end) as label
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! It works on test env, now I am going to try it on real data and will return to you!

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.