How do I create a repetitive applications?

So, I have the following query:

Select count (*)
of biw_hda_event
where
+(+
+(+
report_date < to_date ('01-06-2011 00:00:00 ',' YYYY-MM-DD HH24:MI:SS') and deliver_date > = to_date ('01-06-2011 00:00:00 ',' YYYY-MM-DD HH24:MI:SS')
+)+
and ltrim (rtrim (status)) <>'Void '.
+)+
Gold
+(+
report_date < to_date ('01-06-2011 00:00:00 ',' YYYY-MM-DD HH24:MI:SS') and ltrim (rtrim (status)) in ('Work In Progress', 'Assign', 'Climbing')
+)+
order by 1 desc

The dates 2011-06-01 00:00:00 and 01-07-2011 00:00:00 are parameters.

The result above will return a value (number) for the period from 2011-06-01. How can I create the same query repeatedly to X number of times? For example, I would run that the query above to be run 13 times but each with a different setting. The parameters are in order. for example: 2011-06-01, 01-05-2011, 2011-04-01, etc.

Thank you

What exactly are you trying to do? You try to subtract (, ) to (, )... which makes no sense. You subtract numbers of numbers, not (date, number) pairs of (date, number) pairs!

You have also abused DATEs and subquery factoring in your query. Keep dates DATEs for as long as possible - only to_char them when you want to generate the results. With the subquery factoring, you have one available (which may contain multiple subqueries, each with an alias), and then you make your query at the end.

Maybe (and this is just a massive assumption), you're after something like:

WITH date_tab AS (SELECT ADD_MONTHS(TRUNC(sysdate, 'mm'), 1 -LEVEL) dt1,
                         ADD_MONTHS(TRUNC(sysdate, 'mm'), 2 - LEVEL) dt2
                  FROM   DUAL
                  CONNECT BY LEVEL <= 13),
     incoming AS (SELECT b.dt1,
                         COUNT(*) AS incoming_cnt
                  FROM   biw_hda_event a,
                         date_tab b
                  WHERE  (a.report_date < b.dt1
                          AND a.deliver_date >= b.dt1
                          AND TRIM(a.status) != 'Void')
                  OR     (a.report_date < b.dt1
                          AND TRIM(status) IN ('Work In Progress', 'Assign', 'Escalate'))
                  OR     (TRIM(status) != 'Void'
                          AND report_date = b.dt1)
                  GROUP BY b.dt1),
     resolved AS (SELECT b.dt1,
                         COUNT(*) AS resolved_cnt
                  FROM   biw_hda_event a,
                         date_tab b
                  WHERE  (   (a.report_date< b.dt1
                              AND a.deliver_date >= b.dt1
                              AND TRIM(status) != 'Void'
                              AND a.deliver_date < b.dt2)
                          OR (a.report_date < b.dt1
                              AND TRIM(status) IN  ('Work In Progress', 'Assign', 'Escalate'))
                          OR (a.report_date = b.dt1
                              AND a.deliver_date = b.dt1))
                  AND    TRIM(status) IN ('Complete', 'Deliver', 'Ready')
                  GROUP BY b.dt1)
SELECT TO_CHAR(i.dt1, 'dd/mm/yyyy') dt,
       i.incoming_cnt - r.resolved_cnt carry_forward
FROM   incoming i,
       resolved r
WHERE  i.dt1 = r.dt1;

PS. to format your code, please use the {code {noformat} {noformat}} tag at each end of it. (if you click on answer, and then quotes (at the end of the bold, italic, toolbar etc.) button, you can see how I use it to format my example SQL.)

ETA: I'm not particularly happy with the incoming subqueries and resolved - there should be a way to use the CASE as well as the relevant conditions develop the counties incoming and resolved in a single query, but it will take more time that I have or am willing to spend trying to decipher your logic. I'll leave that as an exercise for you to do...

Published by: Boneist on July 12, 2011 10:28

Tags: Database

