Compare dates between 2 different rows and columns

I'm having problems figuring this out.  Here is an example table:
What I need to be able to find is any records where the Discontinue_Date is greater than the Effective_Date on the next row for a given Customer ID and Part_ID.  This is a customer pricing table so the Discontinue_Date of row 53 for example should never
be greater than the Effective_Date of row 54130, these are the records I'm looking to find.  So I'm looking for a SELECT query that would look for any records where this is true.  Obviously the last Discontinue_Date row for a Customer_ID will not
have a next row so I wouldn't want to return that. 
Let me know if anyone has any ideas or if more clarification is needed, I've been struggling with how to get started on this!!
Thanks very much in advance!
JIM

>> I'm having problems figuring this out. Here is an example table: <<
NO! Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data
should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
This is minimal polite behavior on SQL forums. You pasted a colored picture that we have to transcribe into DDL to do your job for you. But you also do not know basic terminology! 
Rows are not records, since tables are sets, there is no “next row” concept, rows do not have physical row numbers, etc.  Your mindset is still in a spreadsheet and not RDBMS. 
>> What I need to be able to find is any records [sic] where the discontinuation_date is greater than the effective_date on the next row for a given customer_id and part_id. <<
Why not prevent bad data instead of trying to kludge and report it after the fact? 
 Consider this self-reference trick to prevent gaps in a timeline of events:
