Sample SOQL using Apex:
for ( User objUser : [ SELECT Id, Name, Profile.UserLicense.Name FROM User WHERE Profile.UserLicenseId != null ] )
system.debug( objUser.Profile.UserLicense.Name );
system.debug( objUser.Profile.UserLicense.Name );
Output: