According to https://docs.jboss.org/author/display/MODE50/JCR-SQL2#JCR-SQL2-SinceModeShape4.0: it is not possible to query nodes with no children in JCR-SQL2.
You must write a simple groovy script to get all the folders node and check if there is a child node or not.
Although in SQL2 you can get nodes with children node using joins