Skip to content
Advertisement

Change the column value depends on occurrence count

There is the table:

So, we can have a book with only one or with many genres. From this table I would like to obtain this table

So in the new table if the book has only one genre, we keep this genre, if the book has many genres we change genre value by “mixed_genres”.

There is any way to do this? Many thanks for any advice!

Advertisement

Answer

You can use aggregation:

You can also list out all the genres:

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