Re: Selecting multiple dates that are outside a specified time period

Hi All,
I have the following dataset/table structure:
Order #     Customer ID     Order Date
4     10     14-Jan-09
3     10     25-Jul-08
2     10     20-Jul-08
1     10     15-Jul-08
What I'm trying to do is a tad complicated for my skillset. I want to be able to select a particular order date for each unique individual but I need to apply a rule that if each subsequent order date falls within 180 days of the previous order date, the date gets ignored until it reaches an order date that is more than 180 days so it captures that particular order along with the initial (minimum) order. So for the example above the first order date for Customer ID #10 is 15-jul-2008, each subsequent order (Order #'s 2 and 3) are within 180 days so they get ignored until Order #4 comes along which is exactly 183 days after the first order date so this goes beyond the 180 day time limit and the record needs to get included so I need a query that will essentially pull the following two records:
Order #     Customer ID     Order Date
1     10     15-Jul-08
4     10     14-Jan-09
Thanks,
Ed

This works for your sample data
SQL> with sample_data as (
  2    select 4 ord_no, 10 cust_no, to_date('14-Jan-2009', 'dd-mon-yyyy') dt
  3    from dual union all
  4    select 3, 10, to_date('25-Jul-2008', 'dd-mon-yyyy') from dual union all
  5    select 2, 10, to_date('20-Jul-2008', 'dd-mon-yyyy') from dual union all
  6    select 1, 10, to_date('15-Jul-2008', 'dd-mon-yyyy') from dual)
  7  select sd.* from sample_data sd
  8    join (select cust_no, min(dt) dt from sample_data
  9          group by cust_no) mo
10      on sd.cust_no = mo.cust_no and
11         (sd.dt = mo.dt or
12          sd.dt >= mo.dt + 180);
    ORD_NO    CUST_NO DT
         4         10 14-JAN-2009
         1         10 15-JUL-2008This will also include all orders more than 180 days after the first order.
John

