Drop Unrated Reviews, Replace Empty Comments

Drop Unrated Reviews, Replace Empty Comments

At "Kotomarket" customers leave reviews on products. The reviews table is flat: one review per row. Not every review is filled in completely — sometimes the customer left no rating (rating is NULL), and sometimes they wrote no text (comment is NULL). The moderation team is preparing a review feed and asks for an export following two rules: 1. Show only reviews that have a rating — that is, rating is not NULL. Reviews without a rating must be excluded. 2. If a review has no text (comment is NULL), output the placeholder string 'нет комментария' instead of the empty value. If text exists, output it as is. Return three columns: id, product, and the comment text under the alias comment_text. Use IS NOT NULL for the filter and COALESCE for the placeholder substitution. No sorting is required — row order does not matter.

Expected output sample

This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables. Your answer must use the same column names as this sample — alias them with AS if needed.

idproductcomment_text
1Когтеточка «Башня»Кот в восторге, точит каждый день
2Корм «Сытый кот» 2кгнет комментария
3Игрушка «Мышка»Любимая игрушка!
PostgreSQLv16

Your query result will appear here

Focus radio
Paused · SomaFM · Fluid