PHP query in a view will cause website error
You cannot directly insert values into queries in Drupal. They need to be escaped. You would want something like this:

$count_users_premium = db_query('SELECT COUNT(license_id) FROM {commerce_license} WHERE state=:active', [':active' =&gt; 'active'])-&gt;fetchField();