Added the Dates of application

What I'm trying to achieve.
I have 3 tables.

tblCUSTDETAILS - contains information of customers.
tblFLTNUMS - contains defects the customer has
tblCONTACTS - contains the monthly Volume of Contacts by the customer.

I want to do is show the amount of contacts of 3 months after the date of the fault. So I can say things like 3 months after a fault of the customer always contact us because they lost trust with our service. etc.

The problem is that if the customer has not called for a specific month then it does not save 0 and that's what I want.

WITH tblCUSTDETAILS AS (
    SELECT  '11111' AS CUST_ID, 'John Smith' AS CUST_NAME FROM DUAL UNION ALL
    SELECT  '11112' AS CUST_ID, 'Andy Wilson' AS CUST_NAME FROM DUAL
), tblFLTNUMS AS (
    SELECT  '11111' AS CUST_ID, TO_DATE('JAN-10', 'MON-YY') AS FLT_DT FROM DUAL UNION ALL
    SELECT  '11112', TO_DATE('FEB-10', 'MON-YY') FROM DUAL UNION ALL
    SELECT  '11112', TO_DATE('APR-10', 'MON-YY') FROM DUAL  
),
   tblCONTACTS AS (
    SELECT  '11111' AS CUST_ID, TO_DATE('JAN-10', 'MON-YY') AS CONTACT_DT, 5 AS CONTACT_VOL FROM DUAL UNION ALL
    SELECT  '11111', TO_DATE('FEB-10', 'MON-YY'), 3 FROM DUAL UNION ALL
    SELECT  '11112', TO_DATE('MAR-10', 'MON-YY'), 1 FROM DUAL UNION ALL
    SELECT  '11112', TO_DATE('MAY-10', 'MON-YY'), 2 FROM DUAL 
)
SELECT  t1.cust_id, 
        t2.cust_name,
        t1.flt_dt,
        t3.contact_dt,
        t3.contact_vol 
FROM    tblFLTNUMS t1
JOIN    tblCUSTDETAILS t2
    ON t1.cust_id = t2.cust_id
JOIN    tblCONTACTS t3
    ON t1.cust_id = t3.cust_id
ORDER BY flt_dt, contact_dt, cust_name DESC
;   
As you can see by the example atttached Joh Smith had a flaw on 01/01/2010 and contacted us on 01/01, 01/02, not 01/03 but I want 01/03 to say 0.

It's just a report that I can't rebuild the tables so a SQL-based solution is required.

I hope you can help.

I'm not sure what you are really after, but I gave it a shot:

SQL> WITH tblCUSTDETAILS AS (
  2      SELECT  '11111' AS CUST_ID, 'John Smith' AS CUST_NAME FROM DUAL UNION ALL
  3      SELECT  '11112' AS CUST_ID, 'Andy Wilson' AS CUST_NAME FROM DUAL
  4  ), tblFLTNUMS AS (
  5      SELECT  '11111' AS CUST_ID, TO_DATE('JAN-10', 'MON-YY') AS FLT_DT FROM DUAL UNION ALL
  6      SELECT  '11112', TO_DATE('FEB-10', 'MON-YY') FROM DUAL UNION ALL
  7      SELECT  '11112', TO_DATE('APR-10', 'MON-YY') FROM DUAL
  8  ), tblCONTACTS AS (
  9      SELECT  '11111' AS CUST_ID, TO_DATE('JAN-10', 'MON-YY') AS CONTACT_DT, 5 AS CONTACT_VOL FROM DUAL UNION ALL
 10      SELECT  '11111', TO_DATE('FEB-10', 'MON-YY'), 3 FROM DUAL UNION ALL
 11      SELECT  '11112', TO_DATE('MAR-10', 'MON-YY'), 1 FROM DUAL UNION ALL
 12      SELECT  '11112', TO_DATE('MAY-10', 'MON-YY'), 2 FROM DUAL
 13  ), tblMonthParameters AS (
 14          SELECT  MIN(FLT_DT) AS startMonth
 15          ,       ADD_MONTHS(MAX(FLT_DT),2) AS endMonth
 16          FROM    tblFLTNUMS
 17  ), tblMONTHS AS (
 18          SELECT  ADD_MONTHS(startMonth,ROWNUM - 1) AS DT
 19          FROM    tblMonthParameters
 20          CONNECT BY LEVEL <= MONTHS_BETWEEN(endMonth,startMonth) + 1
 21  )
 22  SELECT  t1.cust_id,
 23          t2.cust_name,
 24          t1.flt_dt,
 25          t3.dt,
 26          NVL(t3.contact_vol,0)   AS CONTACT_VOL
 27  FROM    tblFLTNUMS t1
 28  JOIN    tblCUSTDETAILS t2
 29      ON t1.cust_id = t2.cust_id
 30  JOIN    (
 31                  SELECT  CUST_ID
 32                  ,       CONTACT_VOL
 33                  ,       DT
 34                  FROM    tblCONTACTS PARTITION BY (tblCONTACTS.CUST_ID)
 35                  RIGHT JOIN tblMONTHS  ON tblCONTACTS.CONTACT_DT = tblMONTHS.DT
 36          ) t3
 37      ON  t3.CUST_ID = T1.CUST_ID
 38      AND MONTHS_BETWEEN(t3.DT,t1.FLT_DT) BETWEEN 0 AND 2
 39  ORDER BY flt_dt, dt, cust_name DESC
 40  ;