Similar Messages

  • How do you select and move more than one bookmark at a time? Shift+Click does not select multiple items that are next to one another in a list because the item

    How do you select and move more than one bookmark at a time?
    Shift+Click does not select multiple items that are next to one another in a list because the items open in firefox before this happens.

    Use the bookmarks library. You may use Shift +Click, and Ctrl + Click to create groupings of selected bookmarks to drag and drop.
    * one method of opening the bookmarks library is keyboard shortcut <br /> Ctrl+Shift+B (Windows)
    *see also [[How to use bookmarks to save and organize your favorite websites]]
    *and [[Use bookmark folders to organize your bookmarks]]

  • Hi, I am using HP11 and iPlanet web server. When trying to upload files over HTTP using FORM ENCTYPE="multipart/form-data" that are bigger than a few Kilobytes i get a 408 error. (client timeout).

    Hi, I am using HP11 and iPlanet web server. When trying to upload files over HTTP using FORM ENCTYPE="multipart/form-data" that are bigger than a few Kilobytes i get a 408 error. (client timeout). It is as if the server has decided that the client has timed out during the file upload. The default setting is 30 seconds for AcceptTimeout in the magnus.conf file. This should be ample to get the file across, even increasing this to 2 minutes just produces the same error after 2 minutes. Any help appreciated. Apologies if this is not the correct forum for this, I couldn't see one for iPlanet and Web, many thanks, Kieran.

    Hi,
    You didnt mention which version of IWS. follow these steps.
    (1)Goto Web Server Administration Server, select the server you want to manage.
    (2)Select Preference >> Perfomance Tuning.
    (3)set HTTP Persistent Connection Timeout to your choice (eg 180 sec for three minutes)
    (4) Apply changes and restart the server.
    *Setting the timeout to a lower value, however, may    prevent the transfer of large files as timeout does not refer to the time that the connection has been idle. For example, if you are using a 2400 baud modem, and the request timeout is set to 180 seconds, then the maximum file size that can be transferred before   the connection is closed is 432000 bits (2400 multiplied by 180)
    Regards
    T.Raghulan
    [email protected]

  • How do I preview objects that are outside of artboard.

    Hello,
    When I placed an illustrator file in Indesign, I would select command+D > select "Show Import Options" and we have a preview of the image. On some occasions, the preview will include all extraneous objects that are outside of the artboard and other times, it will display only the image within the artboard or bounding box. (Please see attached samples)
    Does anyone know the reason behind this?
    Thanks,
    Sutagami

    The only way I can reproduce what you are experiencing is if I save out as an .eps and am not mindful of the Artboard check box on the save dialog. If you deselect this check box you will get all of the file content, if you select this check box you will only get the designated Artboard bounding area. But you never said what file format your are saving or what version of Illustrator you are using. I have to assume you are in CS4.

  • How to avoid purchasing multiple things that are the same but different titles

    How can I avoid purchasing multiple things that are the same but have multiple names but is the same purchase for the same use?

    "Things"?  What things?  Apps for keeping track of when to change cat litter?  30 different versions of "twinkle, twinkle little star" played by everything from punk rockers to Gregorian chant?  Videos on the best way to make Christmas cake?

  • Can I insert into a form build in FORMSCENTRAL, a Formula with the numerical data that are updated by a given formula, like in Excel?

    Can I insert into a form build in FORMSCENTRAL, a Formula with the numerical data that are updated by a given formula, like in Excel?

    Hello danna,
    please have a look there as a first step: http://helpx.adobe.com/acrobat-com/formscentral/topics.html  >>> Formula syntax for built-in functions  >>> http://helpx.adobe.com/acrobat-com/formscentral/help/formula-syntax-built-in-functions.htm l
    Hans-Günter

  • How do I get files from multiple DVDs that are using thesame file names?

    How do I get files from multiple DVDs that are using thesame file names? Message says "file already exists in catalog"
    Message was edited by: marcr56

    marcr56
    I am viewing your question from different perspective, that is, the issue that you face when you are ripping VOBs from a second DVD-VIDEO on DVD disc using Premiere Elements,
    It is best to give the Premiere Elements version and computer operating system that it is running on. In the absence of that, I will generalize.
    Assuming that you are using
    Premiere Elements 12
    Add Media
    "DVD Camera or Computer Drive"
    Video Importer
    Typically the Video Importer Save In: is C:\Users\Owner\Videos
    Each of your DVD discs is going to have the same names for the ripped VOBs (VTS_01_1.VOB and so on depending on the duration of the movie). Consequently, after the ripping of the first DVD's VOBs and their save to Videos, you will end up with that "files already existing..." block for the ripping of the VOBs from the second DVD.
    The answer is, for each DVD disc VOB ripping, to plan ahead and create and set for different folders in Videos in the Save In field of the Video Importer.
    Please review and then let us know if that works for you. Please do not hesitate to ask if you need clarification on anything that I have written.
    Thank you.
    ATR.

  • How do I delete multiple photos that are stored on my IPAD imported folder? I have a first generation IPad

    How do I delete multiple photos that are stored on my IPAD imported folder? I have a first generation IPad

    The links below have instructions for deleting photos.
    iOS and iPod: Syncing photos using iTunes
    http://support.apple.com/kb/HT4236
    iPad Tip: How to Delete Photos from Your iPad in the Photos App
    http://ipadacademy.com/2011/08/ipad-tip-how-to-delete-photos-from-your-ipad-in-t he-photos-app
    Another Way to Quickly Delete Photos from Your iPad (Mac Only)
    http://ipadacademy.com/2011/09/another-way-to-quickly-delete-photos-from-your-ip ad-mac-only
    How to Delete Photos from iPad
    http://www.wondershare.com/apple-idevice/how-to-delete-photos-from-ipad.html
    How to: Batch Delete Photos on the iPad
    http://www.lifeisaprayer.com/blog/2010/how-batch-delete-photos-ipad
    (With iOS 5.1, use 2 fingers)
    How to Delete Photos from iCloud’s Photo Stream
    http://www.cultofmac.com/124235/how-to-delete-photos-from-iclouds-photo-stream/
     Cheers, Tom

  • I somehow erased everything (all important dates) off my ical on my mac and I'm afraid that if I connect my iphone that it will do the same there.  Will my iphone sync the dates that are on the phone and add them to the ical?  Or will it delete everything

    I somehow erased everything (all important dates) off my ical on my mac and I'm afraid that if I connect my iphone that it will do the same there.  Will my iphone sync the dates that are on the phone and add them to the ical?  Or will it delete everything

    Contacts are designed to be synced to a supported application on the computer or a cloud service.
    Pictures taken with the device are designed to regularly be copied off the device to a computer as would be done with any digital camera.
    If you have failed to use the device as designed it may be too late to recovery anything.
    Is the device regularly backed up to a computer via iTunes?  If so, the most recent backup (when restored to a replacement iOS device) should contain all contacts and pictures as of when the backup was created.

  • Need a VB-Script that read a txt-file and only the lines that are new since last time

    Hi,
    I need help to write a VB script that read all new lines since the last time.
    For example:  The script reads the textfile at specific time, then 10 minutes later the script read the file again, and it should now only read the lines that are new since last time. Anyone that has such a script in your scriptingbox?
    cheers!
    DocHo
    Doc

    Based on the excellent idea by Pegasus, where is a VBScript solution. I use a separate file to save the last line count read from the file, then each time the file is read I update the line count. Only lines after the last count are output by the program:
    Option Explicit
    Dim strFile, objFSO, objFile, strCountFile, objCountFile, strLine, lngCount, lngLine
    Const ForReading = 1
    Const ForWriting = 2
    Const OpenAsASCII = 0
    Const CreateIfNotExist = True
    ' Specify input file to be read.
    strFile = "c:\Scripts\Example.log"
    ' Specify file with most recent line count.
    strCountFile = "c:\Scripts\Count.txt"
    ' Open the input file for reading.
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(strFile, ForReading)
    ' Check if the line count file exists.
    If (objFSO.FileExists(strCountFile) = False) Then
        ' Initial count is 0, so all lines are read.
        lngCount = 0
    Else
        ' Open the line count file.
        Set objCountFile = objFSO.OpenTextFile(strCountFile, ForReading)
        ' Read the most recent line count.
        Do Until objCountFile.AtEndOfStream
            lngCount = CLng(objCountFile.ReadLine)
        Loop
    End If
    ' Read the input file.
    lngLine = 0
    Do Until objFile.AtEndOfStream
        ' Count lines.
        lngLine = lngLine + 1
        strLine = objFile.ReadLine
        If (lngLine >= lngCount) Then
            ' Output the line.
            Wscript.Echo strLine
        End If
    Loop
    ' Close all files.
    objFile.Close
    If (lngCount > 0) Then
        objCountFile.Close
    End If
    ' Ignore last line of the file if it is blank.
    If (strLine = "") Then
        lngLine = lngLine - 1
    End If
    ' Save the new line count.
    Set objCountFile = objFSO.OpenTextFile(strCountFile, _
        ForWriting, CreateIfNotExist, OpenAsASCII)
    objCountFile.WriteLine CStr(lngLine + 1)
    objCountFile.Close
    Richard Mueller - MVP Directory Services

  • Select Multiple refinements of a facet at a time

    Hi,
    Could anyone suggest me to implement selecting multiple refinements of a facet at a time( it should be function as OR). In documentation, i see it is buit in functionality in ATG 9 version with PIPE symbol ( eg Blue |Green) . But i am using ATG 2007.3.
    Thank you
    -kranthi

    hi Jhansi,
    thank you very much for your response.
    nevertheless, this is not what I wanted to do (perhaps I should explain better).
    In fact, what I want is is to do as if I clicked on every single line of my table, but in one time (without cliking on them one by one...)
    I do not want to short them with color, I reall want to select every one of them, but in one time.
    thanks a lot
    regards,
    pierre

  • Dispatch center - Select multiple tasks for scheduling at the same time

    Hi!
    I need a consultation regarding Dispatch center. Is there a functionality to select multiple tasks for scheduling at the same time for one resource?
    Please, guys, this is urgent.
    Jan

    You can schedule a single task or multiple tasks automatically directly from the
    dispatch center. The scheduling criteria applied come from Advanced Scheduler.
    Make Sure, you have the advanced scheduler. With out Advanced Scheduler and by just using Advice, you can only assign one task at a time.
    HTH
    ps: for more information, refer Field Service User Guide, "Scheduling Tasks"

  • Getting Lync enable users who are modified after specified time

    Getting Lync enable users who are modified after specified time
    Hi,
    I need to get all the Lync enabled users from Lync 2010 server who are modified after specified time.
    I have written a client with this below code for my purpose
    string
    dateString = "11/4/2014 11:19:10 PM";
    DateTime
    lastModifiedTime = DateTime.Parse(dateString, System.Globalization.CultureInfo.InvariantCulture);
    PSCommand command = new PSCommand();
    command.AddCommand("Get-CsUser");
    command.AddParameter("Filter",
    "WhenChanged -gt " + lastModifiedTime.ToString());
    powershell.Commands
    = command;
    Collection<PSObject> outPut = powershell.Invoke();
    But on calling Invoke method I am getting the below exception,
    Cannot bind parameter 'Filter' to the target. Exception setting "Filter": "Invalid cast problem for value: "11" type: "System.Nullable`1[System.DateTime]" query: "WhenChanged -gt 11/4/2014 11:19:10 PM" "17""
    Can anyone please point me what am I doing wrong.
    This command
    Get-CsUser -filter {whenchanged -gt
    "11/4/2014 11:19:10 PM"}
    when run directly on Windows Powershell works fine.
    Thanks in advance.
    Sandeep

    It appears you may be casting the date variable wrong. 
    If you have
    command.AddParameter("Filter",
    "WhenChanged -gt 11/4/2014 11:19:10 PM"
    And avoid the lastModifiedTime.ToString() addition, does it work?
    If so, it's just the way you're doing your date manipulation.
    Also, why convert from a string to a datetype and back for the datestring?  Are you trying to correct a timezone issue?
    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question please click "Mark As Answer".
    SWC Unified Communications
    This forum post is based upon my personal experience and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Select multiple date ranges?

    I am looking to select from a set of date ranges. I know that a UNION will work, but how to I get a valid set of results from multiple dates without a UNION?
    example:
    select date from test
    where date >= '01-MAR-07 0000'
    and date <= '02-MAR-07 0000'
    and date >= '04-MAR-07 0000'
    and date <= '08-MAR-07 0000'
    order by date;
    This gets zero records.
    But if I use UNION:
    select date from test
    where date >= '01-MAR-07 0000'
    and date <= '02-MAR-07 0000'
    union
    select datre from test
    and date >= '04-MAR-07 0000'
    and date <= '08-MAR-07 0000'
    order by date;
    It works, I get the records in no test table.
    How can I structure this query to work without UNION?

    true, date is taken eh?
    I am still running into an issue:
    Let's say I am using the following context:
    select date1, name from test
    where name in ('SUNDAR', 'ASUNDAR')
    and date1 >= '01-MAR-07 0000'
    and date1 <= '03-MAR-07 0000'
    or (date1 >= '05-MAR-07 0000'
    and date1 <= 07-MAR-07 0000');
    My results are wrong, it would not include the select as part of the or clause.

  • Why does it let me erase only one cookie at a time, or all cookies at once, and not let me select multiple cookies that I want to delete?

    Do you not realize that there are HUNDREDS of cookies in the Cookie Jar? I want to save SOME of them (banks, stores, Facebook, etc.) but get rid of the rest. Why have you made it so that I can't click & drag (or otherwise select) multiple cookies for deletion? You're going to make me delete them one at a time? What could possibly be the reasoning for such a decision? Or is it an oversight?

    The last Firefox version that runs on Mac OS X 10.4 is Firefox 3.6.28.
    Current Firefox versions require a Mac with an Intel processor and OS X 10.6 (Firefox 16 runs on Intel Mac OS X 10.5).
    *http://www.mozilla.org/firefox/22.0/system-requirements/
    For an unofficial Firefox 17.0.7 ESR compatible version (TenFourFox) that runs on a PowerPC Mac with OS X 10.4.11 or OS X 10.5.8 you can look at:
    *http://www.floodgap.com/software/tenfourfox/
    *http://www.macupdate.com/app/mac/37761/tenfourfox
    *http://code.google.com/p/tenfourfox/wiki/ReleaseNotes1707
    See also:
    *http://code.google.com/p/tenfourfox/wiki/PluginsNoLongerSupported
    *http://code.google.com/p/tenfourfox/wiki/QuickTimeEnabler
    *http://code.google.com/p/tenfourfox/wiki/AAATheFAQ

Maybe you are looking for

  • Is there a compatibility issue with the Current USB 3 external Hard drives and MacBook Pro 2011 (USB 2)?

    I am currently having bad hangs with my 13" MacBook Pro (2011) which I book 2012 ad a New external Harddrive (WD My Passport Edge) which was given to me as a gift. Friends of mine told me there is a compatibility issue between the USB 3 cord and the

  • Unable to install iTunes 11.1.4.62 on Windows 7 64-bit computer

    Received notice of iTunes update to currently installed version of iTunes, first on media computer, then on every day computer (both Windows 7 64-bit).  Successfully installed iTunes 11.1.4.62 on media computer, then attempted download and install on

  • Date format in BEx Analyser / PreCalc Server

    Hi All, First off, i have read many threads in this forum but none seem to solve our issue. So hopefully somebody will have a fresh view on this. When i broadcast a workbook from BEx Broadcaster using a Precalc server, the date format displays as mm/

  • Size of image is getting increased

    Hi I have cross compiled BDB using m68k-elf toolchain. I'm using motorola coldfire processor with uClinux for our development purpose. Now I need to include BDB into uClinux and flash it into our processor. The flash we are using is 4mb. The image I

  • Cam problem in win 8.1

    i installed new skype but when i am chating with any one i cant see that persons video it appears as distorted broken image with scattered view  please help my cam is fine in other apps and i can see it fine also if person is chating from mobile with