CREATE TABLE Events
(event_id CHAR(10) NOT NULL,
previous_event_end_date DATE NOT NULL
CONSTRAINT Chained_Dates
REFERENCES Events (event_end_date),
event_start_date DATE NOT NULL,
event_end_date DATE UNIQUE, -- null means event in progress
PRIMARY KEY (event_id, event_start_date),
CONSTRAINT Event_Order_Valid
CHECK (event_start_date <= event_end_date),
CONSTRAINT Chained_Dates 
CHECK (DATEADD(DAY, 1, previous_event_end_date) = event_start_date).
<< other stuff for this event >>
-- disable the Chained_Dates constraint
ALTER TABLE Events NOCHECK CONSTRAINT Chained_Dates
-- insert a starter row
INSERT INTO Events(event_id, previous_event_end_date, event_start_date, event_end_date)
VALUES ('Foo Fest', '2010-01-01', '2010-01-02', '2010-01-05');
-- enable the constraint in the table
ALTER TABLE Events CHECK CONSTRAINT Chained_Dates
-- this works
INSERT INTO Events(event_id, previous_event_end_date, event_start_date, event_end_date)
VALUES ('Glob Week', '2010-01-05', '2010-01-06', '2010-01-10');
-- this fails
INSERT INTO Events(event_id, previous_event_end_date, event_start_date, event_end_date)
VALUES ('Snoob', '2010-01-09', '2010-01-11', '2010-01-15'); 
Since you did not write DDL for us, you can use this idiom to get a working schema. 
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • How Calculate more than one value and store it into to different rows and column for each input?

    thx guys.....i have a progress now in LV
    But now i have new trouble here. Ok i attached my LV file (LV 7.0.1/7.1) and excel form. I just could'nt calculate more than one input value. I want a different result for each value that i enter ... and store it into different rows and column. But it just store at one row.
    Attachments:
    My Project.vi ‏31 KB
    rumus motor bakar.xls ‏14 KB

    duplicate post

  • Different Rows and Columns property in data forms

    I have a Planning data form. I have one dimension in Row and another in Column. The Column dimension has percent (%) property and the row column has Dollar ($) value property. How the cell value will be displayed? What will be cell property?

    I am glad you asked that :) I started writing blogs few days back, this is the first post of my blog, you can have a look, might help you. I actually needed few more days to post few more threads before I make it public....but anyway... here you go..!!
    http://blogs.oracle.com/HyperionPlanning/entry/evaluation_order
    Cheers..!!!

  • Data format in rows and columns

    I have a table and have the following data,I need to transpose int he required form.
    The number of rows are dynamic and i dont want decode and string concatenation.
    1     Tamil     1     1000
    2     English     2     2000
    3     Hindi     3     3000
    4     German     4     4000
    5     Telugu     5     5000
    o/p
    tamil english hindi german telegu
    1 2 3 4 5
    1000 2000 3000 4000 5000
    The first column values will become the heading and all other corresponsing rows will become the column values
    Kindly reply ,,Thaks in advance

    how about this
    assuming you've implemented the stragg function (see ask tom if not)
    of course you can always use sys connect by path to roll the column values up into a single entry.
    anyway use stragg or sys connect by path to get all the colum values into a single entry seperated by commas
    col1 col2 col3
    Tamil,English,Hindi,German,Telugu 1,2,3,4,5 1000,2000,3000,4000,5000
    next I used the model clause to take the three columns one row construct
    and change it to one column 3 rows so now the result set looks like this
    col1
    Tamil,English,Hindi,German,Telugu
    1,2,3,4,5
    1000,2000,3000,4000,5000
    finally I appended a comma to the end of each row and parsed through it pulling out the text between columns
    here is the whole thing...... again for this to work you need to have implemented the stragg function else you'll have to change to sys connect by path.
    select col4 StraggedValues,
    substr (col4, 1, instr(col4,',',1) -1) col1,
    substr (col4, instr(col4,',',1)+1, instr(col4,',',1,2) - instr(col4,',',1)-1) col2,
    substr (col4, instr(col4,',',1,2)+1, instr(col4,',',1,3) - instr(col4,',',1,2)-1) col3,
    substr (col4, instr(col4,',',1,3)+1, instr(col4,',',1,4) - instr(col4,',',1,3)-1) col4,
    substr (col4, instr(col4,',',1,4)+1, instr(col4,',',1,5) - instr(col4,',',1,4)-1) col5,
    substr (col4, instr(col4,',',1,5)+1, instr(col4,',',1,6) - instr(col4,',',1,5)-1) col6,
    substr (col4, instr(col4,',',1,6)+1, instr(col4,',',1,7) - instr(col4,',',1,6)-1) col7
    from (
    with a as
    select stragg(col1) strCol1, stragg(col2) strCol2, stragg(col3) strCol3 from
    select 1 rn, 'Tamil' col1, 1 col2, 1000 col3 from dual union
    select 2 rn, 'English' col1, 2 col2, 2000 col3 from dual union
    select 3 rn, 'Hindi' col1, 3 col2, 3000 col3 from dual union
    select 4 rn, 'German' col1, 4 col2, 4000 col3 from dual union
    select 5 rn, 'Telugu' col1, 5 col2, 5000 col3 from dual
    select col4||',' col4 from a
    model
    return updated rows
    dimension by (0 d)
    measures (strcol1, strcol2, strcol3, 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' col4)
    rules iterate (3)
    col4[iteration_number + 1] = case iteration_number
    when 0 then strcol1[0]
    when 1 then strcol2[0]
    when 2 then strcol3[0]
    else null end
    )) b

  • How to compare data between two tables?

    Hi,
    My team is trying to develop a SAP data migration tool (DMT) using ABAP.
    One of the functionalities in the DMT is to validate the data in the staging area against the loaded SAP data.
    The tables in the stagin area are customer tables (i.e. user-defined tables starting with Y, Z).
    How do I compare the data in the staging area against data that are loaded into SAP tables? Are there some built-in SAP functions to do this? Or, are there some better ways of doing this (e.g. instead of comparing against data in the SAP tables, we compare with some INTERNAL tables)?
    Any help would be greatly appreciated, thanks!

    Hi Kian,
    Use <b>SCMP</b> transaction to compare data between two tables and you can not use this for comparing internal tables.
    Thanks,
    Vinay

  • How to compare date between 2 file?

    hi there...
    is there any possibility to compare date between 2 file and the file that is latest to open?
    thank you

    i need help urgently..... i type tis code
    <%
    String file = ("C:/");
    File f = new File(file);
    String [] fileNames = f.list();
    File [] fileObjects= f.listFiles();
    %>
    <UL>
    <%
    for (int i = 0; i < fileObjects.length; i++) {
    if(fileObjects.lastModified()){
    %>
    <LI>
    <a href="<%= fileNames[i %">"><%= fileNames[i] %></A>
    <%
    %>
    my purpose is to list out all the file in the folder but not to the user just for the system to check all the files than when i click a link it will open the latest file
    Message was edited by:
    n_dilah</a>

  • Maximum number of rows and columns in data form

    Hi,
    I wanted to know if there is a limitation to the number of rows and columns that can be displayed in a data form, in Hyperion planning 11.1.2.1 ?
    And what would be the most appropriate number of rows and columns to be included for optimum performance.
    Thanks.

    Hi,
    While its a fun fact to determine how much one can stuff into a web form, the reality is: how much can a user reasonably consume in a web form?
    And what would be the most appropriate number of rows and columns to be included for optimum performance
    You will find that the answer to this is by "what design makes a web form most usable?" And no, the users don't really know what they want from a design perspective, they see it in their head, but usually what they ask for is something that would look entirely different (huge).
    The next thing to think about is the use of member selection functions in the page axis. IDescendants(Entity) in a dropdown could cause issues just as easily as too many rows - and again make the drop down unusable for a user.
    If your question is a bit more technical, then consider this (somewhat oversimplified): Web forms are constructed by a process on the server. Objects are created based on the form's definition and used by the process that builds the form. The process uses Cartesian looping (lots of iterations) to construct the form cell by cell, starting at the top left and finishing up in the bottom right. If the form has a million cells on it, then the loop and all the code within it runs a million times. The capability of the server has a lot to do with how well it can handle this request, and how many it can handle at one time.
    The result of this is gobs of HTML and JavaScript. All of this has to be sent over a network to the requesting client. The client starts receiving the web page code and has to render it in the browser and run the JavaScript. The ability to do this is limited by the browser, the OS, and the hardware that the client is running on.
    And that's just rendering the page for use.
    Now it has to be interacted with on the client machine, and changes parsed, packaged, and sent back to the server.
    So the technical answer is, there can be many limitations to how many rows and columns a data form can have - none of which can truly be anticipated by anyone. This is why I put the part about usability first in this post.
    Regards,
    Robb Salzmann

  • How can i open a PDF bank statement in numbers so that the rows and columns contain properly aligned data from statement?

    how can i open a PDF bank statement in "numbers" so that the rows and columns contain properly aligned data from statement?

    Numbers can store pdfs pages or clippings but does not directly open pdf files.  To get the bank statement into Numbers as a table I would open the bank statment in Preview (or Skim) or some pdf viewer.
    Then hold the option key while selecting a column of data.
    Then copy
    Then switch to numbers and paste the column into a table
    Then repeat for the other columns in the pdf document
    It would be easier (in my opinion) to download the QFX or CSV version from your bank

  • Row and Column Formulas on a Data Form

    I am creating a data form which has both row and column formulas. I would like the row formulas to show for some of the cells but it seems to default to the column formula.
    How can I get my form to show the row formula result and not the column formula result?
    Thank you!

    Brian,
    See this example:
    http://htmldb.oracle.com/pls/otn/f?p=31517:160
    There are also a coupleof others showing the same thing you want to achive.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Rows and column limit on Data Grids

    Hello,
    anyone know if there's a limit for the number of rows and columns per page in the Data Grids?
    Thanks in advance

    There is not a limit. There is a default of 1024 rows, but you can change this.
    -- Chris

  • Exporting data in rows and columns and loading in RDBMS

    <p>I have a scenario wherein i want to export data from HyperionEssbase in <b>rows and coulmns</b> and <b>load it into</b><b>RDBMS</b>. I can load data into RDBMS using informatica if theflat file exported is in form of rows and columns.But when i exportthe file using Hyperion Essbase 9 i get it in from of alldimensions and then the fact value which is not how i want. I wantdata in relational from in flat file itself(row,column).</p><p>Looking forard to your suggestions..Thanks in advance..</p>

    <p>Thanks <b>willjordan</b> and <b>twakim</b> for yoursuggestions..</p><p> </p><p>I tried both the techniques and both worked...</p><p>With reference to the technique suggested by <b>twakim</b> , I was able to use that in Hyperion Essbase 9..But in myreal scenario the cube is in Hyperion Essbase 6.5.4.2..Can i usethis Custom defined functions in Hyperion Essbase 6.5.4.2..and ifso how as there is no concept of Analytical server there???</p><p> </p><p>Please help me in this issue???<br></p>

  • How to display 2 dimensional data. i.e with rows and columns?

    Hi,
    I want to know how to display multiple, variable
    rows and columns that are got from the database through
    queries in forms.
    (i,e. a Matrix of Values,something similar to an Excel Spreadsheet).
    Is there a component in forms similar to JTABLE that is
    available in Java through which MULTIPLE, VARIABLE
    rows and columns can be displayed ?.
    I am not using a base table since this data is got thru
    a number of packages and procedures that are used in
    Loops.
    NOTE : I am using forms 6i.
    Thanks
    Sharath.

    I've heard Grant mention adding a Grid component to the Forms toolbox. From the context I would guess this is not yet even under development, so it's not going to be available anytime soon. And not for 6i.
    Sorry, APC

  • How to save data from JTable multiple rows and columns

    Hi Y_Not thanks for your help before...
    But what should I do if I want to get/save many data from many column and rows??

    i don't quite understand your (repeated) question. what is the problem with "multiple rows and columns". Y_NOT and i have shown you ways to access them.
    all you need are 2 loops: one around your number of rows and one around the number of columns or vice versa depending in which order you want to save things:
    for (int col = 0; col < data.size(); col++) {
        for (int row = 0 ; row < data[col].size(); row++) {
            // save your data
            saveData(data[col].getElementAt(row));
            // or use yourtable.getValueAt(row, col);
    }this is not a problem of Swing/Java but of simple algorithm...
    thomas

  • Suppress Overall result (both rows and columns side and its data)

    Hello all,
    I need to do some settings in BEx Query Designer, so that In BEx Analyzer, I don't see 'overall result' both on 'rows' and 'column' sides
    This is what I have done so far
    In 'rows' section, Properties of my KF (no. Products) then 'calculation' tab 'calculate result as'=Suppress result
    This way in BEx Analyzer I don't see the FIGURES/DATA for 'Result' and 'overall result' BUT 'result' and 'overall result' still exist both on rows and colum side even if there are not figures in them.
    Is there any property in BEx Designer so that I don't see 'overall result' at all
    Best regards
    Ahmad

    thanks for responding
    selecting a characteristic, properties, Display tab, Result lines: Always Suppress
    with this I don't see 'result'
    but 'overall result' result exist both on 'rows' and 'column' side alongwith its data.
    If I combine the above with this: selecting KF, properties, calucations, Calculate result as: Suppress result
    then
    I don't see the data in 'overall result' BUT 'overall result' still exist both on rows and column sides
    any setting so that 'overall result' completely vanishes
    Best regards
    Ahsan

  • Multiple Rows and Columns selection on ALV

    Hi all,
    What is the best solution to allow the multiple selection or combination of selection (rows and columns) on an ALV ?
    I would like to be able to select some rows and some columns and to get the result cells in order to update them.
    Thanks in advance for your help.
    David

    Thanks Srinivas and Seela,
    I forgot to precise that my ALV is dynamic, I used the method 'add_new_child_node'.
    I tried the different possibilties with method attributes but I don't find the good attributes combination to allow columns selection.
    I add also that I have to be able to select several no adjacent columns.
    What do you think about this workaround :
    Is it possible to add a line on my ALV with checkbox between the header line (with column title) and data line.
    I will search using the method add_cell_variant but I don't know if it's possible with dynamic ALV.
    Thanks.
    David

Maybe you are looking for