CUST_ CUST_NAME   FLT_DT              DT                           CONTACT_VOL
----- ----------- ------------------- ------------------- --------------------
11111 John Smith  01/01/2010 00:00:00 01/01/2010 00:00:00                    5
11111 John Smith  01/01/2010 00:00:00 02/01/2010 00:00:00                    3
11111 John Smith  01/01/2010 00:00:00 03/01/2010 00:00:00                    0
11112 Andy Wilson 02/01/2010 00:00:00 02/01/2010 00:00:00                    0
11112 Andy Wilson 02/01/2010 00:00:00 03/01/2010 00:00:00                    1
11112 Andy Wilson 02/01/2010 00:00:00 04/01/2010 00:00:00                    0
11112 Andy Wilson 04/01/2010 00:00:00 04/01/2010 00:00:00                    0
11112 Andy Wilson 04/01/2010 00:00:00 05/01/2010 00:00:00                    2
11112 Andy Wilson 04/01/2010 00:00:00 06/01/2010 00:00:00                    0

9 rows selected.

I have added more than two tables to your WITH clause. The tblMonthParameters calculates the minimum FLT_DT and maximum FLT_DT + 2 month based on your requirement of fault for three months. The tblMonths use these input parameters and generates a number of dense months.

This dense months range is then outside connected by the PARTITION OF the table tblCONTACTS syntax to generate months for each customer. This result is then used as a subquery in the main original query you had to join based on the customer and FLT_DT. When the customer has not contacted for any given month, I put a 0 in the CONTACT_VOL column.

If this is not correct please let me know. This solution depends on 10g, so if you do not, you may need to find another way to do this.

HTH!

Tags: Database

