+my @states = (
+ qsearch({
+ 'table' => 'cust_main',
+ 'select' => 'DISTINCT(state)',
+ 'hashref' => { 'country' => 'US' }, # 477 report isn't relevant elsewhere
+ }),
+ qsearch({
+ 'table' => 'cust_main',
+ 'select' => 'DISTINCT(ship_state) AS state',
+ 'hashref' => { 'country' => 'US' },
+ }),
+ qsearch({
+ 'table' => 'cust_location',
+ 'select' => 'DISTINCT(state)',
+ 'hashref' => { 'country' => 'US' },
+ }),
+);
+
+{
+ my %seen = map {$_->get('state') => 1} @states;
+ @states = grep $_, sort keys(%seen);
+}
+