With the help of lag and grade in the same query

Hello

I'm trying to find out the time difference between the memberships peoples, as well as the order in which these memberships are in. So far, I have added in a release status of work on the order, in that the accessions were created, but now want to look at the difference between the dates returned. The SQL, I used is:

SELECT owner_party_id,
mem_number,
support_id,
mem_start_date,
Rank() over (PARTITION BY owner_party_id ORDER BY mem_start_date ASC) MEMBERSHIP_SEQUENCE
OF membership_all
WHERE version_type = "NEWS".
AND owner_party_id IN ('65051', '65051', '65348', '65348', '65607' 65607', 65607')

to get:

"OWNER_PARTY_ID" | "' MEM_NUMBER ' | "' SUPPORT_ID ' | "' MEM_START_DATE ' | "" MEMBERSHIP_SEQUENCE ".
65051 | 318874751 | 8014747 | 1ST MARCH 10 | 1
65051 | 412311060 | 21502883 | 15 AUGUST 12 | 2
65348 | 308672459 | 3526913 | MAY 1, 10. 1
65348 | 409951130 | 20950524 | 18 JUNE 12 | 2
65607 | 315830192 | 7510133 | MAY 17, 10 | 1
65607 | 406448110 | 20024246 | MARCH 16, 12. 2
65607 | 409738130 | 20903556 | JUNE 14, 12. 3

Now I want to calculate the difference between the starting dates of each of the groups owner_party_id, in order to get something like this:

OWNER_PARTY_ID | MEM_NUMBER | SUPPORT_ID | MEM_START_DATE | MEMBERSHIP_SEQUENCE | Diff
65051 | 318874751 | 8014747 | 1st March 10 | 1.
65051 | 412311060 | 21502883 | 15 August 12 | 2. 898
65348 | 308672459 | 3526913 | May 1, 10. 1
65348 | 409951130 | 20950524 | 18 June 12 | 2. 779
65607 | 315830192 | 7510133 | May 17, 10 | 1
65607 | 406448110 | 20024246 | March 16, 12. 2. 669
65607 | 409738130 | 20903556 | June 14, 12. 3. 90

I think I need to use the Lag function, but I'm not sure if it can be linkited looking at the data within a group id of owner of party, that it would be foolish to calculate the difference in dates for the two different owner group ID.

Any advice much appreciated.

Thank you

Published by: 992871 on March 9, 2013 23:34

Maybe NOT TESTED!

SELECT owner_party_id,
       mem_number,
       support_id,
       mem_start_date,
       RANK() OVER (PARTITION BY owner_party_id ORDER BY mem_start_date) MEMBERSHIP_SEQUENCE,
       mem_start_date - LAG(mem_start_date,1) OVER (PARTITION BY owner_party_id ORDER BY mem_start_date) diff
  FROM membership_all
 WHERE version_type = 'CUR'
   AND owner_party_id IN ('65051','65051','65348','65348','65607','65607','65607')

Concerning

Etbin

Tags: Database

