147k views
1 vote
How to get count of particular column value in sql

User Katrin
by
8.4k points

1 Answer

4 votes

Final answer:

To count a particular column value in SQL, use the COUNT() function combined with WHERE clause to specify the value. For instance, SELECT COUNT(status) FROM users WHERE status = 'Active'; gives you the number of 'Active' records in the 'status' column.

Step-by-step explanation:

To get the count of a particular column value in SQL, you would use the COUNT() function in combination with a WHERE clause to filter the records that match the specific value. The basic syntax looks like this:

SELECT COUNT(column_name)

FROM table_name

WHERE column_name = 'value';

For example, if we want to count the number of times the value 'Active' appears in the 'status' column of a 'users' table, the SQL query would look like:

SELECT COUNT(status)

FROM users

WHERE status = 'Active';

This will return a single number representing the count of 'Active' records in the 'status' column.

User Ayyappan Anbalagan
by
8.4k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.