long nose
long nose

Reputation: 35

MYSQL count the row that is not empty

I need to count only those row that is not empty. thanks.

SELECT component,count(comp_details) FROM table GROUP BY component

Upvotes: 0

Views: 127

Answers (2)

Suchit kumar
Suchit kumar

Reputation: 11859

try like this:Add a where clause based on requirement.

SELECT component,count(comp_details) FROM table where comp_details is not null and comp_details != "" GROUP BY component

Upvotes: 0

mynawaz
mynawaz

Reputation: 1594

While you want to count conditionally yet your query does not have any WHERE part

SELECT component,count(comp_details) 
FROM table 
WHERE IFNULL(component, '') != ''
GROUP BY component

Upvotes: 2

Related Questions