Find data between certain values

Hello world

I need help with the script below.
CREATE TABLE BILL_TBL
  (
    "CUSTOMER_ID"       NUMBER(18,0),
    "BILL_ID"           NUMBER(18,0),
    "BILL_ISSUE_DATE"   DATE,
    "BILL_DUE_DATE"     DATE,
    "BILL_DUE_AMOUNT"   NUMBER(20,5),
  );
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,143787012,to_timestamp('12/09/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('12/10/2011','DD/MM/RRRR HH24:MI:SSXFF'),0);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,147279454,to_timestamp('12/10/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('12/11/2011','DD/MM/RRRR HH24:MI:SSXFF'),0);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,161587732,to_timestamp('12/02/2012','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('12/03/2012','DD/MM/RRRR HH24:MI:SSXFF'),2.05);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,150481573,to_timestamp('09/11/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('09/11/2011','DD/MM/RRRR HH24:MI:SSXFF'),0);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,153076866,to_timestamp('01/12/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('01/12/2011','DD/MM/RRRR HH24:MI:SSXFF'),0);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,156547549,to_timestamp('30/12/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('30/12/2011','DD/MM/RRRR HH24:MI:SSXFF'),0);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,150793135,to_timestamp('12/11/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('12/12/2011','DD/MM/RRRR HH24:MI:SSXFF'),58.38);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,159764979,to_timestamp('24/01/2012','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('24/01/2012','DD/MM/RRRR HH24:MI:SSXFF'),0);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,154467859,to_timestamp('12/12/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('12/01/2012','DD/MM/RRRR HH24:MI:SSXFF'),0);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,157241037,to_timestamp('05/01/2012','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('05/01/2012','DD/MM/RRRR HH24:MI:SSXFF'),0);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,158065763,to_timestamp('12/01/2012','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('12/02/2012','DD/MM/RRRR HH24:MI:SSXFF'),0);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (100,123456721,to_timestamp('13/05/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('13/06/2012','DD/MM/RRRR HH24:MI:SSXFF'),123.12);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (100,123456722,to_timestamp('13/03/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('13/04/2012','DD/MM/RRRR HH24:MI:SSXFF'),144.12);
Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (100,123456723,to_timestamp('13/01/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('13/02/2012','DD/MM/RRRR HH24:MI:SSXFF'),4.12);
The query must sort by customer_id, bill_issue_date desc as give below, that retrieves records in which the bill_due_amount is between group by CUSTOMER_ID 0

examples of data
CUSTOMER_ID     BILL_ID           BILL_ISSUE_DATE      BILL_DUE_DATE     BILL_DUE_AMOUNT
100              123456721        13/05/2011      13/06/2011      123.12
100              123456722        13/03/2011      13/04/2011      144.12
100              123456723        13/01/2011      13/02/2011      4.12
3115166              161587732     12/02/2012     12/03/2012     2.05
3115166              159764979     24/01/2012     24/01/2012     0
3115166              158065763     12/01/2012     12/02/2012     0
3115166              157241037     05/01/2012     05/01/2012     0
3115166              156547549     30/12/2011     30/12/2011     0
3115166              154467859     12/12/2011     12/01/2012     0
3115166              153076866     01/12/2011     01/12/2011     0
3115166              150793135     12/11/2011     12/12/2011     58.38
3115166              150481573     09/11/2011     09/11/2011     0
3115166              147279454     12/10/2011     12/11/2011     0
3115166              143787012     12/09/2011     12/10/2011     0
Presents the expected results
CUSTOMER_ID     BILL_ID          BILL_ISSUE_DATE     BILL_DUE_DATE     BILL_DUE_AMOUNT
3115166         150793135        12/11/2011      12/12/2011          58.38
Any help will be appreciated. Thanks in advance
select CUSTOMER_ID, BILL_ID, BILL_ISSUE_DATE, BILL_DUE_DATE,BILL_DUE_AMOUNT from (
select CUSTOMER_ID, BILL_ID, BILL_ISSUE_DATE, BILL_DUE_DATE,BILL_DUE_AMOUNT,
lag(BILL_DUE_AMOUNT) over(partition by CUSTOMER_ID order by BILL_ID desc) b,
lead(BILL_DUE_AMOUNT) over(partition by CUSTOMER_ID order by BILL_ID desc) a
from testdata)
where a = 0 and b = 0
and
nvl(BILL_DUE_AMOUNT,0) != 0

Tags: Database

Similar Questions

  • Adjustment brush works incorrectly between certain values of the brush size

    I am running Windows 7 64 bit on my PC with Lightroom 4.4.  When I resize my adjustment brush cursor by using the wheel of scrolling between certain values the brush cursor changes shape to the usual circular slider for a semicircular slider crushed. Below certain levels, the brush changes from the circular single slider to two small sliders and values less than four small sliders.  Can anyone help. My usual mouse is a Dell USB with scroll wheel and my keyboard is a Microsoft multimedia keyboard.

    I tried the following to any available-

    Re starting lightroom

    Check the BIOS to USB mouse is on

    I've tried different mouse (manufacturers)

    Any suggestion would be appreciated

    Mick Norman

    Hi snowynorman,

    Could you please share a screenshot of your adjustment brush in Lightroom?

    Usually, two circles appear when you have a good pen of value.

    In addition, suggest you try to change the size of the brush manually via the cursor or up and down arrow keys on your keyboard to check if you still see this type of behavior.

    Kind regards

    Claes

  • Find Dates between 2 dates

    Hi all

    I use SOASuite 11 g. Using XSLT, I want to find some dates between 2 dates

    For example, if I input 01-02-2016 and 2016-02-07


    The XSLT must return

    2016-02-01,.

    2016-02-02,.

    2016 02-03,

    2016 02-04,

    2016 02-05,

    2016 02-06,

    2016 02-07


    can someone suggest me how to build this logic in the xslt file?


    Thank you

    (1) fn:days - of-life feature gives you the difference in days between two dates.

    (2) use the value above in the foreach loop and then create a counter variable and map it to element position().

    (3) now use this counter variable in the Sub method within the loop for.

    xs:date(fromdate) + xs:dayTimeDuration(concat('P',$counter,'D'))

    (4) you can now print this value (or) copy it to a repetitive Xml structure element. When copying, you can use the $counter as an index for the repetitive element of the target.

    Now if you want including and to the dates too, then add 1 to the output in step 1 and step 3 use $counter - 1 in xs:dayTimeDuration.

    It will be useful.

  • Pass data between applications value reference

    The issue is that data application reference value is local to the application instance, or can be transferred between different applications.

    I have a main application that acquires the table of 100 MB and I need to use these data in a dll. Obviously, I don't want to send table, reference would be better. Both applications are generated in labview 2011.

    The second question is whether reference data value can be converted to a string (type cast or flatten to a string) and back. For example with DAQmx tasks flatten to a string does not work.

    Alexander_Sobolev wrote:

    It's value application data reference is local to the application instance.

    Yes.

    or may be transferred between applications.

    Laughing out loud

    The second question is whether reference data value can be converted to a string (type cast or flatten to a string) and back.

    Yes, but only means something in the app instance appeared to reference.

    You will want to perhaps give more details on what are your real needs, but keep in mind that play with memory directly in LV is not so simple, as he does all he can to hide these details you.

    If you pass a pointer to an array to a DLL, you can configure the DLL for this call. If you want to get an accurate picture of LV in memory address and passing around, this isn't something LV supports and you shouldn't do that because the memory should not be controlled by more than one master at any time in time.

    LV has functions of memory allocation and to get the pointer back, but requiring explicit calls.

    Anyway, I have no real experience with this. If you want to read materials, there are at least two users here with much more knowledge on the subject and you can go through their messages or search and filter for their post - rolfk and nathand.

  • Find dates between 2 dates given

    Hello

    I want to write pl/sql block that will give me the dates between 2 dates that I entered. Are there any oracle in built function that does. I use version oracle 11g rel2.

    We know not what you want, but it looks like:

    SQL> select  &start_date + level  - 1 dt
      2    from  dual
      3    connect by &start_date + level  - 1 <= &end_date
      4  /
    Enter value for start_date: date '2012-08-01'
    old   1: select  &start_date + level  - 1 dt
    new   1: select  date '2012-08-01' + level  - 1 dt
    Enter value for start_date: date '2012-08-01'
    Enter value for end_date: date '2012-08-31'
    old   3:   connect by &start_date + level  - 1 <= &end_date
    new   3:   connect by date '2012-08-01' + level  - 1 <= date '2012-08-31'
    
    DT
    ---------
    01-AUG-12
    02-AUG-12
    03-AUG-12
    04-AUG-12
    05-AUG-12
    06-AUG-12
    07-AUG-12
    08-AUG-12
    09-AUG-12
    10-AUG-12
    11-AUG-12
    
    DT
    ---------
    12-AUG-12
    13-AUG-12
    14-AUG-12
    15-AUG-12
    16-AUG-12
    17-AUG-12
    18-AUG-12
    19-AUG-12
    20-AUG-12
    21-AUG-12
    22-AUG-12
    
    DT
    ---------
    23-AUG-12
    24-AUG-12
    25-AUG-12
    26-AUG-12
    27-AUG-12
    28-AUG-12
    29-AUG-12
    30-AUG-12
    31-AUG-12
    
    31 rows selected.
    
    SQL> 
    

    SY.

  • find data between specific times in a date range

    HII all,.
    I'm pretty new in PL/SQL so any help will be greatly appreciated. I'm trying to retrieve data from a set of tables. one of these tables has a field that is a timestamp in the format «dd/mm/yyyy hh24:mi:ss» field asked me to produce data for records that were created between 16:00 and 20:00 between 01/01/2010 and 31/08/2010. I can eat the date of issue, but the question of time is that I'm stuck.

    your help would be appreciated
    SELECT *
    FROM my_table
    WHERE col_date BETWEEN DATE '2010-01-01' AND DATE '2010-09-01'
    AND TO_NUMBER ( TO_CHAR ( col_date, 'HH24MI' )) BETWEEN 1600 AND 2000;
    

    Now something difficult:
    A DATE data type represents a specific time. It's something abstract. There's no format. It is in some cases stored internally, but we know not how (in fact, we know a little). Cannot directly display a DATE value - it is not a text, it is a point in time, it can be established on a calendar and a clock, but not on the screen. DATE FORMAT allows us to tell Oracle how we want it to be converted into a string and displayed. Do we want to day/month/year or year/day/month? Do we want a 24 hour clock 12-hour am/pm or? The same value, the same point in time can be displayed using different channels, produced using different DATE FORMATS. "Friday, September 17, 2010 13:15" is exactly the same point in time as "2010-09-17 13:15" - the only difference is the FORMAT. This allows us to perform several clever tricks with DATE data. Ok?
    (If you do not specify a DATE format, and then there are the values by default for your session and for the database. But the principle remains the same: a point-in-time value is converted to a string using the DATE FORMAT).

  • time data between extraction using the database

    Hello

    I do datalogging with data 1 min interval, the logg data upward at 3 days, was preparing I use sql server, now I can't able to insert and extract data also plenty fast.  but I need to recover the data in the time specified and also a lot of wise.  could you tell me how to implement this?

    I downloaded a few vi ni.com, but his does not work...

    send me if possible example vi

    Hi DP Baro,

    See this link please

    http://vyaskn.tripod.com/searching_date_time_values.htm

    It shows how you can find date and time values. You can combine them. I don't really know if you can solve the interval of 5 minutes with her, but you can get definitifly the beach, you need. You can then filter the latest data in LabVIEW.

    See also this link for your second question

    http://www.mssqlcity.com/articles/compare/sql_server_vs_access.htm

    Mike

  • Pass data between panels

    I have a digital slide on a Panel. When I move the cursor, I need the value update on another Panel.

    How can I do this?

    The two panels are loaded as a senior-level windows.

    It seems that I read something on the use of queues to pass data between the panels, but I can't seem to find where I read that.

    A basic concept that differentiate the CVI to other languages, it's that there is no relationship between a sign and a specific source file. I mean, you do not need to put a sign functions in a specific source file: they can be spread over multiple sources; Conversely, you might have a source only that collects reminders for all panels of files in your application. What readers recall execution are Panel handles and control ID. (One effect of this paradigm is, you might have a reminder installed on controls on different panels).

    For this reason, there is no problem by putting the cursor callback in panel1.c. In addition, you can call the file source in a different way.

    Arriving at the base of your problem, a DAQ multithreaded application is really different from a UI single-threaded application.

    Put the functions of data acquisition in a separate thread can be beneficial for your application, because they are not likely to suffer user interface events.

    CVI provides also the different methods of transmission of data between threads. the most powerful in data acquisition applications is probably a Thread Safe queue.

    I suggest you look at Programmer's Reference > chapter of the creating multithreaded Applications to aid, where the basic principles of programming are explained multithreaded and information are provided on all instruments CVI includes.

    If you want to discuss on this scenario, I suggest yu to start a new thread, as it has nothing to do with the original question with which you started this discussion.

  • Problems of access to data between threads

    I have a singleton who has a painting I want to access it from multiple threads.  I set the table as volatile and initialize it to certain values when you create the singleton.  When my application starts, I create a thread that periodiclly checks that the user made and adds values to the table.    I have a screen displaying, it lists all values in this table.  The wire and the screen become two different instances of singleton.  Entries added in the thread do not appear on the screen.  Any time, the display shows it shows what the table is when the object is first.  When I debug this, all calls the screen makes the get the array of the result singleton in it being created.  Is not possbile to share data between threads?

    Here's how to create the instance on the singleton:

    private static volatile DataAccess instance = new DataAccess();

    I created a simple java file that creates three threads and uses the same object that I use in the blackberry app and everything works fine.  Is there something particular aboue screens that makes them not nice game with wires?

    Thanks for your suggestions.

    runtimestore is used for exactly that. I don't know of another way to share. You can communicate using world events and have other options, but runtimestore is the easiest.

  • Essbase Warning (1023135) skip certain values for the replication

    Hello

    When you replicate the complete data of a partition Essbase BSO in Essbase ASO (11.1.2.2),
    thousands of warning messages are logged in the application log:

    "Warning (1023135) skip certain values for the replication.

    The partition (data of level 0) valid and the counties of cells in each area are exactly.

    No idea of the possible causes and consequences?

    Thanks for your help.

    Philippe Cuisset

    Hello

    Thanks to the contributors.

    The contours of the source and the corresponding target, with the exception of 3 members with different names in the source and target.
    My score has 2 spaces for these 3 members. Mapping advanced between the names of source and target members has been set in a field, but it was missing in the other (not detected by the validation of the partition!). I don't set it too and now no more warnings.

    Philippe Cuisset

  • Count the number of records between two values of keys (BTREE)

    How can I count the number of keys between two values?

    I use python driver and BTREE access method.

    = >

    Ideally, what I want is a set of whole time series data (intervals may change) to a given number of points on average. The keys are timestamps and the values are the data that it takes on average. I need to count the number of records between two timestamps so that I can divide this figure by the number of points I need and data on average. What is the best way to do it?  Or should I keep the timestamp constant intervals and use the RECNO access method?

    Thank you
    (first post btw... and why is there not a lot of people at stackoverflow that answering the questions of Berkeley DB?)

    BDB is an integrated db and there no internal counters or statistics you might grap to use for this.    You will have to do it manually.

    You can create a cursor, grap the records you want, whenever you get the next card that you bump a counter.

    If you are using RECNO, you can use a slider to obtain the number of registration (DB_GET_RECNO), and if all that you data is in

    sequentail records with no missing documents, you can find the total number of take the last rec #-original rec # + 1 to get a count.

    If you pass the SQL API, you can issue a SQL query to give you a count.  Select count (*) where...

    As you enter the data anyway, so better perhaps to count records as you go along.

    Thank you

    Mike

  • Date between Clause

    Hi all
    I have a dashboard for the date prompt(assume D_Date). I want to apply the date as xDate filter > = D_Date and YDate < = D_Date.

    Please help me I am unable to find a way to do this.

    Rahul

    Hello Rahul,

    For the column in the command prompt:

    Choose between the operator and control that the calendar. By which the user can select the date between a range value.

  • Share data between a PC host and NEITHER sbRIO-9626 connected by Ethernet


    Hi Sophiec,

    In fact, shared Variables are a good way to share data between a host and a target. However, this is not the only way for data sharing.

    On the follow-up document, you will find different ways to do it: http://digital.ni.com/public.nsf/allkb/48D244EC86971D3986256BD4005CCC28 as:

    Shared variables
    TCP
    UDP
    DataSocket
    Other methods of Communication

     

     

    I hope this will help!

     

     

  • Take the time between two values

    Hi people,

    I have a problem and I know idea how to solve... I need help.

    The problem is I want to take the time between two values max as you can see in the chart.

    For example, in the image that I have add

    4.5 - 1 840 = 2.66

    And enter this value in the 'time between mostra '.

    It's that I want...

    But what I think is very complicated, because I don't know how to take the time correctly and does remove...

    Thank you very much

    Any solution?

    Hi jocuma,

    I tried something and hope that helps u.

    Just create two arrays of temperature and voltage. First of all, I'll get the value of the voltage when it is more of a certain value and that same index to get the value of time and store in the shift register.

    When I get the second higher than the limit value, I'll get time and subtract the previous value.

  • Financial statement for line above a certain value

    Hello

    How can I do for the analysis of an array of strings of x and are data and output the line containing the data exceeding a certain value. I have attached a vi that I started to work on, but don't know how to do for x and y of output data above - 80.

    Any help will be greatly appreciated.

    Thank you

    hiNi.

    LV82.

Maybe you are looking for