如果启用始终为1或0,则可以执行以下操作:
SELECT COUNT(*) as total_count, SUM(enabled) as enabled_count FROM widget
如果它是另一个值,也许:
SELECT COUNT(*) as total_count, SUM( CASE WHEN enabled in ('enabled value 1', 'enabled value 2') THEN 1 ELSE 0 END ) as enabled_count FROM widget