Identify the last data package in start routine

Hi Everyone
We have a start routine in transformations. We require to do some special processing in the start routine only when the last data package is executing. How can we determine in the start routine that current package is last one or not ? Any pointers in this direction are appreciated.

Hi,
You can get packet Id from datapackid in start routine and end routine. But I'm not so sure how to identify the last packet ID, alternatively you can store this packet id in some where else and read the same value in End routine if your logic(processing) permits to do this in End routine instead of Start routine.
METHODS
      start_routine
        IMPORTING
          request                  type rsrequest
          datapackid               type rsdatapid
        EXPORTING
          monitor                  type rstr_ty_t_monitors
        CHANGING
          SOURCE_PACKAGE              type tyt_SC_1
        RAISING
          cx_rsrout_abort.
hope it helps...
regards.
Raju

Similar Messages

  • How to set request number of info package using start routine

    Hi All,
    I have a specific requirement in which I need to upload only selective request nos from PSA to DSO.
    Any one can suggest how to set request number of info package using start routine or any other mode so that only selective request should proceed using DTP?
    Thanks
    Sangita

    You'll probably want to do this in a start routine.  It is probably not advisable to hard-code the technical name of the InfoPak.  They seem to remain the same upon transport, unlike DTP technical names which are locally generated.
    I would do a SQL select like this in a start routine, and then filter based on the results of the SQL.  You'll probably want to sort the results by date and time, both descending.  Or do a MAX in the SQL.
    Please let me know if this isn't clear.
    select q~rnr q~logdpid q~tdatum q~tuzeit
    from rsreqdone as q
      inner join rsldpio as p
        on p~logdpid = q~logdpid
    where p~objvers = 'A'
    and p~logdpid like 'ZPAK%'
    and p~source = 'your data source'

  • SD PRICING: How to identify the last call of a Condition Value Formula

    Hello  Experts.
    I'm working on a condition value formula, and because a Group Condition, I need to do a calculation in the last call of the formula. The formula is called 5 times and I couldn't identify any flag to diferentiate the last 3 calls.
    I could use a counter in a static variable per position, but I think there must be another way to identify the last call.
    Thanks in advance and best regards
    Matías

    Hi,
    Define a counter say w_ii type I in your routine.
    Whenever you enter the routine  use 'IMPORT' to get the last value of w_ii. If sy-subrc ne 0 its first time so increment the counter w_ii = w_ii + 1 & 'EXPORT' it. If sy-subrc = 0 check the value of w_ii to decide if it's the last time.If yes do whatever you want to do
    else increment w_ii i.e. w_ii = w_ii + 1 & 'EXPORT' it which in turn will be used during next 'IMPORT'.
    I hope this helps,
    Regards
    Raju chitale

  • How to update the last date into DSO?

    Hi,all,
    When I do  grouping in a transformation from DSO1 to another DSO2 ,which means I will make three(for example) records from dso1 into one record in dso2 by using a higher level key in DSO2. I will sum the keyfigure quantity of DSO1, but using the last date of the field posting date in DSO1 to update DSO2. I could write a routing to achieve this.
    But the question is, how can I make sure the three records are in one datapackge to through my routing?since the packages are excute in transformation one by one? If not,how can I update for the field of last date? And since I use sum to keyfigure,the sematic groups function in DTP can not be used.
    I'm very anxious about it.Hope someone could help me.Thank you.

    hi,darshak,
    Could you explain a little bit more? I'm still not clear enough how to do that.
    Thank you for your reply.

  • Get the first and the last date of a week

    Hi all
    I need to get the first and the last date of a specific week.
    I need a function that returns two date passing it just one date.
    The function has to calculate the first and the last date of the week of the argument date.
    hope to be clear
    regards

    goiters,
    I need to get the first and the last date of a specific week.Yup, and what's the first day of the week in your part of the world, is it Sunday or Monday?
    I need a function that returns two date passing it just one date.No you don't, just add 7 days to the start of the week.
    hope to be clearWell, you can hope.
    Keith.
    Message was edited by: corlettk - now I hope to clear ;-)

  • I am using OS 10.7.5.  During the last week, it has started running very slow.Any ideas?, I am using OS 10.7.5.  During the last week, it has started running very slow.Any ideas?

    I am using Mac OS 10.7.5.  During the last week, it has started running very slow.  Any thoughts?

    Things You Can Do To Resolve Slow Downs
    If your computer seems to be running slower here are some things you can do:
    Start with visits to:     OS X Maintenance - MacAttorney;
                                      The X Lab: The X-FAQs;
                                      The Safe Mac » Mac Performance Guide;
                                      The Safe Mac » The myth of the dirty Mac;
                                      Mac maintenance Quick Assist.
    Boot into Safe Mode then repair your hard drive and permissions:
    Repair the Hard Drive and Permissions Pre-Lion
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    Repair the Hard Drive - Lion/Mountain Lion/Mavericks
    Boot to the Recovery HD:
    Restart the computer and after the chime press and hold down the COMMAND and R keys until the Utilites Menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD disk icon and click on the arrow button below.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported, then click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu. Select Restart from the Apple menu.
    Restart your computer normally and see if this has helped any. Next do some maintenance:
    For situations Disk Utility cannot handle the best third-party utility is Disk Warrior;  DW only fixes problems with the disk directory, but most disk problems are caused by directory corruption; Disk Warrior 4.x is now Intel Mac compatible.
    Note: Alsoft ships DW on a bootable DVD that will startup Macs running Snow Leopard or earlier. It cannot start Macs that came with Lion or later pre-installed, however, DW will work on those models.
    Suggestions for OS X Maintenance
    OS X performs certain maintenance functions that are scheduled to occur on a daily, weekly, or monthly period. The maintenance scripts run in the early AM only if the computer is turned on 24/7 (no sleep.) If this isn't the case, then an excellent solution is to download and install a shareware utility such as Macaroni, JAW PseudoAnacron, or Anacron that will automate the maintenance activity regardless of whether the computer is turned off or asleep.  Dependence upon third-party utilities to run the periodic maintenance scripts was significantly reduced since Tiger.  These utilities have limited or no functionality with Snow Leopard or later and should not be installed.
    OS X automatically defragments files less than 20 MBs in size, so unless you have a disk full of very large files there's little need for defragmenting the hard drive.
    Helpful Links Regarding Malware Protection
    An excellent link to read is Tom Reed's Mac Malware Guide.
    Also, visit The XLab FAQs and read Detecting and avoiding malware and spyware.
    See these Apple articles:
              Mac OS X Snow Leopard and malware detection
              OS X Lion- Protect your Mac from malware
              OS X Mountain Lion- Protect your Mac from malware
              About file quarantine in OS X
    If you require anti-virus protection I recommend using VirusBarrier Express 1.1.6 or Dr.Web Light both from the App Store. They're both free, and since they're from the App Store, they won't destabilize the system. (Thank you to Thomas Reed for these recommendations.)
    Troubleshooting Applications
    I recommend downloading a utility such as TinkerTool System, OnyX, Mavericks Cache Cleaner, or Cocktail that you can use for removing old log files and archives, clearing caches, etc. Corrupted cache, log, or temporary files can cause application or OS X crashes as well as kernel panics.
    If you have Snow Leopard or Leopard, then for similar repairs install the freeware utility Applejack.  If you cannot start up in OS X, you may be able to start in single-user mode from which you can run Applejack to do a whole set of repair and maintenance routines from the command line.  Note that AppleJack 1.5 is required for Leopard. AppleJack 1.6 is compatible with Snow Leopard. Applejack does not work with Lion and later.
    Basic Backup
    For some people Time Machine will be more than adequate. Time Machine is part of OS X. There are two components:
    1. A Time Machine preferences panel as part of System Preferences;
    2. A Time Machine application located in the Applications folder. It is
        used to manage backups and to restore backups. Time Machine
        requires a backup drive that is at least twice the capacity of the
        drive being backed up.
    Alternatively, get an external drive at least equal in size to the internal hard drive and make (and maintain) a bootable clone/backup. You can make a bootable clone using the Restore option of Disk Utility. You can also make and maintain clones with good backup software. My personal recommendations are (order is not significant):
      1. Carbon Copy Cloner
      2. Get Backup
      3. Deja Vu
      4. SuperDuper!
      5. Synk Pro
      6. Tri-Backup
    Visit The XLab FAQs and read the FAQ on backup and restore.  Also read How to Back Up and Restore Your Files. For help with using Time Machine visit Pondini's Time Machine FAQ for help with all things Time Machine.
    Referenced software can be found at MacUpdate.
    Additional Hints
    Be sure you have an adequate amount of RAM installed for the number of applications you run concurrently. Be sure you leave a minimum of 10% of the hard drive's capacity as free space.
    Add more RAM. If your computer has less than 2 GBs of RAM and you are using OS X Leopard or later, then you can do with more RAM. Snow Leopard and Lion work much better with 4 GBs of RAM than their system minimums. The more concurrent applications you tend to use the more RAM you should have.
    Always maintain at least 15 GBs or 10% of your hard drive's capacity as free space, whichever is greater. OS X is frequently accessing your hard drive, so providing adequate free space will keep things from slowing down.
    Check for applications that may be hogging the CPU:
    Pre-Mavericks
    Open Activity Monitor in the Utilities folder.  Select All Processes from the Processes dropdown menu.  Click twice on the CPU% column header to display in descending order.  If you find a process using a large amount of CPU time (>=70,) then select the process and click on the Quit icon in the toolbar.  Click on the Force Quit button to kill the process.  See if that helps.  Be sure to note the name of the runaway process so you can track down the cause of the problem.
    Mavericks and later
    Open Activity Monitor in the Utilities folder.  Select All Processes from the View menu.  Click on the CPU tab in the toolbar. Click twice on the CPU% column header to display in descending order.  If you find a process using a large amount of CPU time (>=70,) then select the process and click on the Quit icon in the toolbar.  Click on the Force Quit button to kill the process.  See if that helps.  Be sure to note the name of the runaway process so you can track down the cause of the problem.
    Often this problem occurs because of a corrupted cache or preferences file or an attempt to write to a corrupted log file.

  • Itunes it's not showing me the last date/time the iPhone/iPad was backed up.

    I just backed up my iPhone and iPad but  iTunes it's not showing me the last date/time my device was backed up. I had just done a backup about 3 hours ago. And when I go to check the backup location I see a folder there with the time it was last backed up. But it's not showing me the backup date in iTunes. I don't know what to do.
    I already tried to remove the folder in App. Support-Mobile Sync and start a brand new backup. But no date.
    Tried to delete and start a new iTunes folder in Music but nothing has changed
    Any solution is welcome!

    iCloud requires OS X Lion (10.7.2) or higher.  You will need to upgrade to either Lion higher in order to set up iCloud on your Mac.  First check to see if your system meets the system requirements to upgrade.
    Lion system requirements are:
    Mac computer with an Intel Core 2 Duo, Core i3, Core i5, Core i7, or Xeon processor
    2GB of memory
    OS X v10.6.6 or later (v10.6.8 recommended)
    7GB of available space
    Mountain Lion requirements are shown here: http://support.apple.com/kb/HT5444.
    Mavericks requirements are shown here: http://support.apple.com/kb/HT5842.
    If you can run Mavericks, you can purchase an upgrade from the Mac App Store.  If you can only run Lion or Mountain Lion, contact the online store in your country and purchase a redemption code to download it from the Mac App Store.
    After upgrading, you will find iCloud in System Preferences>iCloud on your Mac, and can set it up as explained here: http://www.apple.com/icloud/setup/mac.html.
    Before upgrading, you may want to check the compatibility of your existing programs by checking here: http://roaringapps.com/apps:table.

  • How to get the last data point from a TDM file in LabVIEW?

    Hello,
    I am using LabVIEW to analyze some rather large TDM files, and I need a way to get only the last data point.  So far, the only way I have been able to accomplish this is by reading the entire file.  Is there a property in the TDM file or a function in LabVIEW that will allow me to get the index of the last item in a channel?  
    Thanks!
    Christina

    Do you want to avoid reading whole file and want to be able to reach or get the index of last value of channel? is there any specific reason? I am not sure you could do it without loading the whole file. But the easiest way would be just to use array functions "array size" would give you the index of last element. 
    -Nilesh
    Kudos are (always) welcome for the good post. :-)

  • Is there any way to tell the last date my ipod was plugged into my computer?

    OKay, this may be a techie question, but I'm pretty savvy so if this info is contained in a file somewhere, you can feel free to explain how to find it, I can look for it.
    i Misplaced my iPod nano at some point in time, and knowing the last date I synced it to iTunes or even plugged it in would be HUGELY helpful in helping me to maybe locate it.  IS there any way to see this information (the date specifically) anywhere on my computer dated in any file?
    I Did look at devices and the iPod wasn't listed there, (only my more recent iPad and iPhone as backups) so I'm assuming maybe this wasnt an option in earlier versions of iTunes at least when I last had that sucker plugged in.
    IIt's Moreso just killing me that I can't find it, and I KNOW it's one of a few places.
    ANy help is great!
    thanks!
    ROb

    Go here for instructions.
    iFixit: The free repair manual
    If your iPod got wet, put the whole iPod in a bag/container of rice and see it and leave it for days.
    How to fix a wet iPod or iPhone | eHow.com

  • Query to find the difference between the last date and the second to the last date

    Hi all,
    Hope all is well.
    I am working on the following problem because I am trying to improve my MS SQL skills. But I am stuck at the moment and I wonder if you could provide some assistance please. Here is the issue:
    Table 1: Dividends
    divId
    ExDate
    RecordDate
    PayDate
    Amount
    Yield
    symId
    1
    2013-02-19
    2013-02-21
    2013-03-14
    0.23
    0.00000
    3930
    2
    2012-11-13
    2012-11-15
    2012-12-13
    0.23
    0.00849
    3930
    3
    2012-08-14
    2012-08-16
    2012-09-13
    0.20
    0.00664
    3930
    4
    2012-05-15
    2012-05-17
    2012-06-14
    0.20
    0.00662
    3930
    5
    2012-02-14
    2012-02-16
    2012-03-08
    0.20
    0.00661
    3930
    6
    2011-11-15
    2011-11-17
    2011-12-08
    0.20
    0.00748
    3930
    7
    2011-08-16
    2011-08-18
    2011-09-08
    0.16
    0.00631
    3930
    8
    2011-05-17
    2011-05-19
    2011-06-09
    0.16
    0.00653
    3930
    9
    2011-02-15
    2011-02-17
    2011-03-10
    0.16
    0.00594
    3930
    10
    2010-11-16
    2010-11-18
    2010-12-09
    0.16
    0.00620
    3930
    11
    2010-08-17
    2010-08-19
    2010-09-09
    0.13
    0.00526
    3930
    12
    2010-05-18
    2010-05-20
    2010-06-10
    0.13
    0.00455
    3930
    13
    2010-02-16
    2010-02-18
    2010-03-11
    0.13
    0.00459
    3930
    Table 2: Tickers
    symId
    Symbol
    Name
    Sector
    Industry
    1
    A
    Agilent Technologies Inc.
    Technology
    Scientific & Technical Instruments
    2
    AA
    Alcoa, Inc.
    Basic Materials
    Aluminum
    3
    AACC
    Asset Acceptance Capital Corp.
    Financial
    Credit Services
    4
    AADR
    WCM/BNY Mellon Focused Growth ADR ETF
    Financial
    Exchange Traded Fund
    5
    AAIT
    iShares MSCI AC Asia Information Tech
    Financial
    Exchange Traded Fund
    6
    AAME
    Atlantic American Corp.
    Financial
    Life Insurance
    7
    AAN
    Aaron's, Inc.
    Services
    Rental & Leasing Services
    8
    AAON
    AAON Inc.
    Industrial Goods
    General Building Materials
    9
    AAP
    Advance Auto Parts Inc.
    Services
    Auto Parts Stores
    10
    AAPL
    Apple Inc.
    Technology
    Personal Computers
    11
    AAT
    American Assets Trust, Inc.
    Financial
    REIT - Office
    12
    AAU
    Almaden Minerals Ltd.
    Basic Materials
    Industrial Metals & Minerals
    I am trying to check the last date (i.e. max date) and also check the penultimate date (i.e. the second to the last date).  And then find the difference between the two (i.e. last date minus penultimate
    date).
    I would like to do that for each of the companies listed in Table 2: Tickers.  I am able to do it for just one company (MSFT) using the queries below:
    SELECT
    [First] = MIN(ExDate),
    [Last] = MAX(ExDate),
    [Diff] = DATEDIFF(DAY, MIN(ExDate), MAX(ExDate))
    FROM (
    SELECT TOP 2 Dividends.ExDate
    FROM Dividends, Tickers
    WHERE Dividends.symId=Tickers.symId
    AND Tickers.Symbol='MSFT'
    ORDER BY ExDate DESC
    ) AS X
    Outputs the following result:
    First
    Last
    Diff
    2012-11-13
    2013-02-19
    98
    But what I would like instead is to be able to output something like this:
    Symbol
    First
    Last
    Diff
    MSFT
    2012-11-13
    2013-02-19
    98
    AAN
    2012-11-13
    2012-12-14
    1
    X
    2012-11-13
    2012-12-14
    1
    Can anyone please let me know what do I need to add on my query in order to achieve the desired output?
    Any help would be greatly appreciated.
    Thanks in advance. 

    Could you try this?
    create table Ticker (SymbolId int identity primary key, Symbol varchar(4))
    insert into Ticker (Symbol) values ('MSFT'), ('ORCL'), ('GOOG')
    create table Dividend (DividendId int identity, SymbolId int constraint FK_Dividend foreign key references Ticker(SymbolId), ExDate datetime, Amount decimal(18,4))
    insert into Dividend (SymbolId, ExDate, Amount) values
    (1, '2012-10-1', 10),
    (1, '2012-10-3', 1),
    (1, '2012-10-7', 7),
    (1, '2012-10-12', 2),
    (1, '2012-10-23', 8),
    (1, '2012-10-30', 5),
    (2, '2012-10-1', 10),
    (2, '2012-10-6', 1),
    (2, '2012-10-29', 7),
    (3, '2012-10-1', 22),
    (3, '2012-10-3', 21),
    (3, '2012-10-7', 3),
    (3, '2012-10-12', 9)
    WITH cte
    AS (SELECT t.Symbol,
    d.ExDate,
    d.Amount,
    ROW_NUMBER()
    OVER (
    partition BY Symbol
    ORDER BY ExDate DESC) AS rownum
    FROM Ticker AS t
    INNER JOIN Dividend AS d
    ON t.SymbolId = d.SymbolId),
    ctedate
    AS (SELECT Symbol,
    [1] AS maxdate,
    [2] AS penultimatedate
    FROM cte
    PIVOT( MIN(ExDate)
    FOR RowNum IN ([1],
    [2]) ) AS pvtquery),
    cteamount
    AS (SELECT Symbol,
    [1] AS maxdateamount,
    [2] AS penultimatedateamount
    FROM cte
    PIVOT( MIN(Amount)
    FOR RowNum IN ([1],
    [2]) ) AS pvtquery)
    SELECT d.Symbol,
    MIN(MaxDate) AS maxdate,
    MIN(penultimatedate) AS penultimatedate,
    DATEDIFF(d, MIN(penultimatedate), MIN(MaxDate)) AS numberofdays,
    MIN(MaxDateAmount) AS maxdateamount,
    MIN(penultimatedateAmount) AS penultimatedateamount,
    MIN(MaxDateAmount) - MIN(penultimatedateAmount) AS delta
    FROM ctedate AS d
    INNER JOIN cteamount AS a
    ON d.Symbol = a.symbol
    GROUP BY d.Symbol
    ORDER BY d.Symbol
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers.
    Thanks!
    Aalam | Blog (http://aalamrangi.wordpress.com)

  • How to find out the last date & time on which a program has been run

    Hi Experts,
    Can anybody tell how to find out the last date on which a purticular program has been run.
    Valuable answers will be rewarded.
    Thanks & Regards,
    Satish.

    Hi!
    Try STAD transaction. Unfortunately it contains a huge amount of data, so it is available only for a few days backwards... Maybe some weeks, but you can't make yearly reports from its data... So it's not useful to see, which program is in use or not...
    I planned once to download it weekly, but it was not so important...
    Regards
    Tamá

  • Min,Max for a time Range and Sum of Records for the last date/time

    Hi All,
    I have a table with the following structure/data:
    create table  Events   (
                                        [EventID]       
    int                   NOT NULL,
                                        [Title]            
    nvarchar(200)  NOT NULL,
                                        [SourceName]  nvarchar(20)    NOT NULL,
                                        [Type]             
    int                  NOT NULL,
                                        [eDate]           
    datetime
    insert into Events values(100, 'Event 1', 'S01', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S07', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S08', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S09', 3,'2014-01-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S010', 3,'2014-01-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S03', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S04', 3,'2014-01-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S05', 3,'2014-01-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S06', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S01', 3,'2014-02-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S02', 3,'2014-02-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S03', 3,'2014-02-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S04', 3,'2014-02-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S05', 3,'2014-02-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S06', 3,'2014-02-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S01', 3,'2014-03-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S02', 3,'2014-03-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S03', 3,'2014-03-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S04', 3,'2014-03-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S05', 3,'2014-03-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S06', 3,'2014-03-01 00:00:00.000')
    And I wrote the following query:
     select EventID as [Event ID],
           Title, 
           count(distinct(SourceName)) as [Instances], 
           Type,
           min(eDate) as  [First Detected],
           max(eDate) as [Last Detected],
           datediff(d,min(eDate),max(eDate)) as [Delta (days)]
    from  Events
    where type = 3
    group by EventID, Title, Type
    having max(eDate) <> min(eDate)
       and max(eDate) =(select top 1 eDate from Events order by eDate desc)
    and I get the following results (see the instance number)
    Event ID Title         Instances Type First Detected                      Last Detected                    
       Delta (days)
    =============================================================================================================================
    100         Event 1         5         3    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000    
    59
    101         Event 2        
    3         3    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000     59
    102         Event 3        
    2         3    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000     59
    This is normal for this query however what I need to do is a little different.
    In other words, while I need to show when we recorded a specific event first and last time,
    I need to display the results for the last date/time when it was recorded. 
    For example what I need to provide should look like this:
    Event ID  Title                Instances        Type       First Detected                    
    Last Detected                          Delta (days)
    =============================================================================================================================
    100         Event 1            2                   3           
    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000      59
    101         Event 2            2                   3           
    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000      59
    102         Event 3           
    2                   3            2014-01-01 00:00:00.000     2014-03-01 00:00:00.000     
    59
    Could you please help me to fix this query?
    TIA,
    John

    ;With cte As
    (Select EventID as [Event ID],
    Title,
    SourceName,
    Type,
    min(eDate) Over(Partition By EventID, Title, Type) as [First Detected],
    max(eDate) Over(Partition By EventID, Title, Type) as [Last Detected],
    eDate,
    datediff(d,min(eDate) Over(Partition By EventID, Title, Type),max(eDate) Over(Partition By EventID, Title, Type)) as [Delta (days)],
    max(eDate) Over() As MaxEDate
    from Events
    where type = 3)
    Select [Event ID],
    Title,
    COUNT(Distinct SourceName) As Instances,
    Type,
    [First Detected],
    [Last Detected],
    [Delta (days)]
    From cte
    Where eDate = MaxEDate And [First Detected] <> [Last Detected]
    Group By [Event ID],
    Title,
    Type,
    [First Detected],
    [Last Detected],
    [Delta (days)];
    Tom
    P.S. Thanks for providing the DDL and data.  That is always very helpful.

  • How to get the last date of that month after adding the two month.

    Hi,
    I have a requirement, My input is month/lastdate of the month/year after adding 2 months i want the same format mont+2/lastdate of the month/year.
    Please let me know the exact FM for this.
    I have check this FM RE_ADD_MONTH_TO_DATE.
    Input:                                           
    Import parameters               Value    
    MONTHS                          02       
    OLDDATE                         02/29/2008
    Output:                                           
    Export parameters               Value     
    NEWDATE                         04/29/2008
    But this wrong because i am expecting the last date of the April.
    2) I have checked another FM that also also shows the wrong output: RP_CALC_DATE_IN_INTERVAL                                                
      Import parameters               Value         
      DATE                            12/31/2008    
      DAYS                            00            
      MONTHS                          02            
      SIGNUM                          +             
      YEARS                           00                                                                               
    Export parameters               Value         
      CALC_DATE                       03/01/2009    
    Thanks In avance,
    Thanks & Regards,
    Venkata

    Hi,
    do the RE_ADD_MONTH_TO_DATE then
    Plug the result date into FM RP_LAST_DAY_OF_MONTHS
    Regards
    Stu

  • How do you restore the "Last Date Played" notice in the iTunes window for songs?

    How do you restore the "Last Date Played" note in the iTunes window of playlists?  I lost this a couple of weeks ago, and had someone explain the steps to take (which are not on the iTunes "Help" menu).  Thanks.

    In the playlist, Right Mouse click on the column headers and it will give you a list to choose from in the pop up select Last Played and that column will display

  • HOW DO I SEE THE LAST DATE I BACKED UP ON ICLOUD

    How can I see the last date that icloud was backed up?

    Go to Settings>iCloud>Storage & Backup and look at the very bottom under Back Up Now.

Maybe you are looking for

  • Can't install OSX after I installed new hard drive

    Okay so my 2009 MacBook pro would not start up, took it to the genius bar and they said I need a new hard drive. I installed a Western Digital blue Scorpio one from Best Buy and now when I turn on the computer I just get a flashing folder with a ques

  • Can't backup library

    When I go to backup my itunes library, it starts off working fine, I put in my DVD-R or DVD+R and it tells me I need more than one disc and tells me how many discs I need. It then proceeds to write to the first DVD. The problem occurs when the first

  • Is there  a way to view photos on a calendar

    from the date i originaly took the photo?I just downloaded a cf card and it seems to have bunched all the photos onyo one date?I previously used adobe photo and this program automaticaly did this feature.thanks

  • Email is to wide for screen

    Emails come in and I have t o use the bottom arrow to see it all. It almost doubles.

  • Loss of detail with cut-outs

    We have just started using an external company to do our cut-outs and we have found for example with complicated hair images, that when we place the 300 dpi images on to a page in indesign and then make the pdf a considerable amount of hair detail is