Skip to content
Advertisement

If ID has both values A and B it should return AB

INPUT:

OUTPUT:

If ID has both values A and B it should return AB.

Advertisement

Answer

You are describing string aggregation as a window function. In standard ANSI SQL, the syntax would be:

Not all databases support this syntax though. In MySQL, you would use group_concat(), in Postgres, that’s string_agg(), and so on – but the logic remains the same.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement