SQL to query categories with no childrens in Wordpress

SELECT wp_terms.name, wp_terms.term_id
FROM wp_terms
INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id
WHERE wp_term_taxonomy.taxonomy = "category"
AND wp_terms.term_id NOT
IN (
SELECT DISTINCT parent
FROM `wp_term_taxonomy`
WHERE parent <>0
)
LIMIT 0 , 30