Schtasks query

Hi,
We are using "schtasks.exe /Query /FO LIST /v > C:\scheduled_tasks.csv" command to export the Scheduled tasks to a CSV file. Then we use this CSV file to read some of the values.
Issue:
If Windows OS is in Japanese then schtasks command will export the scheduled task details to CSV file in Japanese language. 
In Japanese environment, is it possible to export the scheduled task details to CSV file in English instead of Japanese language. If not then, is there any other way to get the Schudeled tasks details in English where windows OS is in Japanese.
Any help is highly appreciated.

You can use the
API provided for the Task Scheduler directly to retrieve scheduled task information.  For things that are entered as language-specific strings, it won't translate to English from Japanese, but there's far more information not in string form than is
in string form; it ultimately depends on what you want to retrieve, but that API will probably work for you.
WinSDK Support Team Blog: http://blogs.msdn.com/b/winsdk/

Similar Messages

  • DOS Command Schtasks - error

    Hello,
    I am locally executing a batch file which contains the following:
    SchTasks /query /fo csv > C:\AllReports\Schedtask.txt /v /s AppServer.xyz.org
    I do get the ouptut file along with the requested info but I also get the following:
    ERROR: The task XML contains a value which is incorrectly formatted or out of range
    ERROR: Task cannot be loaded: UpsizeToSQL - Special Run - is the first line withing the output file. Subsequent lines show actual Schtasks results
    Appserver.xyz.org is a remote server I am able to access to using my network credentials. I am able to run Schtasks from the command line without issues and get a results clean of error messages. The issue appears when I execute the batch file from my local
    machine to retrieve tasks on that remote server.
    Any help to find a solution would be much appreciated.
    Thank you.

    Hello,
    I locally executing a batch file which contains the following:
    SchTasks /query /fo csv > C:\AllReports\Schedtask.txt /v /s AppServer.xyz.org
    I do get the ouptut file along with the requested info but I also get the following:
    ERROR: The task XML contains a value which is incorrectly formatted or out of range
    ERROR: Task cannot be loaded: UpsizeToSQL - Special Run - is the first line withing the output file. Subsequent lines show actual Schtasks results
    Appserver.xyz.org is a remote server I am able to access to using my network credentials. I am able to run Schtasks from the command line without issues and get a results clean of error messages. The issue appears when I execute the batch file from my local
    machine to retrieve tasks on that remote server.
    Any help to find a solution would be much appreciated.
    Thank you.
    Hi,
    Since this issue is mainly related to Dos Commands, I would recommend you refer to the following thread to get where to get supports for this issue.
    Where is the Forum for DOS Commands
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Need to delete Scheduled Tasks automatically using a script or schtasks.exe, but it is NOT allowing it - PLEASE HELP!

    I have tried and tried to get this to work in a script, but it simply is NOT doing what I need. I am simply trying to run
    schtasks /delete /tn <task name> /f
    but when I do, I receive the following ANNOYING ERROR:
    ERROR: The system cannot find the file specified.
    I am looking right at the task in the Task Scheduler utility, so I know it EXIST!!
    Then, when I run a "schtasks /query" I see that the task I want to delete has the following information:
    INFO: There are no scheduled tasks presently available at your access level.
    I can delete the tasks just fine in the Task Scheduler console, but I NEED this to be automated so these tasks can be deleted on multiple systems. 
    Can someone PLEASE help me out with this. The systems I need this to run on our Windows 7 SP1. 
    Thank you

    Listen up dude, I am not a home user I am a professional and this same issue is spread all over the internet with most professionals scratching their head not understanding why it is not working.
    However, I found the answer here:
    http://www.jonathankeller.com/2012/02/schtasks-query-tn-tasks-over-network.html
    So you see "dude" even your link shows that you were not a professional as any professional would have read the help first.  Your post give no information as to what you are doing and assumes that a system utility is a script which nearly
    all professionals agree that system utilities are not scripts.
    From the question and the very arrogant response it is clear you are a home user with no formal technical training....or are you theoffice manager who was stuck with doing these things for your boss?
    Your "handle" is also very unprofessional and telling about your "I AM Sir Ask A lot".  Try studying the technical information about Windows.  Learn to start with the system help.  It will save you a lot of blood pressure
    excursions.
    Also note that the help is explicit.  Use the folder path syntax returned from /Query and not the one you see in the GUI.  Again - learning to use help first would save a lot of headaches.
    Stick with it kid.  When you get to by half my age you might be able to call yourself a "professional".  Until then - hit the books.
    ¯\_(ツ)_/¯

  • Want to reserve Windows 10 but don't see the icon on the taskbar possible solution

    One of my laptops did not show the get windows 10 in the taskbar and the required microsoft update KB3035583 was installed, this article gave the solution by running CMD as administrator and the command to run also how to save it on your computer.Article is found here - http://answers.microsoft.com/en-us/windows/forum/windows_10-win_upgrade/i-want-to-reserve-my-free-copy-of-windows-10-but-i/848b5cce-958b-49ae-a132-a999a883265b?auth=1 From the article:  1. Open Notepad 2. Copy the following text and paste it into Notepad: REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\UpgradeExperienceIndicators" /v UpgEx | findstr UpgExif "%errorlevel%" == "0" GOTO RunGWXreg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Appraiser" /v UtcOnetimeSend /t REG_DWORD /d 1 /fschtasks /run /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" :CompatCheckRunningschtasks /query /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser"schtasks /query /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" | findstr Readyif NOT "%errorlevel%" == "0" ping localhost >nul &goto :CompatCheckRunning:RunGWXschtasks /run /TN "\Microsoft\Windows\Setup\gwx\refreshgwxconfig" Click File, and then Save AsIn the File name box, change the file name to ReserveWin10.cmdThen click the dropdown next to Save as type, and select All files (*.*)Select the folder you would like to save the file to.  For this example, let’s choose to save the file to the C:/Temp folder.  Then click Save.  Open an elevated command prompt.  (From the Start screen or Start menu, type Command Prompt in the search box, and then in the list of results, right-click Command Prompt, and select Run as administrator.)Finally, run the file from the location you saved to in Step 6.  In this example, you would type the following in the Command Prompt window and hit Enter:C:/Temp/ReserveWin10.cmdThe Microsoft Compatibility Appraiser can take 10 – 30 minutes to run, during which the script will continuously provide status reports that it is running.  Please be patient. After this ran I had the get Windows 10 in the taskbar. 

    Look on the Launchpad icon in your Dock. Or switch over to the Purchases side in App Store. If it's downloading it will take a while since Mountain Lion is over 4 GBs.

  • Unacceptable behavior from software protection service

    I was using computer with windows 8.1 and everything shuts down and reboots.  I look at system logs and it states System unexpectedly shut down. Also Computer was improperly shut down.  I go to application and find entry Successfully scheduled
    Software Protection service for restart at 2114-06-12T18:34:09Z.  Reason Rules Engine. If user has administrative rights there should be override of this since it did not show an error state.  Are they trying to make the OS less and Less useful?
    I have a temperature sensor running and cpu was 60 degrees below max temperature.
    PS last update broke my combo plug headset.  System has forgotten how to set the single combo plug for input and output.  I have a feeling it involves RealTek drivers again. It also affected Intel audio too.

    Hi,
    Many reasons could caused the computer shutdown expectedly.
    Was this behavior regular?
    Please check if there any schedule task is configured to carry out this operation.
    Run this command:
    schtasks /query /v /fo LIST
    If there is no clue, perform a Clean Boot to see if there is any third-party software conflicts.
    How to perform a clean boot in Windows
    http://support.microsoft.com/kb/929135
    Karen Hu
    TechNet Community Support

  • Execute batch file

    Hello,
    I have a simple and short batch file I am trying to execute from SQL server. The SQL database I am connected to is my local instance. The script I am using is as below:
    EXECUTE [master].[dbo].[xp_cmdshell] 'C:\Users\Jdoe\Desktop\Test.bat'
    The batch file is located at the path listed above and contains the below:
    SchTasks /query /fo csv > I:\Schedtask.txt /v /s reports.xyz.org
    The above command line code connects to a remote machine and gets the list of all scheduled tasks. Please note that executing the batch file by double-clicking on the icon works without issues. When I try however to run the SQL listed above, I get the below:
    output
    NULL
    C:\Windows\system32>SchTasks /query /fo csv /v /s reports.xyz.org 1>I:\Schedtask.txt
    The system cannot find the path specified.
    NULL
    What am I doing wrong. I am expecting the SQL to execute de batch file which should create a output file at the specified location but it doesn't.
    Thanks for helping

    Try to use UNC path (\\server\share\file_path). Also make sure that the doamain account used as task owner has the proper rights on the source and destination
    Javier Villegas |
    @javier_vill | http://sql-javier-villegas.blogspot.com/
    Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you

  • Export-CSV Not working for a user

    Hi Guys,
    Here's a good one for you. I have a client who is trying to run the script Get-ScheduledTasks.ps1 with the option to export-csv. So he's running .\get-scheduledTask.ps1 | Export-CSV C:\schedtask\schedtask.csv The script runs just fine but doesn't output
    to the csv it just displays the output in the ISE console window. It does this if he's logged onto his laptop, the server itself, as him or as another local account.
    Here's the weird thing I can run the script just fine on both my laptop, and the server, logged on as myself or as the same local user he tried to run the script on and it works just fine. There are no errors when he runs the script it just refuses to output
    to the CSV file for him, no matter who he's logged on as.
    If anyone has come across this before and knows why.
    TIA

    If you carefully read the script you posted it clearly states that it outputs nothing.
    Somewhere you are doing two different things.
    I suggest getting an analyst to follow both of you around and discover what you are doing.  One of you is a bit deluded about what is happening.
    Prepare yourself for a big embarrassment.
    Here is what it says in the directions for the script you posted the link for:
     .OUTPUTS 
            Nothing 
     There is no output to send to a CSV.
    The internal code does the following:
    $tasks = & schtasks /query /s $ComputerName /fo csv /v | ConvertFrom-Csv 
    See - no output.
    THen it does this:
     Send-MailMessage -Body $TasksInError -BodyAsHtml -From [email protected] -SmtpServer mysmtpserver.mydomain.com -Subject "Scheduled Tasks Report - $ComputerName" -To [email protected]  
    See - still no output.
    That is all there is in  your script.  Go back and retest and pay close attention to what you are doing.
    ¯\_(ツ)_/¯

  • Windows 10 reservation icon does not show in the tray

    Hi
    I have a 1/2 year old lenovo t440p with Windows 8.1 - totally updated on Windows Update.
    A windows 10 reservation icon should be shown on the lower right part of the tray, but it doesn't. A have searched different solutions, and tried manually to run gwx etx.
    I there any reason related to Lenovo, that it is not possible to make a reservation for Windows 10 at present time (it should have been possible since 29 May 2015).
    [Topic title edited to conform to additional posts in this discussion.]

    i have 3 lenovo laptops, W550s, Lenovo edge 15", Yoga 13, HP laptop and desktop, and Toshiba laptop. i have same problem with with only lenovo branded products. all with win 8.1 pro. you must have KB3035583 update installed. some people say that the script below helped them: REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\UpgradeExperienceIndicators" /v UpgEx | findstr UpgEx
    if "%errorlevel%" == "0" GOTO RunGWX
    reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Appraiser" /v UtcOnetimeSend /t REG_DWORD /d 1 /f
    schtasks /run /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser"
    :CompatCheckRunning
    schtasks /query /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser"
    schtasks /query /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" | findstr Ready
    if NOT "%errorlevel%" == "0" ping localhost >nul &goto :CompatCheckRunning
    :RunGWX
    schtasks /run /TN "\Microsoft\Windows\Setup\gwx\refreshgwxconfig" paste to a notepad file and change the extension to .cmd this did not worked for any of the lenovo laptop.  Lenovo must have a software issue which prevents icon appear. todat microsoft tech remotely worked for 4 hours and fixed w550s. he spent another 4 hrs on second lenovo edge but no success. he is trying to run script above but did not worked on lenovo edge. will try another microsoft tech tomorrow morning. we need lenovo to fix this issue whatever causes this problem. all other brand PCs i have and other PCs we use in office gets the upgrade notification. lenovo please weigh in and fix the issue.

  • Custom scheduled tasks dissapears in Windows 2012

    I have created custom task in Task Scheduler, but it does no appear under "Active Tasks".
    I found the task in C:\Windows\System32\Tasks, but not in the "schtasks /query".
    What is happening?

    Hi sindred,
    àI have created custom task in Task Scheduler, but it does no appear under "Active Tasks".
    I also create a task in my Lab environment via Task Scheduler. Yeah, as you find, the scheduled task didn't appear under "Active Tasks". However, after that task running, please refresh,
    and then you will find it in "Active Tasks" list.
    àI found the task in C:\Windows\System32\Tasks, but not in the "schtasks /query".
    How you configure Location option in General tab when create this task? After creating the scheduled task, please click Task Scheduler Library and check if find that created task. I also run
    "schtasks /query" command. However, I can find that task which I created. I suggest that check the result of "schtasks /query" command again. Meanwhile, please open this task Properties and click History tab, then check
    if find some relevant events.
    If any update, please feel free to let me know.
    Best regards,
    Justin Gu
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Windows 10 Reservation Icon

    I recently run all the Windows update for my laptop and I also updated all my drivers through HP Support Assistant however I still doesn't have the icon of upgrading to Windows 10, I double checked whether my laptop is compatible or not from the HP website and the website itself is telling me that yes it is compatible. there are no more updates that needs to be run from my laptop I wonder why im not getting the option to upgrade to Windows 10

    i have 3 lenovo laptops, W550s, Lenovo edge 15", Yoga 13, HP laptop and desktop, and Toshiba laptop. i have same problem with with only lenovo branded products. all with win 8.1 pro. you must have KB3035583 update installed. some people say that the script below helped them: REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\UpgradeExperienceIndicators" /v UpgEx | findstr UpgEx
    if "%errorlevel%" == "0" GOTO RunGWX
    reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Appraiser" /v UtcOnetimeSend /t REG_DWORD /d 1 /f
    schtasks /run /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser"
    :CompatCheckRunning
    schtasks /query /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser"
    schtasks /query /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" | findstr Ready
    if NOT "%errorlevel%" == "0" ping localhost >nul &goto :CompatCheckRunning
    :RunGWX
    schtasks /run /TN "\Microsoft\Windows\Setup\gwx\refreshgwxconfig" paste to a notepad file and change the extension to .cmd this did not worked for any of the lenovo laptop.  Lenovo must have a software issue which prevents icon appear. todat microsoft tech remotely worked for 4 hours and fixed w550s. he spent another 4 hrs on second lenovo edge but no success. he is trying to run script above but did not worked on lenovo edge. will try another microsoft tech tomorrow morning. we need lenovo to fix this issue whatever causes this problem. all other brand PCs i have and other PCs we use in office gets the upgrade notification. lenovo please weigh in and fix the issue.

  • Error while running a query-Input for variable 'Posting Period is invalid

    Hi All,
    NOTE: This error is only cropping up when I input 12 in the posting period variable selection. If I put in any other value from 1-11 I am not getting any errors. Any ideas why this might be happening?
    I am getting the following error when I try and run a query - "Input for variable 'Posting Period (Single entry, mandatory)' is invalid" - On further clicking on this error the message displayed is as follows -
    Diagnosis
    Variable Posting Period (Single Value Entry, Mandatory) is used as a lower limit (X) and an upper limit () in an interval selection. This limit has the value #.
    System Response
    Procedure
    Enter a different value for variable Posting Period (Single Value Entry, Mandatory). If the value of the other limit is determined by another variable, you can change its value also.
    Procedure for System Administration

    OK.
    Well, if the variable is not used in any interval selection, then I would say "something happened to it".
    I would make a copy of the query and run it to check if I get the same problem with period 12.
       -> If not, something is wrong in the original query (you can proceed as below, if changes to original are permitted).
    If so, then try removing the variable completely from the query and hardcode restriction to 12.
       -> If problem still persists, I would have to do some thinking.
    If problem is gone, then add the variable again. Check.
       -> If problem is back, then the variable "is sick". Only quick thing to do, is to build an identical variable and use that one.
    If problem also happens with the new variable, then it's time to share this experience with someone else and consider raising an OSS.
    Good luck!
    Jacob
    P.S: what fisc year variant are you using?
    Edited by: Jacob Jansen on Jan 25, 2010 8:36 PM

  • Logical database in adhoc query

    Hello All,
    Can anyone tell me what is the logical database in adhoc query?

    Hi
    When you create a query , you have to select an infoset. Infoset can be considered as a source from which data is populated in the Query Fields.
    Infosets are created from Transaction SQ02.
    There can be four methods through which an Infoset can become a source of data:
    1.  Table join ( By joining two or more tables from Data dictionary)
         example: Joining tables PA0001 and PA0006 on Pernr to get a one resultant dataset
    2. Direct read of Basis Table ( Like PA0001 as a source for data in Infoset )
    3. Logical Database ( A Pre-written Program by SAP that extract data from clusters, tables taking care of authorizations and validity periods)
    Example : Logical database PNP, PNPCE (Concurrent Employement),PCH ( LDB for Personnel Development Data)
    Custom Logical DBs can be created in T_Code SE-36.
    4. Data Retrieval by a Program ( Custom code written by ABAP developers which will collect and process data) . This program has a corresponding Structure in data dictionary and the fields of this structure will be used in query)
    Reward Points, if helpful.
    Regards
    Waseem Imran

  • Query help on Goods Receipt Query with AP Invoice

    Looking for a little help on a query.  I would like to list all the goods receipts for a given date range and then display the AP Invoice information (if its been copied to an AP Invoice).  I think my problem is in my where clause, I plagerized an SAP query to show GR and AP from a PO as a start.  SBO 2005 SP01.  Any help would be great appreciated.  Thanks
    SELECT distinct 'GR',
    D0.DocStatus,
    D0.DocNum ,
    D0.DocDate,
    D0.DocDueDate,
    D0.DocTotal,
    'AP',
    I0.DocStatus,
    I0.DocNum ,
    I0.DocDate,
    I0.DocDueDate,
    I0.DocTotal,
    I0.PaidToDate
    FROM
    ((OPDN  D0 inner Join PDN1 D1 on D0.DocEntry = D1.DocEntry)
    full outer join
    (OPCH I0 inner join PCH1 I1 on I0.DocEntry = I1.DocEntry)
    on (I1.BaseType=20 AND D1.DocEntry = I1.BaseEntry AND D1.LineNum=I1.BaseLine))
    WHERE
    (D1.BaseType=22 AND D1.DocDate>='[%0]' AND D1.DocDate<='[%1]')
    OR (I1.BaseType=20 AND I1.BaseEntry IN
    (SELECT Distinct DocEntry
    FROM PDN1 WHERE BaseType=22 AND DocDate>='[%0]' AND DocDate<='[%1]'))

    Hi Dalen ,
    I  believe it is because of the condition
    (D1.BaseType=22 AND D1.DocDate>='%0' AND D1.DocDate<='%1')
    OR (I1.BaseType=20 AND I1.BaseEntry IN
    (SELECT Distinct DocEntry FROM PDN1 WHERE PDN1.BaseType=22 AND DocDate>='%0' AND DocDate<='%1'))
    Try changing
    D1.BaseType=22 OR D1.DocDate>='%0' AND D1.DocDate<='%1
    PDN1.BaseType=22 OR DocDate>='%0' AND DocDate<='%1'))
    Lets see what would be the result . Lets have some fun with troubleshooting
    See what would be the difference in the result .
    Thank you
    Bishal

  • Can you check for data in one table or another but not both in one query?

    I have a situation where I need to link two tables together but the data may be in another (archive) table or different records are in both but I want the latest record from either table:
    ACCOUNT
    AccountID     Name   
    123               John Doe
    124               Jane Donaldson           
    125               Harold Douglas    
    MARKETER_ACCOUNT
    Key     AccountID     Marketer    StartDate     EndDate
    1001     123               10526          8/3/2008     9/27/2009
    1017     123               10987          9/28/2009     12/31/4712    (high date ~ which means currently with this marketer)
    1023     124               10541          12/03/2010     12/31/4712
    ARCHIVE
    Key     AccountID     Marketer    StartDate     EndDate
    1015     124               10526          8/3/2008     12/02/2010
    1033     125               10987         01/01/2011     01/31/2012  
    So my query needs to return the following:
    123     John Doe                        10526     8/3/2008     9/27/2009
    124     Jane Donaldson             10541     12/03/2010     12/31/4712     (this is the later of the two records for this account between archive and marketer_account tables)
    125     Harold Douglas               10987          01/01/2011     01/31/2012     (he is only in archive, so get this record)
    I'm unsure how to proceed in one query.  Note that I am reading in possibly multiple accounts at a time and returning a collection back to .net
    open CURSOR_ACCT
              select AccountID
              from
                     ACCOUNT A,
                     MARKETER_ACCOUNT M,
                     ARCHIVE R
               where A.AccountID = nvl((select max(M.EndDate) from Marketer_account M2
                                                    where M2.AccountID = A.AccountID),
                                                      (select max(R.EndDate) from Archive R2
                                                    where R2.AccountID = A.AccountID)
                   and upper(A.Name) like parameter || '%'
    <can you do a NVL like this?   probably not...   I want to be able to get the MAX record for that account off the MarketerACcount table OR the max record for that account off the Archive table, but not both>
    (parameter could be "DO", so I return all names starting with DO...)

    if I understand your description I would assume that for John Dow we would expect the second row from marketer_account  ("high date ~ which means currently with this marketer"). Here is a solution with analytic functions:
    drop table account;
    drop table marketer_account;
    drop table marketer_account_archive;
    create table account (
        id number
      , name varchar2(20)
    insert into account values (123, 'John Doe');
    insert into account values (124, 'Jane Donaldson');
    insert into account values (125, 'Harold Douglas');
    create table marketer_account (
        key number
      , AccountId number
      , MktKey number
      , FromDt date
      , ToDate date
    insert into marketer_account values (1001, 123, 10526, to_date('03.08.2008', 'dd.mm.yyyy'), to_date('27.09.2009', 'dd.mm.yyyy'));
    insert into marketer_account values (1017, 123, 10987, to_date('28.09.2009', 'dd.mm.yyyy'), to_date('31.12.4712', 'dd.mm.yyyy'));
    insert into marketer_account values (1023, 124, 10541, to_date('03.12.2010', 'dd.mm.yyyy'), to_date('31.12.4712', 'dd.mm.yyyy'));
    create table marketer_account_archive (
        key number
      , AccountId number
      , MktKey number
      , FromDt date
      , ToDate date
    insert into marketer_account_archive values (1015, 124, 10526, to_date('03.08.2008', 'dd.mm.yyyy'), to_date('02.12.2010', 'dd.mm.yyyy'));
    insert into marketer_account_archive values (1033, 125, 10987, to_date('01.01.2011', 'dd.mm.yyyy'), to_date('31.01.2012', 'dd.mm.yyyy'));
    select key, AccountId, MktKey, FromDt, ToDate
         , max(FromDt) over(partition by AccountId) max_FromDt
      from marketer_account
    union all
    select key, AccountId, MktKey, FromDt, ToDate
         , max(FromDt) over(partition by AccountId) max_FromDt
      from marketer_account_archive;
    with
    basedata as (
    select key, AccountId, MktKey, FromDt, ToDate
      from marketer_account
    union all
    select key, AccountId, MktKey, FromDt, ToDate
      from marketer_account_archive
    basedata_with_max_intervals as (
    select key, AccountId, MktKey, FromDt, ToDate
         , row_number() over(partition by AccountId order by FromDt desc) FromDt_Rank
      from basedata
    filtered_basedata as (
    select key, AccountId, MktKey, FromDt, ToDate from basedata_with_max_intervals where FromDt_Rank = 1
    select a.id
         , a.name
         , b.MktKey
         , b.FromDt
         , b.ToDate
      from account a
      join filtered_basedata b
        on (a.id = b.AccountId)
    ID NAME                     MKTKEY FROMDT     TODATE
    123 John Doe                  10987 28.09.2009 31.12.4712
    124 Jane Donaldson            10541 03.12.2010 31.12.4712
    125 Harold Douglas            10987 01.01.2011 31.01.2012
    If your tables are big it could be necessary to do the filtering (according to your condition) in an early step (the first CTE).
    Regards
    Martin

  • Query help : Query to get values SYSDATE-1 18:00 hrs to SYSDATE 08:00 hrs

    Hi Team
    I want the SQl query to get the data for the following comparison : -
    Order Created is a Date Column , and i want to find out all the values from (SYSDATE-1) 18:00 hours to SYSDATE 08:00 hours
    i.e.
    (SYSDATE-1) 18:00:00 < Order.Created < SYSDATE 08:00:00.
    Regards

    Hi, Rohit,
    942281 wrote:
    If i want the data in the below way i.e.
    from (SYSDATE-1) 18:00 hours to SYSDATE 17:59 hours ---> (SYSDATE-1) 18:00:00 < Order.Created < SYSDATE 07:59:00.If you want to include rows from exactly 18:00:00 yesterday (but no earlier), and exclude rows from exatly 08:00:00 today (or later), then use:
    WHERE   ord_dtl.submit_dt  >= TRUNC (SYSDATE) - (6 / 24)
    AND     ord_dtl.submit_dt  <  TRUNC (SYSDATE) + (8 / 24)
    So can i use the below format : -
    ord_dtl.submit_dt BETWEEN trunc(sysdate)-(6/24) and trunc(sysdate)+(7.59/24) . Please suggest . .59 hours is .59 * 60 * 60 = 2124 seconds (or .59 * 60 = 35.4 minutes), so the last time included in the range above is 07:35:24, not 07:59:59.
    If you really, really want to use BETWEEN (which includes both end points), then you could do it with date arithmentic:
    WHERE   ord_dtl.submit_dt  BETWEEN  TRUNC (SYSDATE) - (6 / 24)
                      AND         TRUNC (SYSDATE) + (8 / 24)
                                               - (1 / (24 * 60 * 60))but it would be simpler and less error prone to use INTERVALs, as Karthick suggested earlier:
    WHERE   ord_dtl.submit_dt  BETWEEN  TRUNC (SYSDATE) - INTERVAL '6' HOUR
                      AND         TRUNC (SYSDATE) + INTERVAL '8' HOUR
                                               - INTERVAL '1' SECONDEdited by: Frank Kulash on Apr 17, 2013 9:36 AM
    Edited by: Frank Kulash on Apr 17, 2013 11:56 AM
    Changed "- (8 /24)" to "+ (8 /24)" in first code fragment (after Blushadown, below)

Maybe you are looking for

  • Performance loss with audio apps in Leopard

    I upgraded one of my machines to Leopard when it came out. It had the same apps installed as my production machine, so I thought this would be a good way to really test Leopard with real applications that I use everyday. So far my audio apps have tak

  • IE 10: SSRS Reports no longer allows Drop Down functionality

    IE 10 doesn't support the SSRS Report Drop Down Functionality. It works fine with IE 9: The drop down arrow functionality only works with IE9 SSRS server for folders and reports. It does not work with IE 10. Please advise. Garth Henderson - Vanguard

  • Why will the Apple music app on my iPad not play certain songs???

    Hi, Suddenly I noticed that certain songs, that will play without problem within iTunes on my PC, and with no problem on my iPhone 4S, will NOT play at all on my iPad (MB293KS) running iOS 5.1.1... I have reset the iPad and then downloaded everything

  • HT1689 On iPad my iTunes screen is blank,  does not show any information

    I open iTunes and I only get the icons on te bottom of the screen.  No content displays.  Same result if I search for music.

  • Print text AND pictures

    Hi, I have a psc 1355 AIO. When I have written a document in Open Office Writer with text and pictures and want to print the document, it suddenly comes out with text and an empty space where the pictures should have been. It has never done that befo