Sql to find narrow ranges within broad ranges in the same table?

hi,
i'm building a query to find narrow ranges of zip codes within broader
ranges in a table (for tax purposes). for example:
LOW_ZIP HI_ZIP
23400 23499
need to find
23401 23402
23403 23440
23441 23... you get the picture. :)
so, each row has a low value and a hi value, then i need to run a
subquery to take those values and find narrower ranges. any ideas?
so far here's what i have - neeless to say it doesn't work. :P
select sales_tax_id,
from_postal_code,
to_postal_code
from ar_sales_tax a,
(select from_postal_code as fpc,
to_postal_code as tpc
from ar_sales_tax
where rowid = rowid) b
where from_postal_code between b.fpc and b.tpc
and to_postal_code between b.fpc and b.tpc
and end_date is null

here's the table layout...
SQL> desc ar_sales_tax
Name Null? Type
LAST_UPDATE_DATE NOT NULL DATE
LAST_UPDATED_BY NOT NULL NUMBER(15)
CREATED_BY NOT NULL NUMBER(15)
CREATION_DATE NOT NULL DATE
LOCATION_ID NOT NULL NUMBER(15)
RATE_CONTEXT NOT NULL VARCHAR2(30)
ENABLED_FLAG NOT NULL VARCHAR2(1)
START_DATE NOT NULL DATE
END_DATE NOT NULL DATE
FROM_POSTAL_CODE NOT NULL VARCHAR2(30)
TO_POSTAL_CODE NOT NULL VARCHAR2(30)
TAX_RATE NOT NULL NUMBER
TAX_ACCOUNT NUMBER(15)
LOCATION1_RATE NUMBER
LOCATION2_RATE NUMBER
LOCATION3_RATE NUMBER
LOCATION4_RATE NUMBER
LOCATION5_RATE NUMBER
LOCATION6_RATE NUMBER
LOCATION7_RATE NUMBER
LOCATION8_RATE NUMBER
LOCATION9_RATE NUMBER
LOCATION10_RATE NUMBER
ATTRIBUTE_CATEGORY VARCHAR2(30)
ATTRIBUTE1 VARCHAR2(150)
ATTRIBUTE2 VARCHAR2(150)
ATTRIBUTE3 VARCHAR2(150)
ATTRIBUTE4 VARCHAR2(150)
ATTRIBUTE5 VARCHAR2(150)
ATTRIBUTE6 VARCHAR2(150)
ATTRIBUTE7 VARCHAR2(150)
ATTRIBUTE8 VARCHAR2(150)
ATTRIBUTE9 VARCHAR2(150)
ATTRIBUTE10 VARCHAR2(150)
ATTRIBUTE11 VARCHAR2(150)
ATTRIBUTE12 VARCHAR2(150)
ATTRIBUTE13 VARCHAR2(150)
ATTRIBUTE14 VARCHAR2(150)
ATTRIBUTE15 VARCHAR2(150)
PROGRAM_APPLICATION_ID NUMBER(15)
PROGRAM_ID NUMBER(15)
PROGRAM_UPDATE_DATE DATE
REQUEST_ID NUMBER(15)
DATE_FIRST_USED DATE
LAST_UPDATE_LOGIN NUMBER(15)
SALES_TAX_ID NOT NULL NUMBER(15)
SQL> spool off