Similar Questions

  • Need help to open two images with the same file with different exposures on the screen at the same time in the Photoshop creative cloud (in previous versions we could open two images of the same nef (raw) file and then combine them on the screen with the

    Need help to open two images with the same file with different exposures on the screen at the same time in the Photoshop creative cloud (in previous versions we could open two images of the same nef (raw) file and then combine them on the screen with the move tool. They have become a composite of two layers which could be developed further with the mask tool.

    Hello

    Please go to the preferences > workspace and uncheck the option 'open the document in the tabs '.

    Now you can click on file and choose file > open and open the two images in two different windows which can be arranged side by side.

    Thank you

  • How can I restart firefox with the same tabs and windows?

    How can I restart firefox with the same tabs and windows?

    It is not in the file menu or tools. I get nothing when searching for help. FF still knows how to do it, say to update extensions.

    I know that I can do by saving my session, coming out, reboot and restore the session but is there a single command to do this?

    Thank you. -David

    I have attached a screenshot showing how to select restore automatic session just above the setting of the Home Page where it says "When Firefox starts".

    With this set, you can restart Firefox manually out using the menu-

    • "3-bar" menu button > button "power".
    • (menu bar) File > Exit

    -and then restart Firefox.

    If you want a real reboot with a click of button, you can check something on the Add-ons site: https://addons.mozilla.org/firefox/

  • text messages sent with an email address from a touch ipod duplicated on a second ipod touch using a different email address, but the two ipods are controlled by a parent with the same apple ID and password.

    Text messages sent with an email address from a touch ipod duplicated on a second ipod touch using a different email address, but the two ipods are controlled by a parent with the same apple ID and password.  This has happened recently.  My two girls have used their respective ipods and texting, without their messages of duplication for each of the other ipods for more than a year.  Somehow recently, both addresses seem to be synced with them or something, so that both see each and other messages.  I've recently updated two ipods, iTunes on my computer--not the cloud and added music for two ipods, but has not changed anything by email email settings or message I know.  Help, please!

    Welcome to the Apple community.

    I can't fully follow how you have everything set up, but a glance at the settings > messages > send & receive

  • My I phone was lost a few months a go but I was recivin a subventio of Apple Inc. which is see my phone and I can activat again but not using the phone now then, what can I do about it, but I am now using a moment I phone with the same Apple ID

    My iPhone6 more was lost a few months a go but I received a notice for a while at Apple Inc. that my phone is a must see and I can't activator and again one time, but I'm not one using this phone now, so what can I do on this, but now use an iPhone now with the same Apple ID? If no help on how to use the IMEI of iPhone lost to lock fill?

    I doubt that Apple is you send messages. I suspect it is a pirate who is trying to steal your personal information.

  • I've updated VIA / S3G UniChrome IGP plug-and-play reverse, but the update still no resolution 1600 x 1200 with the exception and others with the same ratio of 4 x 3.

    I've updated VIA / S3G UniChrome IGP plug-and-play reverse, but the update still no resolution 1600 x 1200 with the exception and others with the same ratio of 4 x 3. That did not help.

    Hello

    1. What version of Windows are you using?
    2. What is the brand and model of the computer?

    I suggest to run the patch from the following link and check the status of the issue.

    Hardware devices do not work or are not detected in Windows.

    http://support.Microsoft.com/mats/hardware_device_problems/en-us

    If the problem persists, I suggest you to send us more information to help you better.

  • I am also having the same problem with the same updates. I have Windows XP SP3 and it's updates with the problem.

    I am also having the same problem with the same updates. I have Windows XP SP3 and it's updates with the problem.

    Security Update for Microsoft .NET Framework 2.0 SP2 on Windows Server 2003 and Windows XP x 86 (KB2572073)
    A security update for .NET Framework 2.0 SP2 and 3.5 SP1 on Windows Server 2003 and Windows XP x 86 (KB2518864)
    Security Update for Microsoft .NET Framework 2.0 SP2 on Windows Server 2003 and Windows XP x 86 (KB2633880)

    They all install properly but switches back to windows update to install. It's some kind of loop.

    Hi billy73,

    In addition, if you still have questions, please take a look at the thread similar here with a solution as possible.

    I hope this helps!

  • Mix records with the same name of the internal and external space (clip +)

    Hello

    I have a question regarding the reading of 'File': if having a folder on the inside and external space microsd, both are named "graphics". Is it possible to shuffel these 2 files with the same name? There are also a few other folders I want to be included, so I just couldn't use the "play all" option. I don't want to use replay by id3tag because mines are always screwed up and would be a lot of work to mark all the appropriate files in the.

    Thanks for help

    m.

    I've not played with playlists much.

    If ID3 tags are all screwed up, I would use the MP3tag utility to change the label of the kind in "Charts" on internal and external memory, then you access the kind-> just Charts and play at all.  It is probably not an option if your labels are blank and you don't want to ruin you, but it's really quick & easy to do with MP3tag.

    I think that even Windows Explorer (XP/Vista) can change the field type in the batch (select all 'charts' music files, click right properties, summary (Advanced) tab change the field of its kind in "Charts", OK).  I keep the ID3tags 'good' on my PC, but edit on my player according to the needs.

    Just another idea which is really easy if you're not afraid of screwing the ID3 tags.

  • Files and folders with the same name

    I am trying to unzip some files and folders and it works fine on my computer with Windows XP. However, when you use Windows Vista I can't because there are folders and files with the same name. After an internet search, it seems that the only suggestion is to extract the files in separate folders which then would allow them to keep the same name. The problem is I want what they in the same folder and they need to have the names they have.

    NOTE: I do have two files with the same name in the same folder, I have a folder and a file with the same name. I would have thought that this would be acceptable because they are two things separate, and given that it's great under XP.

    All solutions?

    You are right, if I make a file and a text file with the same name, it works fine. However, when I try to extract the files I need it tells me that there is already a file with the same name as the folder. He goes to tell me to choose a new name but my only options are 'try again', 'jump' or 'Cancel '.

    I think I can understand what the problem is. For some reason when you download the zip file, the computer seems to have added a few files side with any format other than "file." It is those who have the same name as the folders as if they were, and they could not be uncompressed because of this. I have no idea whence they came as they appear from nowhere (compared to my XP). I'm trying now unzip the files separately and exclude the strange s 'file '.

    Thanks for your help though!

  • Service Pack does not have changes to restore it then shuts off and restarts with the same message over and over again.

    Help!  I have an apple mac with windows alongside mac system.  I the have not used for a while and when I logged in the windows system advised me to update to IE 9.  To do this, I had to install Service Pack 2 I did.  He then restarted but cannot install and came up with the following: Service Pack does not have changes to restore it then shuts off and restarts with the same message over and over again.  I don't know what to do to reopen and to reinstall the Service Pack.

    Hello

    This article explains how to troubleshoot problems when you install a service pack for Windows Vista or Windows Server 2008.

    http://support.Microsoft.com/kb/947366

    Use this forum link for all questions related to Windows Vista SP1, Windows Vista SP2 and Windows Server 2008 SP2 below.

    http://social.technet.Microsoft.com/forums/en/itprovistasp/threads

    or repost in the Windows Update forum link below

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_vista-windows_update?page=1&tab=all

  • All with the same name and more many nested directories

    Ideas: when trying to install Window7 it cannot be installed because of a folder and its subfolder had the same name... called a duplicate. There is a process to find duplicates files which takes you back to Vista to correct the problem. However my name of the folder's subfolders 28 user/name/photos/images/pictures etc all with the same name. When you try to delete more are added. There were files, but I moved to them but there is now way to delete the files. Strange but true. Help to install Windows 7, they should be deleted.

    First try to run a disk check. Open the computer and right click on the drive,
    choose Properties, Tools tab, and then under check errors click check now and
    Follow the prompts.
     
    --
    ..
    --
    "cjones5" wrote in message news: 8cecad2e-6e5d-49ef-a6ec-e40324ea19f5...
    > Remember - this is a public forum so never post private information such
    > as numbers of mail or telephone!
    >
    > Ideas: when trying to install Window7 it cannot be installed due to a
    > folder and its subfolder had the same name... called a duplicate. There are
    > a process designed to find duplicate files which takes you back to Vista for
    > correct the problem. However my folder name is
    > subfolders user/name/photos/pictures/images etc. 28 all with the same
    > name. When you try to delete more are added. There were some files but I
    > displaced but there is now to remove the files. Strange but true.
    > Help to install Windows 7, they should be deleted.
    >
    > a.. You have problems with programs
    > b.. Error messages
    > c.. Recent changes to your computer
    > d.. What you have already tried to solve the problem
    >
     
     
  • I currently store my pictures on and an external hard drive.  Lightroom 6 was not able to find the picture momentarily files.  I inserted an external Flash DRIVE after removing the hard drive and the computer renamed the stick with the same drive letter t

    Redesign existing external hard disks and still 6 Lightroom able to find existing photos.

    I currently store my pictures on and an external hard drive.  Lightroom 6 was not able to find the picture momentarily files.  I inserted an external Flash DRIVE after removing the hard drive and the computer renamed the stick with the same drive letter that has been designated by Lightroom to store my photos.  I could go into my Windows 10 and reset the player to the letter that Lightroom has given at the beginning of the external hard drive.   However, I know this can happen again, if I connect any stick USD or another device, while the external hard drive is not connected to my laptop.   I found the information that I can do the new designation of the final drive by choosing a letter it is 1/2 way or higher in the alphabet.   I would like to turn an external hard drive on a strong letter, warns we hope this previous problem.   My question is, if I already have a lot of pictures on this external hardrive with the designation of the current drive, how it becomes a higher letter and have 6 Lightroom recognizes files, now under the new designation of drive letter without having to go to each photo individually and manually force Lightroom 6 find each photo.  It would take more time than I'd like to lose.  Is there a way to get just 6 Lightroom to recognize the new disk designation has changed and is able to find all of the existing files?

    I have read the ADOBE LightRoom 6 manual and seem not to be able to find anything on how to do it.

    Any help would be welcome.

    Thank you!

    So in Windows, you can select a drive like q letter (or any other letter you want only towards the end of the alphabet)

    Then in Lightroom, you can reconnect to the photos on q: the following instructions (see specifically 4 Figure and related text)

    Adobe Lightroom - find moved or missing folders and files

  • How can I download the new update on my Macbook pro when the password is not working? When I connect to the Adobe site with the same user name and password it DOES not work. I don't understand why.

    So I have a macbook pro - and she advised me that I had to update my Adobe flash player. So I go through all the steps and I'm stuck at the last stage, where he asks me my user name and password. I go in there correctly - several times and it does NOT connect. He shakes to show that there's an error. Double check my file AND I go to the Adobe site to connect with the same information. and it works very well.

    WHAT IS THE PROBLEM? Help please.

    Could you please try ComputerName administrator as username and the password as password.

    I hope this works.

    Concerning

    Hervé Khare

  • Help! Need a script to automatically open files with the same name but in another location.

    Good morning friends,

    So for my work, I need a script to open files with the same name but located in a different folder. But since I'm a total noob when it comes to programming, I can't understand how do. That's what I have in mind:

    -J' I manually open an image.

    -The script will look for a file with the same name in another folder that I've specified.

    -The script will then select the channel CMYK of the second file and copy and paste it into the first file.

    -The second file is then closed without saving the changes.

    I have problems with the part where the script searches for a file with the same name as the opened file. I would really appreciate help. Thanks in advance.

    If (app.documents.length > 0) {}

    myDocument var = app.activeDocument;

    var Nomdoc = myDocument.name;

    try {var basename = docName.match (/(.*)-.)} [ ^\.] +$/)[1]}

    catch (e) {var basename = thedoc.name};

    var path = / * path of folder to insert as a string here * / + ' / ' + base name + / * insert file extension, including the period as a string here * /;

    If (queue (path) .exists == true) {var otherDocument = app.open (File (path))};

    };

  • I've uninstalled and reinstalled the drive several times with the same result, my problem is when I download the drive icons for my browsers and above all my desktop icons change adobe logo, so when I click on them Adobe tries to open them.

    I've uninstalled and reinstalled the drive several times with the same result, my problem is when I download the drive icons for my browsers and changing most of my the desktop icons for the adobe logo, so when I click on them Adobe tries to open them, of course, he does not format because it's not an adobe application , so I tried to restore the computer to an earlier date and it wont let me as long as Adobe reader is installed, so I need to uninstall and now I have nothing to open files and downloads of Adobe, someone had this problem and if so, did you get it resolved? Thank you Tommy...

    This may help: Application, file icons change in Acrobat/Reader icon

Maybe you are looking for