1 of 5

I do not think that Wikidata is reliable source in this case. However, just as an exercise:

SELECT DISTINCT ?stateLabel ?capitalLabel ?countyLabel WHERE
 {
    {
    ?county wdt:P31/wdt:P279* wd:Q47168 .
    ?county wdt:P36 ?capital .
    }
    UNION
    {
    ?county wdt:P31 wd:Q3301053 .
    BIND (?county AS ?capital)
    }
    UNION
    {
    ?county wdt:P31 wd:Q1266818 .
    BIND (?county AS ?capital)
    }
    UNION
    {
    ?county wdt:P31/wdt:P279* wd:Q47168 .
    FILTER NOT EXISTS {?county wdt:P36 ?capital }
    FILTER NOT EXISTS {?county wdt:P31 wd:Q3301053 }
    }
   OPTIONAL {?county wdt:P131 ?state}
   SERVICE wikibase:label {bd:serviceParam wikibase:language "en" .}
 } ORDER BY (!BOUND(?stateLabel)) ASC(?stateLabel) (!BOUND(?capitalLabel)) ASC(?capitalLabel)

Try it!