The wildcard character for pattern matching is %, not *. Also, if you want a sum, then use sum(), not count().

So:

select sum(price) sum_price from perfume where family_smell like 'flower%'

This phrases as: sum the prices of all rows where family_smell starts with “flower”. If you wanted contains “flower”, then you would put a wildcard on both ends:

where family_smell like '%flower%'

Note that I used single quotes instead of double quotes to surround the literal string. This complies to the SQL standard. In many other databases (and in ANSI SQL as well), double quotes stand for identifiers (such as column or table names), not for strings.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top