use GROUP BY instead of DISTINCT ON in the state and country queries for better cross...
[freeside.git] / FS / FS / Misc.pm
index 101a2d4..06fa51f 100644 (file)
@@ -359,10 +359,12 @@ sub states_hash {
 #     sort
      map { s/[\n\r]//g; $_; }
      map { $_->state; }
-     qsearch( 'cust_main_county',
-              { 'country' => $country },
-              'DISTINCT ON ( state ) *',
-            )
+     qsearch({ 
+               'select'    => 'state',
+               'table'     => 'cust_main_county',
+               'hashref'   => { 'country' => $country },
+               'extra_sql' => 'GROUP BY state',
+            })
   ;
 
   #it could throw a fatal "Invalid country code" error (for example "AX")