|
-
Query Efficiency
I'm trying to pull the highest valued suffix for a phone number from a phone number inventory table. When a number is first assigned to a customer it receives a suffix such as 888-437-7777-1. If that number is disconnected and than assigned to another customer it would look as follows 888-437-7777-2. I'm trying to pull all of the telephone numbers from the inventory but I only want the highest suffix of the number because that will be the current status of the number. I wrote this subquery.
select tni.tel_nbr_npa ||''||tni.tel_nbr_nxx ||''||tni.tel_nbr_line_range, tni.tel_nbr_suf, tni.tel_nbr_status
from tel_num_inv tni
where tel_nbr_suf = (select max(tel_nbr_suf) from tel_num_inv
where tni.tel_nbr_npa||''||
tni.tel_nbr_nxx ||''||tni.tel_nbr_line_range = tel_nbr_npa||''||tel_nbr_nxx ||''||tel_nbr_line_range)
It works but it is very slow. Is my syntax as efficient as possible? I'm new at writing subquerys and querys in general. Thanks in advance.
BradO
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|