Similar Questions

  • How can I create folders with Applications folder

    I have a brain injury, so I have memory problems and I would like to create folders in the Applications folder so I can consolidate all my apps in a single folder in photo editing Applications. It is roughly the same method, which can be done in windows in the Start Menu. If someone could tell me how I am able to achieve this goal, it would be greatly appreciated.

    Open your application and choose the menu bar > new folder. You can then drag and drop them into this folder. However, I wouldn't put Apps in subfolders as what update of OS X is unable to see them there.

  • To view the details of the table, how can I create users and applications for the dev team?

    Hello
    Veiw the tables as column details, etc., we use the password apps by oracle apps Forms.But apps password giving the development of values is threat to security. My question, how the development team will check the details of the database other than the apps user & password? No work around for this problem?

    Naya,

    The developers must have access to the development/TEST instance but must not be connected directly to the instance of PROD. Assuming that your development instance is identical to the production, I believe that the best scenario is to prepare reports on the development instance (having full access including password apps), and once they are done, they go to the ADMINISTRATOR to upload it to the production instance.

  • How to create a Java application that receives Messages from Web site.

    Hello

    I'm a c# developer, and I am new to programming Java with Eclipse.

    How can I create a simple application that listens on a port for incoming text Messages.

    In c#, I can do this in 5 minutes but in Java, well, I don't know.

    Help out me of the good people

    Research advance for your answers

    Hamid Weiss

    Here is an article that will help you:

    http://supportforums.BlackBerry.com/T5/Java-development/different-ways-to-listen-for-SMS-messages/TA...

    Unfortunately, this is the easy bit.  The hard bit is creating the application and have it run in a background Thread.

    For this, I recommend study you the samples provided and understand how they work.  The website is also a good source of material and explanations, as of course is this forum.

    You might find this useful too:

    http://supportforums.BlackBerry.com/T5/Java-development/tutorials-for-new-developers-part-1/m-p/1621...

    Good luck.

  • How can I create a group through Outlook without the application Outlook email?

    How can I create a group by using Outlook without an application Outlook email?

    Sigmalambda wrote:

    How can I create a group by using Outlook without an application Outlook email?

    It is difficult to understand what you're trying to do. You can create a group and send an email to the group in any mail client. The recipients can use any e-mail provider or an e-mail client to receive e-mail. Please explain in more detail what you are trying to accomplish.

  • How can I create a Windows using NOR-DAQmx application in Visual Studio 2010 64-bit

    Hello

    How can I create a Windows using NOR-DAQmx application in Visual Studio 2010 64-bit?

    I'm transferring a 32-bit application on 64-bit.  In visual Studio, I added the 64-bit project configuration.  He compiled the source very well but the reports link errors:

    error LNK2019: unresolved external symbol DAQmxReadAnalogF64 referenced in function NI6008_AnalogInput NI_6281\NI6281.obj
    error LNK2019: unresolved external symbol DAQmxCreateAIVoltageChan referenced in function NI6008_AnalogInput NI_6281\NI6281.obj
    error LNK2019: unresolved external symbol DAQmxReadDigitalLines referenced in function NI6008_DigitalInput NI_6281\NI6281.obj
    error LNK2019: unresolved external symbol DAQmxCreateDIChan referenced in function NI6008_DigitalInput NI_6281\NI6281.obj
    error LNK2019: unresolved external symbol DAQmxWriteDigitalLines referenced in function NI6008_DigitalOutput NI_6281\NI6281.obj
    error LNK2019: unresolved external symbol DAQmxCreateDOChan referenced in function NI6008_DigitalOutput NI_6281\NI6281.obj

    These, of course, are the functions OR that I use.  The NIDAQmx.lib has been added to the Input of the link property.

    Any help would be appreciated.

    Thank you

    -Neil shore

    Hi LaserShore,

    Think you that you added the 64-bit platform settings target according to this page? : http://zone.ni.com/reference/en-XX/help/372636F-01/mstudiowebhelp/html/64bitcore/

    Already running 32-bit application? Have you changed references to the 64-bit version?

    You use Measurement Studio? If so some features are not supported with 64 bit.

    Also when you say that you have added the NIDAQmx.lib, did you follow this KB:http://digital.ni.com/public.nsf/allkb/38F67B28D995C6958625706E000C580C

  • How to export a .sql file, I created from Oracle Application Express of SQL Server Management 2012?

    Hello

    I was wondering if you could help me.

    I'm trying to find out how to export a .sql file, I created from Oracle Application Express of SQL Server Management 2012? I'm not very technical, but it seems that the Oracle code does not work with SQL Management Studio when I drag the file inside.

    I need the database Oracle express and its data to enter in SQL Management Studio, so any help would be much appreciated!

    Thank you.

    Hello

    Your question is beyond the scope of this community.

    Please repost your question in the SQL Server TechNet Forums.

    https://social.technet.Microsoft.com/forums/SQLServer/en-us/home?category=SQLServer

    See you soon.

  • HOW TO CREATE AND MANAGE APPLICATIONS OF PLANNING CLASSIC ON EMP 11.1.2.4

    Hi all

    We installed and configured 11.1.2.4 EMP, and was happy to work on planning that was created by using the workspace EPMA until we came across a requirement for reports plan type, coming to the point:

    1. in the EMP 11.1.2.4 how to create a classic application and how to perform administrative tasks, any suggestions would be helpful.

    2 if we conduct EPMA planning application, then how to convert it into classic?

    concerning

    Shahrukh

    Try to run it with - Setting of Applications Using Planning Application Administration

    Is what I'd do to convert a conventional application of EPMA

    Set the property to true EDIT_DIM_ENABLED - Management of Dimensions in Planning Applications deployed

    Restart the planning

    Extract the application of planning using LCM.

    EDIT_DIM_ENABLED property set to false

    Restart the planning

    Remove application EPMA

    Import the backup LCM to build the new classic application.

  • How to create a new application in a VISION-based APEX

    Hi all

    I am a newbie to this tool. I am creating a new application with the wizard and choosing a report/form. I want to use a VIEW and not a table on the basis of the requests but do not see the display in the drop down menu to choose. In the screen itself, the definition of a page of the report and the form says that a user can update a table or a view. Yet, I don't see a way to choose the view.

    Can anyone make a suggestion on how to choose a view to base an application?

    Thank you

    http://rokitta.blogspot.com/2009/12/tabular-forms-on-complex-views-using.html

  • I have problems of space on my iPhone 6. I have only 21 photos and 2 videos on my phone. However, I am on a discussion group on whatsapp. How can I create more space for my phone? I also have very few applications on my phone.

    I have problems of space on my iPhone 6, I have only 21 photos and 2 videos on my phone. However, I am part of a chart group on whatsapp. The problem now is that my storage space is almost full. How can I create more space for photos and everything?

    You cannot create more space for everything.  All you can do is remove apps, photos and especially videos to make room for other pictures and videos.

  • How to create simple SCM application for shopee material forms of oracle 10g

    Hi all
    I want to create a simple application of the SCM for material shopee.
    I want to know the whole idea behind it, to reset all of the concepts, the required tables, etc.

    This forum focuses on Oracle EBS. You can get a better response in the Oracle Forms forum.
    Forms

    Sandeep Gandhi

  • On a flyer, I need to produce black and PMS color. How can I create a PMS color (instead of something on the color wheel).

    On a flyer, I need to produce black and PMS color. How can I create a PMS color (instead of something on the color wheel or RGB)?

    It depends on the application. You use an inDesign application of PAO as Quark XPress, or something else?

    Many consumer apps is not able to output CMYK or specific pantone color combinations.

  • How can I create a full recovery for OS and preinstalled software media?

    Hello
    My son´s accompanying the new Satelite L855-10U preinstalled OS and much other software already installed on the HARD drive, but no installation media, the client is supposed to create a tool from Toshiba.

    I created 6 Swedish recovery for the operating system using the tools Toshiba had installed on the HARD drive.

    To do this 6 Swedish, I created with the Toshiba Recovery tool contain the operating system and all other preinstalled software?

    How can I create the installation media full and usable if not for the operating system and all other preinstalled software?

    I can´t find all the information on the backup software pre-installed with the exception of the BONE. Is there complete information how to do the above, in the manual of the computer, or have you missed this information?

    I would like to know how I can create media backup complete and usable for the operating system as well as for all other preinstalled software, so I can recreate all the facilities of the plant at a new disk if/when the original HARD disk crashes.

    Is there a partition hidden with pre-installed software, and if so, how can I create a backup of this partition, or all the software, so I can reinstall everything if the HARD drive fails, if it is already not with the Swedes 6 Toshiba tool created for me?

    Forward to your response and to complete your customer documentation about the complete instructions for installation and recovery media creation.

    Thank you very much!

    Baltazar

    Hello

    On this forum, you will find a lot of useful comments on the recovery image saved on the HARD drive and its operation to the facility and the creation of recovery disks.
    All this is clearly and simply.

    Front of Toshiba offer new people for laptop in software development create recovery image. This recovery image will be created for each laptop model (specific hardware configuration). Recovery image contains the operating system, all necessary drivers, tools/utilities Toshiba specific and some other software like DVD/Blu-Ray, Microsoft Office test drive and the antivirus application. With this configuration every laptop owner can begin to use the laptop without having to install important applications.

    This package is then saved on the HARD drive and can be used for the installation of HARD drive recovery - http://aps2.toshiba-tro.de/kb0/HTD1303440001R01.htm. In other words, if something is wrong with HARD drive recovery facility you can reset the preinstalled operating system and reinstall recovery imae. After that make you have absolute same settings you had after purchase and first start of the laptop.
    HARD drive recovery image can not be used if:
    -HARD drive is defective
    -you have installed the version of the own BONE
    Structure of the HARD disk partitions - is changed
    Recovery image - HARD drive is deleted or moved to another partition or copied to the external device.

    To avoid all this Toshiba recommends the creation of recovery disks. Using these disks, you will be able to install the OS on the new drive HARD or in any other situation listed above.
    Please note: the use of recovery disks will remove all HARD drive, create the new recovery partition and install image recovery, so you still have the same settings.

    I hope I can help you with my explanation. If you have any other questions you are welcome.

  • How do you create array of enumerations for transitions in a state machine?

    Hello

    I am trying to build a state machine, but I am struggling with understanding of the methods to determine what State to move to the next.  In other words, I have several States, but I don't want to go in any particular sequence.  If I States numbered 1 to 10, I want to be able to go 1-4-2-5-6-2-6-1-10 etc. in no particular order. I want the transition to the next State (and actions) to be determined by data stream, which may be random and require access to one of my 10 States at any time and in any order.

    I saw this photo on the white paper "Application Design Patterns: machinery of State", but it leaves out some important details.  How do I create the structure in BLUE showed 3 c?  When I try to create this table of enums, all are the same. I am not able to make a list of different enum values.  In other words, when I type '2', then all values in the Bulletin Board "2."

    There is a nice video example and easy to a state machine for the distribution of soda $0.15, however, this state machine moves in a single sequence of 5 cents, 10 cents to deliver; It does NOT illustrate the selection of a State "out of order".  I need to understand how a state machine can move State "5 cents" to distribute directly, with the addition of 10 cents in the State "5 cents.

    Can someone suggest a very good tutorial on how to make the switch to operate in a state machine?  I have read some documents available on ni.com, but, I can't find a good explanation of how do.  I remain confused.

    Or, you can just explain how they created the BLUE table in the attached picture?  Maybe I can understand it from there.

    Thank you

    Dave


  • How can I create a USB Virtual COM Port

    Windows XP Professional / SP3 / 2002 Version

    How do I create a virtual COM Port to USB, so I can run software applications of a Bus USB flash Drive?
    The reason why I am eager to do it, is because I use an audio sequencer and it requires 1 GB of free disk space and at least 1 GB of RAM is recommended. My machine has 0.5 GB of RAM and a total of 6.55 GB of FREE space. My machine has a 256 MB RAM module and I bought another 256 MB RAM module. The manufacturer said that 512 MB of RAM is the maximum that can have my camera.
    My goal is to buy a 4 GB Flash drive and use it to add RAM on my machine. I am also wanting to be able to run software applications that are installed in the USB Flash drive.
    My basic goal is to install the DAW in the USB Flash drive and work with the program that is in the USB Flash drive, and I hope that will release of enough memory on my laptop.

    Hello

    Unfortunately, you cannot use a USB flash as a substitute for the RAM drive.

    Similar topics as an example with the info:

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_xp-hardware/can-i-use-a-USB-flash-drive/70cf81fa-D113-4485-8305-c030665eeac0

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_xp-hardware/can-a-USB-flash-drive-be-used-as-an-external-RAM/d711a70e-6878-4552-933C-423fa04fb222

Maybe you are looking for

  • Photo not displayed in apps for iOS 9.3.1

    My photos are not displayed in four of my apps since I installed the software update iOS 9.3.1.  I checked the settings and have all my applications requesting access to my photos.  Four applications are 5 Miles, OfferUp, VarageSale and Letgo.  All w

  • TouchSmart 300 - 1060 has,

    want to upgrade memory 2 x 2 GB, 2 GB + 4 GB memory do I need?

  • Rebel T5i?

    The EOS Rebel T5i has the geo-tagging capability?

  • HP Pavilion 15-n070sw docking station

    I'm trying to find information on the dock that would be compatible with HP Pavilion 15-n070sw. Do you know what docsking ststaion will work fo this laptop?

  • Issue of group policy

    Is it possible to implement a group policy of global domain so that users cannot change their name to the machine, even if they are admins on their machine only?  Computers running Windows 7 or Mac OS 10.x