select count(category) from list where category like \'action\'
above is a query i want to run. However, when I run that query, I am getting data
To answer the question in the title for future googlers you can use
SELECT COUNT(CASE
WHEN some_text_column IS NOT NULL THEN 1
END)
FROM some_table
In your case though (as pointed out in the comments by @hvd) the WHERE category LIKE 'action'
predicate ensures that any NULL
values will be excluded anyway so it is safe to replace it with COUNT(*)
Moreover you almost certainly should not be using the text
datatype for this. This is a deprecated datatype that was intended for holding LOB (Large Object) data over 8000 bytes.
Strings like "action" definitely do not fit this description!