Similar Questions

  • Less than the date of application


    Than the date of application.

    How to get out the query set so even if a T_DATE is less than the Admission_date the query should display all the data.

    ID T_DATE Admission_date
    101 4/1/2001-5/1/2001
    102 4/1/2001-5/1/2001
    103 4/1/2001-5/1/2001
    104 4/1/2001-5/1/2001
    105 4/1/2001-5/1/2001
    106 6/1/2001-5/1/2001

    Even if a T_DATE is less than the date of Admission, the application must pick up all the data.

    Select * from X where T_DATE < Admission_Date gives only

    101 4/1/2001-5/1/2001
    102 4/1/2001-5/1/2001
    103 4/1/2001-5/1/2001
    104 4/1/2001-5/1/2001
    105 4/1/2001-5/1/2001

    Yet the missing 106.

    Thank you..

    Hello

    You can change the solution in response #2 like this:

    WITH got_ok_cnt AS

    (

    SELECT *- or display the columns that you want to

    , COUNT (CASE WHEN T_DATE)< admission_date="" then="" 1="">

    COURSES (PARTITION BY id) AS ok_cnt

    X

    )

    SELECT *- or the list of all columns except ok_cnt

    OF got_ok_cnt

    WHERE ok_cnt > = 1

    ;

  • Check for the empty table row before adding the date

    On the form below, when I click on the green button (extreme right) plus a new row in the table is created with today's date. the user can then enter more text to the right of the date. Problem is when the form is saved and reopened, the text that the user entered is removed and today new is added because it is in the intialize event. How do I script to check and make sure that each dated line is empty before you add today's date?

    https://Acrobat.com/#d=qTINfyoXA-U6cDxOGgcSEw

    Thank you

    ~ Gift

    Hi Don,

    One possibility would be to use the box caption of the textfield for the date and leave the value part free for the user to enter their data:

    if (xfa.resolveNode("this.caption.value.#text").value === "") {
              this.caption.value.text = util.printd("[mm/dd/yy] ", new Date() );
    }
    

    See here: https://acrobat.com/#d=VjJ-YsXLKmV6QU84JrAAIw.

    Hope that helps,

    Niall

  • Why can't pass the data on applications for some?

    I had this problem for months and I can't activate the data for all the apps I actually use. So now I can't all I can't even see where the nearest ice cream store is at Kansas or download the latest music in iTunes or even to get the news. iOS 9 or up idk. Why???!?!?!?!!!?!??

    Is there a Restriction on the cellular data settings change? Settings/general/Restrictions.

  • Criteria of programmatic view adding the date condition

    Hi all

    I use Jdev 12.1.3. I wrote a method in AMImpl to filter my viewobject based on custom search screen of the user interface.

    I create the criteria for the view programmatically. I have check SMSDate field in my VO date between the criteria in the field settings start date and end date.

    How to define this condition by programming

    ' Public Sub searchInfo (String attribut1, String fullname, startDate, endDate oracle.jbo.domain.Date oracle.jbo.domain.Date) {}

    ViewObjectImpl vo = getSmsInfoVO1();

    ViewCriteria vc = vo.createViewCriteria ();

    ViewCriteriaRow vcRow = vc.createViewCriteriaRow ();

    If (attribut1! = null & &! attribute1.isEmpty ()) {}

    vcRow.setAttribute ("attribut1", attribute1);

    vc.addRow (vcRow);

    }

    If (fullname! = null & &! fullname.isEmpty ()) {}

    vcRow.setAttribute ("full name", fullname);

    vc.addRow (vcRow);

    }

    Need a logic here set VO attribute SMSDate and check the date between the startDate and endDate parameters method

    vo.applyViewCriteria (vc);

    vo.executeQuery ();

    }

    Check this box:

    setOperator ("between")

  • Rename the files in a directory by adding the date and time

    Hello

    I am looking for a way to rename all the files that are in a directory with an add-on at the end with the date and time.

    for example:

    File1-> file1ddmmyyhhmi

    File2-> file1ddmmyyhhmi

    for example:

    $A = get-date-Format "yyyymmddhhmm.

    foreach-object - process ...

    Thank you.

    You can try something like this

    $A=get-date -Format "yyyymmddhhmm"
    Get-ChildItem "C:\folder" | %{
         Rename-Item -NewName ($_.Basename + $A + $_.extension) -Path $_.FullName
    }
    

    This assumes that the files are stored in C:\folder

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • I need to know the date where I deleted an application

    I deleted an application. How can I see the date of applications are deleted?

    You can not.

  • How to consume the data model library adf for the project?

    Hello

    I use Jdev 11.1.1.6.

    I have a workspace Jdev containing the business component (entity objects, view and application module objects exposing the your). This workspace is deployed to a library of the ADF. This library is packed with DB connection details.

    I have a different workspace Jdev which needs to consume this library of ADF data model. This workspace is actually just the layer view (no business at all components).
    I added the data library ADF model to his draft opinion and it is showing application module and your sub of the data controls.

    My question is: how will this project view to connect to DB when running?
    It allows the connection of packaged data model ADF Libabry? If so, how?
    or should I create a business under this workspace view, just the purpose of connection project? If Yes, then what is the use of connections, including creating the library of the ADF?

    Thank you
    JAI

    Hello

    It uses the connection in the library of the ADF. However, I recommend that not save you the database connect information in the library of the ADF. Instead:

    -set the ADF BC model to use JDBC data sources
    -In the library of the ADF, configure it to contain only the name of data source
    -In the view project (the workspace) set up the database connection that is exposed by the library

    When the library is imported, verify the Application resources--> connections and right click on the name of the connection that is imported to configure

    Frank

  • multiple columns when the data connection to a txt file

    I am eager to write for different columns third example of a single txt file when recording data. Can someone show me examples of code how get 3 groups of data with several points, write them in their own columns and then go back and write more data points to the columns by adding the data... Please and thank you.

    Hi Tony,.

    Here's a basic example to do so.

    In newer versions of LV, you will find a 'write in the spreadsheet file' function which performs the task of the two functions to the right of the block diagram, but the version reported is more flexible IMHO because it allows to add easily the headers and footers...

  • Guests of the date to a Date column

    Hi gurus,
    I'm trying to get the Date of application for a Date column. This is the approach that I took from the previous post.

    Re: How to get the date of request for a date column

    My approach
    (1) in the report, I put the filter on the Date column with variable presentation as startdate with a date by default, and in the window of fx, I applied
    CASES WHERE 1 = 0 THEN the picture. Table of date ELSE. END date
    (2) I repeated the same thing by getting the same column with Variable presentation date as Enddate with a date by default and in the fx I applied
    CASES WHERE 1 = 1 THEN table. Table of date ELSE. END date
    (3) in the dash prompt, I had the same date twice column by applying the same formulas in fx, default sysdate - variable Server - and variable adjustment Set - variable of presentation - startdate and same with Enddate.

    The report works well, but the report does not all records. I mean that I have given 12:04:36 am but report draws from 12:37:53 am. So, I'm missing some documents. I don't know where I am doing mistake.

    Could someone help me please

    Thank you

    Published by: 792011 on September 14, 2011 11:00

    792011 wrote:
    Hi gurus,
    I'm trying to get the Date of application for a Date column. This is the approach that I took from the previous post.

    Re: How to get the date of request for a date column

    My approach
    (1) in the report, I put the filter on the Date column with variable presentation as startdate with a date by default, and in the window of fx, I applied
    CASES WHERE 1 = 0 THEN the picture. Table of date ELSE. END date
    (2) I repeated the same thing by getting the same column with Variable presentation date as Enddate with a date by default and in the fx I applied
    CASES WHERE 1 = 1 THEN table. Table of date ELSE. END date
    (3) in the dash prompt, I had the same date twice column by applying the same formulas in fx, default sysdate - variable Server - and variable adjustment Set - variable of presentation - startdate and same with Enddate.

    The report works well, but the report does not all records. I mean that I have given 12:04:36 am but report draws from 12:37:53 am. So, I'm missing some documents. I don't know where I am doing mistake.

    Could someone help me please

    Thank you

    Published by: 792011 on September 14, 2011 11:00

    From what you say, as you did, it should not work. Investigation of the CASE, you have stage 1) and (2) that you put in the window fx in two columns, is indeed the same thing that just have two instances of your table. Date column.

    Follow the steps in this link and you should be good to go:

    http://oraclebizint.WordPress.com/2008/02/26/Oracle-BI-EE-101332-between-prompts-for-date-columns-using-presentation-variables/

  • Display of the data in a recordset object

    Hello

    I created a recordset and returns 6 rows of data when tested. These are products of a catalog online and I would like to do is show 6 products per page. I created 6 areas and added the data dynamically and what happens, is that the first row of data appears 6 times. Is it possible to display all rows on a page? I read "Recordset Paging and go to the next page" and I can get this working, but what I need is to display 6 products on one page. I use PHP and MySQL with Dreamweaver. No doubt it something to do with $mysql_num_row, but is there a simple way in Dreamweaver to do this? If not, anyone know the syntax of PHP to get this working?

    Hope you can help me.

    Concerning

    Nikki

    Wednesday, August 30, 2006 04:23:37 p, Nikki Cade wrote
    Macromedia.Dreamweaver.AppDev:

    > I created a recordset and returns 6 rows of data when tested.
    > These are products of a catalog online and I would like to
    > show 6 products per page. I created 6 areas and added the
    > data dynamically and what happens, is that the first line of data is
    > displays 6 times. Is it possible to display all the lines on one
    > page? I read "Recordset Paging and go to the next page" and I
    > can get this job, but what I need is to display 6 products on a
    > page. I use PHP and MySQL with Dreamweaver. No doubt it
    > something to do with $mysql_num_row, but is there a simple way
    > Dreamweaver to do this?

    Instead of 6 regions on a single page, put a single region and fill
    It is with the database fields. Then select the entire region, including
    any container and add a repeat region. Tell him you want 6 records by
    page. You can then add the Recordset paging.

  • After a time when the data added to the interface user blocked - WPF

    I am currently using WPF graphics.

    I have created a simulation that describes the problem that I have experienced in my application (attached).

    I have two sons, we generate data (in my application gets the material data every second) and the other copies the data in the user interface (copy the data to a variable, which bind to the data source).

    Every second I get 1000 points and adds them to the data. The first seconds it works well, after a while it gets stuck.

    I added a listbox control that displays the time, need to add the variable data and gradually increases.

    I have two questions:
    (1) did whenever I have add data, it attracts all the existing data again? If so, theres a way to improve or prevent this behavior?
    (2) how many points can represent the graph at a glance? (which is the limit of the graph)?

    Thank you

    HODAYA Shalom.

    Your example updated debugging, I think that the question is the Dispatcher.Invoke calls that you use to communicate with the user interface thread. Since you use the delegate only, all calls are sent with Normal priority, which means that events of low priority (as made graphic, or updated on day of data binding to scales) can get transformed. Using a lower as priority Render four Invoke calls not glued to the UI in my tests.

  • The distribution of applications and data between the disk SSD and HDD

    I recently installed an SSD in my Macbook Pro (late 2011) instead of the DVD player. I want to install OS X on it, by replacing the current OS X on the original hard disk, I will continue to use for storing files. How should I allocate its use in car? OS X and applications on the data files on the hard disk of 500 GB and SSD?

    The first series of instructions will partition and format the newly installed SSD disk then install OS X on it. The second block will help you configure OS X on the SSD with your data on the HARD drive.

    Clean Install of El Capitan on a new disc

    1. Restart the computer. Immediately after the chime, press Command + Option + R until a globe appears.
    2. The Utility Menu appears in 5 to 20 minutes. Be patient.
    3. Select disk utility, then click on the continue button.
    4. When loading disk utility, select the drive (generally, the entry Out-bumpy) in the list aside.
    5. Click the Partition tab in the main window of disk utility. A panel will fall.
    6. Set the GUID partition scheme.
    7. Define the type of Format Mac OS extended (journaled).
    8. Click on the apply button, then click the fact when it is active.
    9. Quit disk utility and re-enter the Utility Menu.
    10. Select reinstall OS X and click on the continue button.

    How to use an SSD with your HARD drive

    If you want to use an SSD as boot with your existing HARD disk drive, as the disk 'data', here is what you can do.

    After installing the SSD, you need to partition and format the SSD using disc utility disc. Then install OS X on the SSD. Once installed OSX boot from SSD. Startup disk preferences to set up the SSD as the boot volume.

    Open the preferences users and groups. Click the lock and authenticate you. Or CTRL - RIGHT click on your username account list in the sidebar and select Advanced Options in the context menu. You will see a field called "Home dir: ' on the far right, you will see an Edit button. Click on it. In the file dialog box, navigate to the location in house now located on the HARD disk (disk HARD/users/user_name /.) Select the folder, click the Open button. Restart the computer, as shown. When the computer starts, it will now use the home located on the HARD drive folder.

    Another more technical method involving the Terminal and the alias is discussed in depth here: using OS X with a SSD and HDD - Matt Gemmell configuration. It's my preferred approach because I can choose which records of the House, I want to on the HARD drive and I don't want to. For example, I like to keep Documents and library files on the SSD because I frequently access their content.

    Make sure that you keep the bootable system entirely on your HARD drive where you need it.

  • If an application does not forward on my new phone to iCloud, I lost all the data?

    I just upgraded my phone to a 5S for a SE.  They were both set to update to the latest version of the software.  I saved my 5S for my Macbook Pro before transferred its content to my new SE and erase the 5s.  I thought that all transfer ok, but I just noticed that one of my apps which has some important data on it has not transferred to the wire.  I still have backup on my laptop.  If it does not transfer the first time, she disappears somehow?  I could redownload the app, but I really don't like so much about the app.  It was the data stored in the application that concerns me. Is it possible to get it back?  The app was NotesPro, downloaded from the iTunes app store.

    It is important to understand that applications are not saved in a backup of the iOS.  The application data is saved.

    So if what you describe has happened to me, I would try the following:

    • Erase your iPhone SE and start over.  Settings > general > reset > erase content and settings and set up as new iPhone.
    • Keep in mind that NotesPro (mainly used to manage Lotus Notes) is an application very old.  It has been updated in 2009. which probably explains why this application behaves erratically.
    • Download NotesPro on your iPhone OS on the iTunes Store.  Once connected to your iPhone with your Apple ID, open the App Store, click on "Updates" in the lower right, then "Bought" on top.
    • Now restore your backup.  I hope that will restore the data from the application.  Restore your iPhone, iPad or iPod touch backup - Apple Support
  • my Apple Watch does not record the data of my activity on my iPhone. The application of the activity is implemented on my watch and twinned with phone and not yet to record data.

    my Apple Watch does not record the data of my activity on my iPhone. The application of the activity is implemented on my watch and twinned with phone and not yet to record data.

    HI - try the following steps:

    On your iPhone close application of activity and also, if it runs in the background, the health app (you can close open apps, including the app shows):

    -Double-click the Home button, and then drag upward on each of the app previews to close.

    It can help to restart your iPhone and your watch. Turn on both devices off the power together first, and then restart your iPhone before restarting your watch:

    -To switch off your watch: press and hold the button side until you see the cursor off the power; slide it to turn off;

    -To switch on: press and hold the side button until you see the Apple logo.

    If this does not resolve the problem, try next disconnect and rematching of your watch:

    -L'app shows on your iPhone shows backups automatically, including a new when the unpairing via the application.

    -Choose to restore the watch (backup restore) when provided the opportunity during the whole.

    -Most of the data and settings will be restored, with a few exceptions (for example cards Pay Apple, access code).

    - Pairing your Apple Watch and Support Apple - iPhone

    - Set up your Apple Watch - Apple Support

Maybe you are looking for