Drupal 10: Generate A List Of Published And Unpublished Node Counts

Use the following query to generate a list of the published and unpublished counts of nodes in your database.

SELECT
	type,
	SUM(case when status = 1 then 1 else 0 end) as publishedCount,
	SUM(case when status = 0 then 1 else 0 end) as unPublishedCount
FROM
	node_field_data
GROUP BY
	node_field_data.type
ORDER BY
	publishedCount DESC; 

Written using MySQL/MariaDB.

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
2 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.