Looking for a query to find first/last dates in overlapping dates...

Hi,
I'm looking for a query to find the first dates and last dates in a table conaining overlapping dates.
I have a subscription table which has for each Customer start and end date for different subscriptions.
I want to know the different ranges of date where there is subscriptions active.
so if the table has this:
CustID, Start date, end date
1, 2008-01-01, 2012-06-06
1 ,2009-01-01, 2011-01-01
1, 2011-01-01, 2013-02-02
1, 2013-01-01, 2013-08-08
1, 2014-01-01, 2014-04-04
I want to produce this result:
custid, range start, range end
1, 2008-01-01, 2013-08-08
1, 2014-01-01, 2014-04-04
the first row is the range identified from the 4 rows in my subscription table.
thanks :)

I think I found it...
http://stackoverflow.com/questions/5213484/eliminate-and-reduce-overlapping-date-ranges
let me try this method
Hi,
m writing to follow up with you on this post. Thanks for you posting a reply to share your workground. Was the problem resolved after performing the above link? If you are satisfied with the above solution, I’d like to mark this issue as "Answered".
Please also feel free to unmark the issue, with any new findings or concerns you may have.
Thanks,
Sofiya Li
If you have any feedback on our support, please click here.
Sofiya Li
TechNet Community Support

Similar Messages

  • Query to find first and last call made by selected number for date range

    Hi,
    query to find first and last call made by selected number for date range
    according to filter:
    mobile_no : 989.....
    call_date_from : 25-april-2013
    call_date_to : 26-april-2013
    Please help

    Hi,
    It sounds like you want a Top-N Query , something like this:
    WITH    got_nums   AS
         SELECT     table_x.*     -- or list columns wanted
         ,     ROW_NUMBER () OVER (ORDER BY  call_date      ) AS a_num
         ,     ROW_NUMBER () OVER (ORDER BY  call_date  DESC) AS d_num
         FROM     table_x
         WHERE     mobile_no     = 989
         AND     call_date     >= DATE '2013-04-25'
         AND     call_date     <  DATE '2013-04-26' + 1
    SELECT  *     -- or list all columns except a_num and d_num
    FROM     got_nums
    WHERE     1     IN (a_num, d_num)
    ;This forum is devoted to the SQL*Plus and iSQL*Plus front ends. This question doesn't have anything to do with any front end, does it? In the future, you'll get better response if you post questions like this in the PL/SQL.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the SQL forum FAQ {message:id=9360002}

  • Looking for an app that finds a restaurant centrally located to me

    looking for an app that finds a restaurant centrally located to me and friends

    Try the App store:
    1. In search type R followed by E followed by S followed by T followed by A followed by U followed by R followed by A followed by N followed by T.
    2. Click SEARCH.
    3. Browse through results.
    4. Select the app that you want.
    5.Click download on the app you want.
    6.After that App is downloaded use the app.

  • Looking for a way to find out the x,y coordinates of a string inside a PDF

    Hi!
    I'm looking for a way to find out the x,y coordinates of a string inside a PDF (with free java api's only)
    I got a pdf, and a string to find inside it, what i need to do is to get this string x,y position inside that pdf....
    If any one knows of such, plz let me know...
    Thanx ahead
    Daniel.

    vedmack wrote:
    Hi!
    I'm looking for a way to find out the x,y coordinates of a string inside a PDF (with free java api's only)
    I got a pdf, and a string to find inside it, what i need to do is to get this string x,y position inside that pdf....
    If any one knows of such, plz let me know...
    Thanx ahead
    Daniel.AFAIK, a string of text does not have an (x,y) location inside a PDF file. The location is exists on your screen, and will differ whenever you adjust the resolution of it. Text can have a location when it's stored as an image though, but than it's really the location of a certain number of pixels (not necessarily a string!).

  • Hi..someone there?i am looking for an app, which can show and calculate. fully excel data from windows.until now i only found apps, which just show, but not calculate

    Hi..someone there?i am looking for an app, which can show and calculate fully excel data from windows.until now i only found apps, which just show, but not calculate.anybody who know an app???

    Look at the Rccharles answer on this post.
    https://discussions.apple.com/thread/6033082?tstart=0
    Also, you can download these free MS Office apps (Word, Excel, PowerPoint) to view (but not create or edit) these files.
    https://itunes.apple.com/us/app/microsoft-word-for-ipad/id586447913?mt=8
    https://itunes.apple.com/us/app/microsoft-excel-for-ipad/id586683407?mt=8
    https://itunes.apple.com/us/app/microsoft-powerpoint-for-ipad/id586449534?mt=8
    Microsoft Office for iPad:Early Reviews of Word, PowerPoint & Excel Apps
    http://ipadacademy.com/2014/03/microsoft-office-for-ipad-early-reviews-of-the-wo rd-powerpoint-excel-apps
     Cheers, Tom

  • SQL query to find out last login for each database

    Hi everybody,
    I have a view with following columns:
    DatabaseSid, lastLogin, firstLogin.
    I want to now the newest last_login date for every database.
    SID First Login Last Login
    e.g. Database1, 11.11.2011, 01.12.2011
    Database1, 01.04.2012, 01.05.2012
    Database3, 03.03.2004, 03.06.2005
    Database 3 07.09.2012, 12.10.2012
    How can I do a query to find out for eacht DB (DB1, DB2 and so on) the Last_Login Date?
    Thank you in advance
    Steve

    Steve wrote:
    Hi everybody,
    I have a view with following columns:
    DatabaseSid, lastLogin, firstLogin.
    I want to now the newest last_login date for every database.
    SID First Login Last Login
    e.g. Database1, 11.11.2011, 01.12.2011
    Database1, 01.04.2012, 01.05.2012
    Database3, 03.03.2004, 03.06.2005
    Database 3 07.09.2012, 12.10.2012
    How can I do a query to find out for eacht DB (DB1, DB2 and so on) the Last_Login Date?
    Thank you in advance
    SteveI'm curious as to how you collect this information from multiple databases into one database, and of what value the data is once you have it.

  • Looking for Mac Pro comparisons to first Mac Pro

    I have a Mac Pro Quad bought the same day the first intel mac pros came out. I had a horrible experience with my local Apple Store at the Summit in the Birmingham, AL area which was followed by an even worse experience with the Apple Online support. After standing at the Mac Pro waiting for 45 minutes at the store without anyone approaching me at all, I had to leave and then called the same store during my last 15 minutes of standing there to see if someone who answered the phone would come to the front of the store. After I left it was 25 minutes later before someone finally answered the phone. They tried locating anyone in the store and finding that no person there had a clue they forwarded me to the Apple Care line. Again after a 15 minute wait for someone there I thought I had someone who would answer my question and she got lots of info and was looking up my computer details and was about to answer the question and she accidentally hung up on me and never called back - knowing that I have no way of getting back in touch with her. Over an hour and a half shot with no answer.
    Now - what was the question - I have, as I said, an original Mac Pro (dual processor - duo core 2.66 Ghz with 4 GB Ram). I want real accurate net processor comparison data with the current dual Quad core Mac Pro computer. I don't just want to hear that "its a lot faster". The Apple website compares the previous 8 core with the current 8 core but nothing else. I would be happy with an accurate Specmark comparison. Other than basic browsing and email the vast majority of my work on the computer is video editing in Final Cut Pro and working with Adobe's Master Collection - Photoshop CS5, Premiere Pro, Flash, and Illustrator.
    Since Apple has failed miserably at helping me I am hoping there might be someone here with some clue as to what I am looking for. The website compares todays 8 core with today's 12 core and shows that for $1,500 more you get 33% speed improvement. Naturally that is not a good return but I am 100% confident that data exists somewhere that accurately compares my computer to the latest 8 core Mac Pro.
    Thanks

    I would direct you to Geekbench, Barefeats, MacPerformanceGuide for a couple starters.
    4GB RAM is/was very minimal and basic.
    What do you use and do on Mac Pro matters a lot as to what to expect.
    The 3.33GHz 6-core with SSD boot drive would be good, with 3-4 x 8GB RAM.
    http://discussions.apple.com/thread.jspa?threadID=2538895

  • Query to find First sunday of march and Second Sunday of November in SQL 2008

    Hi,
    I want query to find Second sunday of march and First Sunday of November in SQL 2008. This query can be used for Daylight savings(MST).
    Thanks in Advance.
    Regards,
    LuckyAbdul

    declare @d datetime,@d1 datetime
    set @d = '20140301'
    set @d1='20081101'
     SELECT @d1
    declare @baseMonday datetime
    set @baseMonday = '17530101'
    select
       @baseMonday + datediff(day,@baseMonday,@d)/7*7+13  as Sunday,
       @baseMonday + datediff(day,@baseMonday,@d1)/7*7+6 as Sunday1
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Looking for Pages script to find "return" "return" and delete 2nd one only

    Looking for a Pages Applescript to find "return" "return" and delete 2nd one only. Perform on entire document.
    Thanks

    Funny, the same question was asked on 2011/11/12 in http://macscripter.net/viewtopic.php?id=37477
    Nigel Garvey posted a neat answer :
    --{code}
    tell application "Pages"
       delete (paragraphs of front document whose length is 1)
    end tell
    --{code}
    Yvan KOENIG (VALLAURIS, France)  lundi 14 janvier 2011 11:01:29
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • Query to find out last quarter data

    Hi All,
    I need a SQL query to find out. I have an amount field like below
    Period | Amt | Amt2
    ====================
    Jul | 0 | 0+20+30
    Aug | 20 | 0
    Sep | 30 | 0
    Oct | 0 | 0+50
    Nov | 50 |
    My need is Amt2 which needs to calculating in Qtr wise. Can any one post me a query for this.
    Thanks,
    Kamal

    Hi Valli,
    Thanks, so we need to create a function and then call that from report. I have doubt in this, for example if the user enter 'SEP-12' then it will find which QTR from the case statement. But if the user have account number which is available in all the months from 2010 - 2012.
    So now user will give two inputs like period_name='SEP-12' and Account Number=101010 then it should give output like sum(Q3) in the year of 2012. Here how it will calculate year wise? or do we need to specify any condition here?
    Please advice,
    Thanks,
    Kamal

  • Time Machine looking for backup disk/not finding

    Time Machine backed up the HD on my 2009 20" iMac up till Feb. 4 when I downloaded Since then there have been no new backups of my HD and there have been problems wihen I have Time Machine "on" with other applications (TextEdit, Pages, Adobe Bridge CS4) opening or not responding after being open and with Finder not responding. I have also had grey screen freezes multiple times so that I have to use the power button to shut the computer down. When I take TM off of the Automatic backups, most of the problems with applications quitting and the grey screen freezes stop happening. (Although I believe I've had at least one or two grey screen freezes even then.)
    Today I've run Verify Time Machine Backups. It completed that. Then I turned on Automatic Backups again. But then it showed "Looking for Backup Disk". So I selected the Backup Disk. Then I checked back in a while and it still showed Looking for Backup Disk. I removed the selected backup disk, shut down and rebooted, and reselected the backup disk. It is still showing Looking for Backup Disk.
    The Time Machine is a 1 Terabyte size. My iMac is using 203.6 Gigabytes of its 319.21 G space.
    In looking at what my Finder is showing as the name of my Backup Disk, I see that it is showing my Backup Disk as Virginia's Computer (3). It should be showing my Backup Disk as Virginia's Computer. If this is the source of the problem, how do I get my Backup Disk named back to Virginia's Computer? Is it possible to get it changed back?
    My TM is used as a router for two iMacs and up through Feb. 4 I was sharing files between both computers. When the problems started, I turned off File Sharing in the other computer (Jim's iMac). I had noticed that frequently my computer's name as shown on the other computer would be changed to Virginia's Computer (2) or Virginia's Computer (3) and I would change it back when I noticed. Perhaps this is how the problem started.

    I finally contacted Apple Support. Three support people and seven and a half hours later Time Machine began working correctly. Multiple things were tried. The Time Capsule ended up getting erased. Many files and folders were deleted from several places on my hard drive. It seemed that the final ones that made a difference after the Time Capsule was erased were files that were in my Keychain.
    I have to thank Apple's Support people for persistence, especially Jim who is the one who got things back to normal as far as the Time Capsule & Time Machine goes. I have to keep watch to see if anything acts up now on my hard drive and then the solution will go further. But the issue with the Time Capsule and Time Machine appears to be resolved!
    Thank you, Apple Support!!!

  • HT4528 Looking for an iPhone without find my iphone on

    Is there any way I can track my iphone if I dont have find my iphone or icloud on? Is there any way I can turn icloud on on the device even though i dont have it on me?

    Sorry, other than physically looking for your phone, there is no way to locate it.

  • Sql query to find out last update of 6 hours

    i have table emp . for Exp.
    create table emp
    (empno number(5),
    ename varchar2(20),
    last_update date );
    Now i want the all data which is update in last 6 hours

    Assuming an INDEX, WHERE Last_Update > SysDate - 6/24; is better and clearer.
    It is better because it allows INDEX use. That is because it does not manipulate the COLUMN value.
    It is clearer because it clearly states what we want, the records where Last_Update is after a value of six hours before. In the other query, we are checking for records where Last_Updated minus six hours is after current time. Personally, I find that harder to follow.
    SQL> CREATE TABLE Emp(EmpNo NUMBER(5), EName VARCHAR(20), Last_Update DATE);
    Table created.
    SQL> CREATE INDEX Emp_Last_Update ON Emp(Last_Update);
    Index created.
    SQL> INSERT INTO Emp(Empno, EName, Last_Update) SELECT 626, 'user626892', SysDate - Level FROM Dual CONNECT BY Level <= 10000;
    10000 rows created.
    SQL> exec DBMS_STATS.Gather_Schema_Stats(NULL);
    PL/SQL procedure successfully completed.
    SQL> EXPLAIN PLAN FOR SELECT * FROM Emp WHERE SysDate - Last_Update <= 6/24;
    Explained.
    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3956160932
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |   500 | 11500 |    15  (14)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |   500 | 11500 |    15  (14)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter(SYSDATE@!-"LAST_UPDATE"<=.25)
    13 rows selected.
    SQL> EXPLAIN PLAN FOR SELECT * FROM Emp WHERE Last_Update > SysDate - 6/24;
    Explained.
    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT
    Plan hash value: 38459689
    | Id  | Operation                   | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |                 |     1 |    23 |     3   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP             |     1 |    23 |     3   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | EMP_LAST_UPDATE |     1 |       |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("LAST_UPDATE">SYSDATE@!-.25)
    14 rows selected.

  • My itunes won't update. It's looking for 10.6.0.40. Last time it tried to update, I downloaded the msi to my desktop and I deleted it within the last six months. Now I can't uninstall or update.

    The last time my iTunes couldn't update. I used support from Itunes and downloaded it my desktop. My mistake. Because without thinking, I deleted it within the last six months from my desktop, without thinking I'd need it later. For the past month I've needed to update my Itunes and it can't find the msi. Now, my Ipad, my kids' ipod touches and my iphone can't update. Especially the ipod touches, iphone and work ipad have already updated to the OS6. And, now they won't work with this outdated iTunes. Help.

    (1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    (2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
    (3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
    (4) In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
    (5) Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • Sql query to find the last word in a sentence (column)

    Hi,
    I have to retrieve the last word in a column containing varchar2(text) values.
    If anyone knows the query for this kindly share with me.

    There's also the option of regular expressions in 10g onwards...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'oracle forums is the best resource for oracle intelligence' as l from dual)
      2  select regexp_replace(l, '[[:print:]]* ([^ ]*)$','\1') as l
      3* from t
    SQL> /
    L
    intelligence
    SQL>

Maybe you are looking for

  • Plant issue during cross company sales orders creation

    Hi experts, When creating sales orders, the system pops up "Maintain plant XX for the sales area   Message no. V1762". I have gone through nearly all the relevant thread in the forum but failed to solve it. Moreover, the plant is just assigned to one

  • ORA-31687 in  expdp

    Getting below error in Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production ORA-31626: job does not exist ORA-31687: error creating worker process  with worker id 1 ORA-31687: error creating worker process  with worker id 1 OR

  • Cancel of PO

    Hi Gurus, Is there anything called :Cancellation of PO? There is T.Code MBST via which we can cancel/reverse GR and other documents. But, if we want to cancel PO and/or P.Reqs  which are created in Production box, what is the way? Thanks, Kumar

  • I want to stop in frame 1

    I want to stop every action on keyframe  1. I have so many movie clip on layer 1 and layer 2 and so on. Now, I want to stop all movie cip.

  • ORA- 00937 & ORA-02063 error

    I run he folliwng SQL: (SELECT my_date, MAX(DECODE(last_retry,1,count(*),0)) AS "1", MAX(DECODE(last_retry,2,count(*),0)) AS "2" FROM retry_state@full GROUP BY my_date) and I get this Error: ORA_00937 not a single group group function ORA-02063 prece