Similar Messages

  • Is it possible to have Different Interval Ranges for the same Doc Type

    Dear All,
    Here is the issue.Is it possible to have different interval ranges for the same document type according to certain condition.Like my client , wants his interval ranges  be divided according to region(which are many)
    Regards,
    Sameer Jalees

    Hello,
    As you know we can only assign one number range for External and one number range group for internal in the sales document type.
    If you want different number ranges based on the regions, then as Jignesh suggested, you need to go for an enhancement.
    Use the exit USEREXIT_NUMBER_RANGE in program MVA45AFZZ, include a Z table with region as a critera and number range group for different numbers based on the regions. Talk to the business and get more details, get the help of ABAP team for technical details.
    Regards,
    SAM

  • SQL Developer no longer letting me look at the same table name on 2 servers

    I used to be able to look at the same table (such as; "ATS_Reminders") on both my development box and my production box at the same time. Now when I connect to both databases, if I try to open the same table on the second box, the first table closes so I can't look at them side by side. Is there a way to fix this annoying behavior?
    I'm on Windows 7 running:
    Java(TM) Platform     1.6.0_11
    Oracle IDE     3.1.07.42
    Versioning Support     3.1.07.42

    Hi bucketofsquid -
    You need to pin the 1st editor. This can be done manually by clicking the freeze view button on the object viewer toolbar or automatically by setting auto freeze on in preferences. Tools->Preferences->Database->ObjectViewer->Automatically Freeze Object Viewer Windows
    Brian Jeffries
    SQL Developer Team

  • I have OS V 10.6.8, i try to download 10.7.2 but it says i need 10.7 first, i then find 10.7.1 and i get the same error

    I have OS V 10.6.8, i try to download 10.7.2 but it says i need 10.7 first, i then find 10.7.1 and i get the same error

    You need to purchase OS X 10.7 Lion ($29.99 from the Mac App Store)  in order to udpate to 10.7.2. 

  • I have lost my apple 3gs before few days. Is there any possibilities to find it? Please advise me on the same.

    I have lost my apple 3gs before few days. Is there any possibilities to find it? Please advise me on the same.

    If you did not have Find My Phone turned on & enabled, other than physically looking for your phone, there is no way to locate it.

  • How do I find out if my iTunes ID is the same as my iCloud password?

    How do I find out if my iTunes password is the same as my iCloud password?

    Hello jenny86753092008,
    Welcome to the Apple Support Communities! Your iTunes and iCloud passwords will always be the same unless you have multiple accounts with us. To check to see if you have multiple accounts, you can use this handy Apple ID tool:
    Apple - My Apple ID
    https://iforgot.apple.com/appleid
    You can also contact us for assistance to see if you have multiple Apple ID accounts:
    If you forgot your Apple ID password - Apple Support
    http://support.apple.com/en-us/HT201487
    Make sure that you’re entering the correct Apple ID. In most cases, your Apple ID is also the primary email address of your Apple ID account. If these steps didn't help you change your password, contact Apple Support.
    Cheers,
    Matt M.

  • Filling a range with the same date in Numbers '09

    I know if you type a date in to a field and then drag the corner it will fill successive dates, but is there a way to fill a range of cells with the same date so I don't need to retype them each time?

    Create a pattern of what you want, then do "fill"
    Enter the same date in two or three cells, in a row or column, then drag to fill the range. Numbers should recognize the pattern you created and continue it.

  • Finding Both ( and ) open and closed as the same time in grep

    Hi,
    I have a character style I want to apply to all the () in my document.
    In the GREP area, the drop down shows I can select one at a time and make the change.
    Is there a way to find both at the same time regardless of how many characters are in between?
    thanks
    babs

    Hi Rodney,
    I have an update here.
    Ok-so yesterday everything worked great...
    Today, it's acting very weird.
    I am using the same find and change GREP I used yesterday: To find the (or)
    And i am changing it to the character style I made with the baseline shift change. It worked perfectly yesterday, and now it's deleting the ()????
    I thought maybe the document might be corrupt, so I made a new one and tried it and this was even worse. I had a bunch of () in the file and asked it to find in the GREP  [\(\)] and change to a character style I made and it told me it could not find any?
    Even if I chose, document, all documents selection, story, nothing worked???
    I trashed all the InDesign Prefs but still no go.
    Is this GREP stuff really that buggy or do you think it is something with my software and machine? If you have never seen anything like this, then I will throw up a new forum and try to find out if outers ahve problesm with this stuff.
    thanks!!
    babs

  • How to find a line/edge that starts at the same point as the end of another

    I have an edges table of Lat/Lon data and for a specific edge I want to find any other edges that have the same start point as the end point of the given edge.
    I tried the following query:
    select geo_street_id from geo_street s2
    where SDO_LRS.GEOM_SEGMENT_START_PT(s2.geom) =
    (select SDO_LRS.GEOM_SEGMENT_END_PT(s.geom) as geom from geo_street s
    where geo_street_id = 122978214)
    but it gets the following error:
    ORA-22901: cannot compare nested table or VARRAY or LOB attributes of an object type
    Any Ideas?

    1. to compare geometry to be equal you should use appropriate function (SDO_GEOM.RELATE http://download.oracle.com/docs/html/B14255_01/sdo_objgeom.htm#sthref1561) or operators (sdo_relate http://download.oracle.com/docs/html/B14255_01/sdo_operat.htm#i78531) with specific mask EQUAL.
    2. to filter down the resultset in first place you can use the operator SDO_RELATE with mask TOUCH as this will return already the set of lines sharing endpoints, but will also include lines touching eachother not at endpoints (endpoint intersecting the otherone's interior)
    something like
    select geo_street_id from geo_street s2, geo_street s
    where
    s.geo_street_id = 122978214
    AND
    sdo_relate(s2.geom, s.geom,'mask=touch') = 'TRUE'
    AND
    sdo_geom.relate(SDO_LRS.GEOM_SEGMENT_START_PT(s2.geom),
    'EQUAL',
    SDO_LRS.GEOM_SEGMENT_END_PT(s.geom),0.005)='EQUAL'
    3. if you would do this for the full table, an SDO_JOIN (http://download.oracle.com/docs/html/B14255_01/sdo_operat.htm#BGEDJIBF) might be more appropriate.
    4. you might also consider 4 cases:
    start = start
    start = end
    end = start
    end = end
    5. alternative would be to take only the endpoints of your selected geometry and perform a touch with the edges. using the sdo_util.APPEND on the startpoint en endpoint of your geometry will return a multipoint. although there might some specific cases that this would not return respected result I think
    something like:
    select geo_street_id from geo_street s2, geo_street s
    where
    s.geo_street_id = 122978214
    AND
    sdo_relate(s2.geom,
    SDO_UTIL.APPEND(
    SDO_LRS.GEOM_SEGMENT_START_PT(s.geom),
    SDO_LRS.GEOM_SEGMENT_END_PT(s.geom)
    ,'mask=touch') = 'TRUE'
    Let us know how it works.
    Luc

  • Can you use SQL as a data source for a project in the same way you can in Excel?

    Excel allows you to create a data source that executes a SQL stored procedure, display that data as a table in a spreadsheet and have that data automatically refresh each time you open the spreadsheet. Is it possible to do the same thing in MS Project, displaying
    the data from the stored procedure as a series of tasks?
    Here's what I'm trying to do - I have a stored procedure that pulls task data meeting a specific criteria from all projects in Project Server. We're currently displaying this data as an Excel report. However, the data includes start dates and durations so
    it would be nice to be able to display it as a Gantt Chart. I've played around with creating a Gantt chart in Excel and have been able to do a very basic one, but it doesn’t quite fit our needs.

    No, You can not use sql as a data source for a project.
    You have 3 options to achieve it:
    1. You can create a Sharepoint list with desired column ,fill desired data in that list then you can create a MS project from Sharepoint List.
    2. You can create a SSRS report in which you can display grantt chart Joe has given you that link.
    3. You can write a macro in MPP which will take data from your excel. In excel you will fetch data from your stored procedure. write a schedule which will run every day to update your data or
    create an excel report in which will update automatically and write macro in mpp which will fetch the data then publish it so that it would be available to team members.
    kirtesh

  • HT201493 can 2 pepole use find my friends on 2 devices with the same apple id

    My wife and I are connected to the same Apple ID we would like to use Find My Friends to follow each other but only one of use shows up on the map,

    The app should locate both phones if they are using the same iCloud account and the app is signed into the account.  If they are using different account, sign out, then sign back in with the other account to track the other phone.
    If one of them isn't showing and you're signed into the correct iCloud account, go to Settings>iCloud on the phone in question and turn Find My iPhone Off, then back On.

  • How to use the find Iphone app on two devices with the same itunes and apple id number?

    I have two Iphones connected to the same apple id . I am unable to use the find my iphone app on both devices. It only works on one!! Please help! It is driving me crazy lol!!

    The app should locate both phones if they are using the same iCloud account and the app is signed into the account.  If they are using different account, sign out, then sign back in with the other account to track the other phone.
    If one of them isn't showing and you're signed into the correct iCloud account, go to Settings>iCloud on the phone in question and turn Find My iPhone Off, then back On.

  • How can you find out if another VI running on the same computer and how can you find out the name of that VI?

    Suppose that several VIs running simultaneously on the same computer. How can I find out the names of the running VIs, from another VI?
    If the already running VIs are clones of the same basic VI, open and run with the option "Prepare to call and forget", how can I find out the names and index of each clone? 

    I had an application where I spawned (= ran with Start Asynchronous Call) multiple (reentrant) copies of VIs, and would occasionally "lose control" of them.  I needed a way to find all VIs that were running "Top Level" and stop them (so I didn't have to log off from Windows).
    I used the Application Property "All VIs in Memory" to get an array of (wait for it ...) All VIs in Memory.  I took each name, opened a VI reference to it (simply wire the name string in, as the VI is, by definition, "in memory"), looked at its VI Execution State, and if it was Run Top Level, Invoked the FP.Close and Abort VI Methods.  [To prevent the VI that did all this from "committing Suicide", I compared the name string with the current Call Chain, and did nothing if there was a match].
    I think you could adopt this idea to do what you need.
    BS

  • HT4759 Is it true that when setting up devices with the find my phone app you must use the same account for ICloud ? If so how do I delete a current account to make it read as the other ICloud accounts?

    I'm setting up my devices with the find my phone app. I have accomplished setting up 2 devices. The third I can't setup because I can't change the iCloud account.
    My understanding from reading that the iCloud accounts must use the same name on all devices. How do I change that account in my phone settings?

    You don't have to use the same iCloud account in order to track all your devices.  You just have to sign into the iCloud account being used on the device you are trying to track in order to track it.  When you sign in on icloud.com and open Find My iPhone, you will see all the devices with Find My iPhone enabled that are using the account you signed in with.  To track a device using a different account, simply sign out, then sign back in using the ID the new device is using.
    The Find My iPhone app works the same way.  It will display devices based on the iCloud account you sign in with on the app.  To track a device using a different account, sign out, then sign back in with the iCloud ID that the new device is using.

  • How can I start a new paragraph within the same table cell?

    In Numbers, when adding text within a table frame, how can I start a new line within the same frame (rather than advancing to the next cell)?  I'd like to enter a mini-list of several items of various lengths of data.

    While Wayne's answer solves your problem, another possibility is to uncheck the box at the bottom of the Table inspector for "Return key moves to next cell." If that is unchecked, the return key types a paragraph return within the cell (the same as Option Return with the box checked).
    With that box unchecked, Shift Return types a soft return (new line without a paragraph break).

Maybe you are looking for