Can record comparisons be done without functions or PLSQL

I am used to writing Oracle functions to do record comparisons, however on this particular project the managers do not want to use functions or PLSQL
Is there a way to do the following with a SQL statement rather than writing a function - see data set below? Oracle 9i.
I have the following data set used to track packages that are moved from warehouse to warehouse on trucks
I only want to retrieve a record if the starting location is Dallas Ft Worth and the end location is another city.
I do not want to retrieve a record if the package moves between other cities (say Boston and New York)
For this data set package 1324 was added and removed to the warehouses at Dallas 4 times via truck 735 before it was finally moved to a warehouse in Boston by the same truck
I want the query to return the following record
105273     345          1324               725          11/3/2010 14:32               11/3/2010 15:46               Dallas Ft Worth          WH4
Showing the last location in Dallas before it was moved to Boston
I do not want to return any of the Boston or NY records or any of the previous Dallas Ft Worth Records.
The way the system updates the records is as follows:
If a package is added to a warehouse the record gets an added date.
When it is removed the system updates the removed date of that same record
Once it is added to a new warehouse there is a new record with an added date and null date for the removed date unless it leaves that location
In the record set if the removed date is null then that is the current location of the package
CREATE TABLE package_location
( track_id NUMBER(10)
, sender_id NUMBER(10)
, package_id NUMBER(10)
, truck_id NUMBER(10)
, package_add_date DATE,
, package_remove_date DATE,
, city VARCHAR2 (50)
, Warehouse VARCHAR2(50)
INSERT ALL
INTO package_location(track_id, sender_id, package_id, truck_id, package_add_date, package_remove_date, city, warehouse) VALUES (100012
, 345, 1324, 725, 8/4/2010 2:39:48 PM, 8/4/2010 2:53:07 PM, 'Dallas Ft Worth', 'WH1')
INTO package_location(track_id, sender_id, package_id, truck_id, package_add_date, package_remove_date, city, warehouse) VALUES (100016
, 345, 1324, 725, 8/4/2010 2:53:07 PM, 9/30/2010 10:41:01 AM, 'Dallas Ft Worth', 'WH2')
INTO package_location(track_id, sender_id, package_id, truck_id, package_add_date, package_remove_date, city, warehouse) VALUES (103055
, 345, 1324, 725, 9/30/2010 10:41:01 AM, 11/3/2010 2:32:14 PM, 'Dallas Ft Worth', 'WH3')
INTO package_location(track_id, sender_id, package_id, truck_id, package_add_date, package_remove_date, city, warehouse) VALUES (105273
, 345, 1324, 725, 11/3/2010 2:32:14 PM, 11/3/2010 3:46:22 PM, 'Dallas Ft Worth', 'WH4')
INTO package_location(track_id, sender_id, package_id, truck_id, package_add_date, package_remove_date, city, warehouse) VALUES (105284
, 345, 1324, 725, 11/3/2010 3:46:22 PM, 11/22/2010 11:55:18 AM, 'Boston', 'WH34')
INTO package_location(track_id, sender_id, package_id, truck_id, package_add_date, package_remove_date, city, warehouse) VALUES (106674
, 345, 1324, 725, 11/22/2010 11:55:18 AM, NULL, 'New York', 'WH56')
I tried to do a query with a subquery... the main query was getting all the records with Dallas Ft Worth and then the subquery was to check if the location was not Dallas Ft Worth, but so far I haven't quite been able to get the correct dataset.
Any help is greatly appreciated. I don't know if there is a way to do this with just a sql query, if not other suggestions are welcomed!
Thanks in advance

I added a couple of rows to your table, shipping the package back from New York to Dallas on a different truck, then back out from Dallas to New York just to make sure I understand the requirements.
SQL> SELECT * FROM package_location;
  TRACK_ID  SENDER_ID PACKAGE_ID   TRUCK_ID PACKAGE_ADD_DATE     PACKAGE_REMOVE_DATE  CITY             WAREH
    100012        345       1324        725 04-aug-2010 14:39:48 04-aug-2010 14:53:07 Dallas Ft Worth  WH1
    100016        345       1324        725 04-aug-2010 14:53:07 30-sep-2010 10:41:01 Dallas Ft Worth  WH2
    103055        345       1324        725 30-sep-2010 10:41:01 03-nov-2010 14:32:14 Dallas Ft Worth  WH3
    105273        345       1324        725 03-nov-2010 14:32:14 03-nov-2010 15:46:22 Dallas Ft Worth  WH4
    105284        345       1324        725 03-nov-2010 15:46:22 22-nov-2010 11:55:18 Boston           WH34
    106674        345       1324        725 22-nov-2010 11:55:18                      New York         WH56
    106675        345       1324        804 25-nov-2010 09:55:18 30-nov-2010 15:46:22 Dallas Ft Worth  WH4
    106676        345       1324        804 25-nov-2010 09:55:18 01-dec-2010 15:46:22 New York         WH42Given this data, you would want to get back track_id 105273 and 106675 correct?
If so, then something like:
SQL> SELECT track_id, sender_id, package_id, truck_id, package_add_date,
  2         package_remove_date, city, warehouse
  3  FROM (SELECT track_id, sender_id, package_id, truck_id, package_add_date,
  4               package_remove_date, city, warehouse,
  5               LEAD (city) OVER(PARTITION BY package_id
  6                                ORDER BY package_remove_date) next_city
  7        FROM package_location)
  8  WHERE city = 'Dallas Ft Worth' and
  9        next_city != city;
  TRACK_ID  SENDER_ID PACKAGE_ID   TRUCK_ID PACKAGE_ADD_DATE     PACKAGE_REMOVE_DATE  CITY             WAREH
    105273        345       1324        725 03-nov-2010 14:32:14 03-nov-2010 15:46:22 Dallas Ft Worth  WH4
    106675        345       1324        804 25-nov-2010 09:55:18 30-nov-2010 15:46:22 Dallas Ft Worth  WH4John
Edited by: John Spencer on Aug 14, 2011 2:22 PM
Fixed non-displaying operator

Similar Messages

  • I just bought a new Ipad mini a while ago, a created a new apple ID "***************" , I can't download anything on apps store, it keeps on asking for a credit card but I don't have one. Can I create an account without a credit card?

    I just bought a new Ipad mini a while ago, and created a new apple ID *********** , I can't download anything on apps store, it keeps on asking for a credit card but I don't have one. Can I create an account without a credit card?
    <Edited by Host>

    Read this:
    iTunes Store: Accepted forms of payment
    It is the same for the app store. You are required to have some sort of payment method in the record.
    Barry

  • Every time I try to download a free or paid app or in iTunes   it asks me for a credit card. (Which i don't have one)  How can i download free apps without a credit card and not reset my apple ID? I already put in 20$!!!!!

    Every time I try to download a free or paid app or in iTunes 
    it asks me for a credit card. (Which i don't have one)
    How can i download free apps without a credit card and not reset my apple ID?
    I already put in 20$!!!!!

    How to Get Apps From the App Store Without a Credit Card
    http://ipadhelp.com/ipad-help/how-to-get-free-apps-from-the-app-store-without-a- credit-card/
    Creating an iTunes Store, App Store, iBookstore, and Mac App Store account without a credit card
    http://support.apple.com/kb/ht2534
    If None is not available - On your computer launch iTunes and click "iTunes Store" in the left navigation pane. Click the "down arrow" next to your name at the top right side of the page and click "Account." Enter your username and password and click "View Account" to log into your account information. Next to your Payment Type, click "Edit." Select the "None" button and click "Done." Confirm that your card has been removed by returning to the Apple account information screen. Under Payment Type, it should say that there is no credit card on file.
     Cheers, Tom

  • IPod 5G video + Belkin TuneTalk stereo recording don't function

    iPod 5G video 30Gb + Belkin TuneTalk stereo recording don't function on firmware 1.2.1
    every 48 second it skips for 1 - 2 seconds in HQ MODE
    Belkin say: It's how Apple manage the write from storage to hard disc
    It's a shame that this is already more then 5 mounths !!!!
    no possibilaty to downgrade the firmware..;(
    1 not one note on Belkin.com site (they still sell it !!)
    or
    2 on Apple update site
    NOTE here on the discussion from januari 2007 !!!
    When I record in stereo, it skips through out the recording. I'll be listening to what I have recorded, and I'll notice that chunks of about 3 seconds are missing from the recording
      Mac OS X (10.4.9)   G5

    actually a very similar problem here. the recording was 35 min and it jumps and skips down to about 7 min. I thought it was a problem with the wav file that was recorded so I converted it to mp3 to and the same problem.
    i do have firmware 1.2.1 but had never successfully used it before this attempt. did you ever get any resolution on this?

  • Everytime I try to update to iOS5 on my iPhone 4 I get an error containing 0xE while it is trying to backup data from the iPhone.  I have done everything suggested in Apple support.  How can I upgrade to iOS5 without losing all the data on my phone?

    Everytime I try to update to iOS5 on my iPhone 4 I get an error containing 0xE while it is backing up data from the iPhone before installing the new operating system.  I have done everything suggested in Apple support with no success.  I still get the error everytime (about 5 minutes into backing up iPhone data).  How can I upgrade to iOS5 without losing all the data on my iPhone (the error message says that if I continue I will lose all data on the phone)?  If I have already synced the phone before upgrading the OS, would I be able to restore my data after installing the new OS by syncing after the OS upgrade is complete?  Any help would be greatly appreciated. 

    I had the same problem today and was able to resolve it without having to do a restore or reset. The problem had something to do with my mail accounts. The upgrade reset my mail settings, switching both my gmail and my .mac mail to "archive all mail". I went into the General Settings, disabled that setting, and resynced the phone. The "other" storage allottment dropped back down to less than a gig.
    Before you restore or reset, I would try that first.

  • In BW Reporting what can be done without transport

    Hi Experts,
    In BW Reporting what can be done without transport. Suppose
    RRI, DIS to Nav changes
    Please Detail or any documentation.
    Thanks

    Dear,
    You cannot make changes in underlying structure of objects in prod system , the changes shoud always come through a proper tranport layer ( dev -- QA -- prod).
      CTS(change and tranport system) is build to manage all changes across system , it takes care of versioning as well.
    Usually in production system you can do data loading and other data oriented activities.
    If you need to work on object related changes, start from a dev system.
    regds
    Jay

  • Adobe Bridge has been deleted and needs to be re-installed. How can this be done without reinstallin

    Adobe Bridge has been deleted and needs to be re-installed. How can this be done without reinstalling the entire CS5

    Hi RDMDanielM,
    Welcome to the Community!
    We cannot install Adobe Bridge as a Standalone product, you can just reinstall Photoshop and Bridge will be reinstalled with it. Go ahead and start uninstalling CS5 suite but choose Photoshop from the list and the same will be applicable while Installation.
    Thanks!
    Ankit

  • I need a app which can record incoming and outgoing calls automatically without internet

    i need a app which can record incoming and outgoing calls automatically without internet.
    Can some help me on this ?

    As far as I know there is no app to record phonecalls because US regulations, but I am not using iphone in US so we definately need call recorder. HTC or Samsung has call recorder so why we dont?

  • Can compression be done without changing YUV by using QuickTime SDK?

    Hi,
    I am using QuickTime 7.3 SDK on Mac OS 10.6.1.
    I was trying to compless in picture an aplication, using Quicktime SDK.
    Can compression be done without changing YUV of picture by using QuickTime SDK?
    Can compression be done without changing YUV of picture by using anoter soft?
    If it is possible to do , it teaches to me the soft.

    Hi,
    I am using QuickTime 7.3 SDK on Mac OS 10.6.1.
    I was trying to compless in picture an aplication, using Quicktime SDK.
    Can compression be done without changing YUV of picture by using QuickTime SDK?
    Can compression be done without changing YUV of picture by using anoter soft?
    If it is possible to do , it teaches to me the soft.

  • How can I save my adjusments without clicking Done?

    In ACR,
    How can I save my adjusments without clicking Done?

    Do you mean you are wanting to save your adjustments file-by-file as you work on them without exiting ACR via Done and then having to go back into ACR from Bridge, each time?  I don’t know as you can that.  For Cancel to undo all adjustments for the batch of images, there can’t be something else that saves the adjustments incrementally for individual images.  Of course you’re in trouble if you accidentally hit Cancel after doing a batch of edits and lose everything.
    The Bridge/ACR workflow was developed many years ago and is pretty simple-minded.
    An alternative would be using Lightroom that remembers each adjustment as you do it and stores it in a permanent history so the adjustments are saved immediately but also can be undone, last-to-first, at any point in the future, for a particular image.

  • I  want to make a bootable usb drive for my macbook air,and my ystem is osx mountain lion 10.8.5. How can i download it again without repaying for it so i can make my bootable flashdrive? I'm pretty new at this computer stuff so i don't know how things

    I want to make a bootable usb drive for my macbook air,and my system is osx mountain lion 10.8.5. How can i download it again without repaying for it so i can make my bootable flashdrive? I'm pretty new at this computer stuff so i don't know how things work.
    Message was edited by: tzaphon

    This is not difficult and you will not have to download from the app store.
    your computer has what is called  a recovery partition that came with it.
    simply hold cmd+R while you boot up. let go a second after you hear the chime.
    you will boot into the recovery partition.
    Use disk utlity to format your usb drive and then exit Disk utlity and go to Reinstall Mountain Lion.
    it will ask  you which disk you want to install ML onto. Choose your new USB drive.
    easy peasy

  • Hi, I wish to buy an Adobe Master Collection CS3 (Corporate Edition) from someone in the US and I hope to use it in the UK. Does anyone know if this can be done without any problems, also does Adobe still allow people to register the CS3 Corporate Edition

    Hi, I wish to buy an Adobe Master Collection CS3 (Corporate Edition) from someone in the US and I hope to use it in the UK. Does anyone know if this can be done without any problems, also does Adobe still allow people to register the CS3 Corporate Edition? any help would be greatly appreciated

    The flaw is here:
    corporate edition
    ...which essentially means it's most likely a volume license and thus not transferable in the first place. The rest is as Steve said - buying software on eBay is risky even on the best of days.
    Mylenium

  • Can I use OLAP kind of functionality  without installing OLAP ( using materialized views etc)

    Hi,
    Can OLAP cube be implemented without having ORACLE OLAP installed? As per my understanding, cubes are something which keeps aggregate data. So can I just use materialized view functionality ( which is already there in Oracle)?
    Which other Oracle object can I use without  installing ORACLE OLAP ( Dimension etc?)
    Thanks a lot.
    Nitin

    If you mean by implementing an OLAP cube, you mean setting up reports for various summary level data analysis, it is possible to query materialized views to get the same data in some cases.   A position paper that describes the advantages of the OLAP Cube v. among other things standard materialized views may be found at this URL: http://www.oracle.com/technetwork/database/options/olap/olap-wp-12c-1896136.pdf?ssSourceSiteId=ocomen
    I also would recommend posting this question on the general database forum (General Database Discussions) as well.
    Hope this helps,
    Ken Chin

  • I have problems printing with a HP Officejet 6500 printer directly from my iMac. The printer itself does function well, as I can print from another PC without any problems. Does anyone have a clue?

    I have problems printing with a HP Officejet 6500 printer directly from my iMac. The printer itself does function well, as I can print from another PC without any problems. Does anyone have a clue?

    Hello:
    I must apologize  .  I should have checked here first:
    http://support.apple.com/kb/HT3669#HP
    According to the list, there is no driver for your printer included in OS X 10.7.
    There are a couple of options:
    1.  Contact HP to see if they have a workaround.
    2. If the model of printer is not listed but your printer is a PostScript printer or PCL Laser printer, try the "Generic PostScript" or "PCL Laser printer" drivers.  Generic printer drivers may not let you access all the features of your printer.
    I have not tried #2, but some people have had success.
    Barry

  • I built a 800 x 600 website in Dreamweaver. I now want it 1024 x 768. Can that be done without rebuilding the website?

    I built a 800 x 600 website in Dreamweaver. I now want it 1024 x 768. Can that be done without rebuilding the website?

    Dave,
    This is my css, what should I do?
    body
    .copy {
         font-family: Tahoma;
         font-size: 11px;
         line-height: 12px;
         color: #7B7979;
         text-decoration: none;
    .select {
         font-family: Tahoma;
         font-size: 10px;
         line-height: 12px;
         color: #7D7D7D;
         background-color: #FFFFFF;
         height: 17px;
         width: 106px;
         border: 1px solid #CDCDCD;
    .text_1 {
         font-family: Tahoma;
         font-size: 11px;
         line-height: 12px;
         color: #886600;
    .text_2 {
         font-family: Tahoma;
         font-size: 11px;
         line-height: 13px;
         color: #828282;
    .link_1 {
         font-family: Tahoma;
         font-size: 11px;
         line-height: 12px;
         color: #5C89C9;
    .form_1 {
         font-family: Tahoma;
         font-size: 11px;
         line-height: 12px;
         background-color: #FFFFFF;
         height: 17px;
         width: 228px;
         border-top-width: 1px;
         border-right-width: 1px;
         border-bottom-width: 1px;
         border-top-style: solid;
         border-right-style: solid;
         border-bottom-style: solid;
         border-top-color: #616161;
         border-right-color: #D4D0C8;
         border-bottom-color: #D4D0C8;
    .form_2 {
         font-family: Tahoma;
         font-size: 11px;
         line-height: 12px;
         background-color: #FFFFFF;
         height: 65px;
         width: 228px;
         border-top-width: 1px;
         border-right-width: 1px;
         border-bottom-width: 1px;
         border-top-style: solid;
         border-right-style: solid;
         border-bottom-style: solid;
         border-top-color: #616161;
         border-right-color: #D4D0C8;
         border-bottom-color: #D4D0C8;
         overflow:auto;

Maybe you are looking for

  • Scheduling agreement update with Info record

    Hi, My company is working with scheduling agreement both with external vendors and Inter company purchasing. SA is created for a long term (in years) but the price negotiation takes place for a shot duration (One year or less). The requirement is tha

  • Can we restore the system?

    Dear All: The system is CRM5.0 Unicode based on JAVA+ABAP stack. When we get the backup files, it contains DB files (SQL Server detach files) and whole copy of \usr\sap\<SID> folder (including DVEBMGS51, SCS50, SYS). And we also get the info that the

  • Corrupt pictures

    I just burned a disk of picutes from iPhoto 5.0.4, it burned just fine, but when I put the disk back in the computer to see the photos, there weren't any photos on the disk, just empty white frames. Also when I bring up some of my older albums from l

  • How to resolve iPhoto 9.4.1 to 9.4.2 Update Error 20

    How to resolve iPhoto 9.4.1 to 9.4.2 Update Error 20  Signing In Mac Apple store account after entering password buffers for awhile then error occurs retry repeatedly. Repaired permissions as instructed when opening iPhote App (cmmd+option+Open App s

  • Can I open multiple email accounts on my ipad?

    How can I open multiple email accounts on my ipad?