diff options
Diffstat (limited to 'httemplate/browse/rate_region.html')
-rw-r--r-- | httemplate/browse/rate_region.html | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/httemplate/browse/rate_region.html b/httemplate/browse/rate_region.html index e144625a5..df3d2f0b8 100644 --- a/httemplate/browse/rate_region.html +++ b/httemplate/browse/rate_region.html @@ -33,8 +33,13 @@ my $extra_sql = ''; if ( driver_name =~ /^Pg/ ) { my $fromwhere = 'FROM rate_prefix'. ' WHERE rate_prefix.regionnum = rate_region.regionnum'; + my $prefix_sql = " CASE WHEN nxx IS NULL OR nxx = '' ". + " THEN npa ". + " ELSE npa || '-' || nxx ". + " END"; + my $prefixes_sql = "SELECT $prefix_sql $fromwhere AND npa IS NOT NULL"; $select .= "( SELECT countrycode $fromwhere LIMIT 1 ) AS ccode, - ARRAY_TO_STRING( ARRAY(SELECT npa $fromwhere AND npa IS NOT NULL), ',' ) AS prefixes"; + ARRAY_TO_STRING( ARRAY($prefixes_sql), ',' ) AS prefixes"; } elsif ( driver_name =~ /^mysql/i ) { $join = 'LEFT JOIN rate_prefix USING ( regionnum )'; $select .= "GROUP_CONCAT( DISTINCT countrycode ) AS ccode, |