IFF select all lines satisfy the condition

Hello

I am not able to understand how to go about this requirement of mine. I use APEX 3.1.

I have a table of expiration dates. I want to select only the company_id, all with dates were expired (to_date(sysdate,'DD-MON-YY') < = to_date(expiration_date,'DD-MON-YY').)

Table:

table_id | COMPANY_ID | correspondents

1. 2. 10 APRIL 09
2. 3. 10 APRIL 09
3. 2. AUGUST 10, 10
4. 1. 10 APRIL 09
5. 1. 10 APRIL 09

power required:
table_id | COMPANY_ID
2. 3
4. 1
4. 1

Thank you
Monpetit

Published by: user11267485 on August 18, 2009 11:31

Published by: user11267485 on August 18, 2009 11:32

Frank & I posted two queries return the expected results for the data set, that you posted.

SQL> ed
Wrote file afiedt.buf

  1   with x as (
  2     select 2 table_id, 2 company_id, date '2009-04-10' exp_date from dual
  3     union all
  4     select 1226, 2, date '2010-08-06' from dual
  5     union all
  6     select 1265, 1348, date '2009-04-09' from dual
  7     union all
  8     select 1266, 1348, date '2009-04-09' from dual
  9   )
 10   select table_id, company_id
 11     from (select table_id,
 12                  company_id,
 13                  max( exp_date ) over (partition by company_id) last_exp_dat
e
 14             from x)
 15*   where last_exp_date < sysdate
SQL> /

  TABLE_ID COMPANY_ID
---------- ----------
      1265       1348
      1266       1348

Are you sure that the data in your table are all of the years 2009 and 2010? You post only here two-digit year. I bet if you look at the full 4-digit year that you will eventually discover that TABLE_ID 1226 has an expiration date of August 6, 0010, i.e. approximately 1999 years.

Justin

Tags: Database

Similar Questions

  • Interactive report select all lines

    I have an I / R report that a user can select the columns, and then update > 1 rank a moment with the other page element values.
    I SELECT ALL and CLEAR ALL buttons page.
    The report runs slowly, due to a very complicated sql statement.

    I'm trying to select or clear the column 1 without the 'submission' of the page and re-run the 'slow' report again.
    At present, the SELECT ALL:
    (1 submits the page 2) sets Pxx_SELECT_ALL_ROWS = 'Y' 3) reruns the report with a decoding 'control' of all lines.

    Is there a way to do this WITHOUT submitting the page?

    The box is column 1 of each row by using:
    HTMLDB_ITEM. CHECKBOX
    (1, R.RESEARCH_ID,
    decode (: Pxx_SELECT_ALL_ROWS, 'Y', 'CHECKED',)
    decode (instr (nvl (:Pxx_SELECTED_IDS,0),R.RESEARCH_ID),0,NULL,'CHECKED'))
    )
    AS select_flag,

    Use * $f_CheckAll * JavaScript API

    Just run this JavaScript to check all your column f01

      $f_CheckAll('', true, $('input[name="f01"]'));
    

    OR create a JavaScript function

    function checkall() {
       $f_CheckAll('', true, $('input[name="f01"]'))
    }
    

    Call this function in your button with URLS of the target type and URL value javascript:checkall();

  • Selection of lines with the range Paging VO

    Hello

    JDev 11.1.2.4

    I created a VO based on an OA. I added a transitional attribute in the original Version, this attribute is named Selelected of type Boolean initialized to false (default value Expression: false-Expression of Refresh value: false). That VO appears as an af:table. The attribute is displayed as selectBooleanCheckbox. The VO is set with an access mode of range Paging and a size of 28.

    < af:selectBooleanCheckbox value = "#{row.bindings.Selected.inputValue} '"

    label = "#{bindings." VwRhdPortfolioTranWrkSend11.hints.Selected.label}.

    required = "#{bindings." VwRhdPortfolioTranWrkSend11.hints.Selected.mandatory}.

    shortDesc = "#{bindings." VwRhdPortfolioTranWrkSend11.hints.Selected.tooltip}"id ="it1' autoSubmit = 'true '.

    valueChangeListener = "#{pageFlowScope.portfolioTransferBean.onWorkSelection}" >

    < f: validator binding="#{row.bindings.Selected.validator}"/ >

    < / af:selectBooleanCheckbox >

    The table shows the 25 lines. The user clicks one of the checkbox to select a line. The valueChangeListener is called with the new value (auto submit = true) as expected. Then the user scroll down for another "page" in the table, new lines are displayed. Then it scrolls to the first page. The previous selected checkbox is reset as not selected. The selection is lost.

    Is this expected behavior? If so how do you get a selection of lines with a VO of range paging.

    Thank you

    Try to create the transitional attribute in OT instead of VO.

    See you soon

    AJ

  • Call javascript function when select all is checked the report

    Hi Experts

    Ive a tabular manual from query below

    SELECT Apex_item.checkbox (1, ID, 'onclick = enableButton ()') select, a, b, c of table

    By choosing 1 or more checkbox individually, enableButton() is called, and works very well as expected

    However when select all is done, I do not know how to call the same function

    Position of column select is: < input type = "checkbox" onclick = "$f_CheckFirstColumn (this)" / > (topic is a checkbox, check, selects all rows in the report) "

    I tried: < input type = "checkbox" onclick = "$f_CheckFirstColumn (this)" onclick = "javascritp:enableButton(); "/ >. It does not help

    Is it possible to call the function when select all is checked?

    Thank you

    Archana

    I changed the title of the

    This solved my problem.

    Thank you

  • Select all lines under a special value of columns... Help.

    Hello

    Sorry for posting my query again...

    Knani replied, but I have little more to change out put...


    Table structure:
    CREATE TABLE T_20 (CONTROL NUMBER(10) NOT NULL,
                           PO NUMBER(10) NOT NULL,
                           AMENDNO NUMBER(3) NOT NULL,
                           FACTOR VARCHAR2(3) NOT NULL,
                           COMMENT_X VARCHAR2(40),
                           FLAG VARCHAR2(1))
     
     
    SQL> alter table t_20 add constraint t_20_pk primary key (control, po, amendno, factor);
    INSERT orders:
    SQL> INSERT INTO T_20 VALUES(101,1000,01,'MSC','NO COMMENT','Y')
      2  / 
     
    1 row created.
     
    SQL> INSERT INTO T_20 VALUES(101,1000,02,'MSC','NO COMMENT','Y')
      2  / 
     
    1 row created.
     
    SQL> INSERT INTO T_20 VALUES(101,1001,00,'NDP','NO COMMENT','Y')
      2  / 
     
    1 row created.
     
    SQL> INSERT INTO T_20 VALUES(101,1001,01,'NDP','NO COMMENT','Y')
      2  / 
     
    1 row created.
     
    SQL> INSERT INTO T_20 VALUES(102,1002,00,'ABC','NO COMMENT','Y')
      2  / 
     
    1 row created.
    out put:
    SQL> SELECT * FROM T_20
      2  / 
     
       CONTROL         PO    AMENDNO FAC COMMENT_X                                F 
    ---------- ---------- ---------- --- ---------------------------------------- - 
           101       1000          1 MSC NO COMMENT                               Y 
           101       1000          2 MSC NO COMMENT                               Y 
           101       1001          0 NDP NO COMMENT                               Y 
           101       1001          1 NDP NO COMMENT                               Y 
           102       1002          0 ABC NO COMMENT                               Y
    Now, I want to select only the control number that have several acht.

    In above example only control 101 with several PO 2 PO with 1000 and 1001
    So I need to select only this 101 related lines...

    for 102 having in. sinple folders then it will have to be removed... because I have millions of records in the primary table...

    If one of the members (knapen in this forum) suggested query below:
    select *
      from (
    select t.*, count(distinct po) over(partition by control) cnt
      from t20_ t
          )
     where cnt > 1
    This gives the right output select only controls that have several PO - this satisfied requirment...

    Yet again others want to dig the out put with the condition as:

    Select only controls with multiple PO AND WHERE EACH '' HAVE SEVERAL AMENDNO

    So I modified the query knani as
    select *
      from (
    select t.*, count(distinct po,amendno) over(partition by control) cnt
      from t20_ t
          )
     where cnt > 1
    But I get the error message: invalid number of arguments...

    any help please...


    Thanks in advance
    Prasanth

    Like this?

    WITH tbl AS (select *
                   from (
                         select t.*, count(distinct po) over(partition by control) cnt
                         from t_20 t
                        )
                   where cnt > 1
                  )
    SELECT * FROM
               (SELECT tbl.*, COUNT(amendno) OVER (PARTITION BY control,po) cnt2
                FROM tbl
               )
    WHERE cnt2>1;
    
  • How to upgrade a selection one line of the table based on values in another table when there is exactly one matching entry and negligence if there is more than a football game

    Hello

    I'm trying to achieve the following objectives:

    1. in table A, select rows based on the values in column 2. something like SELECT * FROM TABLE A WHERE (COLUMN2 = 'X' or Column2 IS NULL)

    2 and these values selected, I want to update Column3 from Table A if TableA.column1 = TableB.column1, but only if there is exactly one game. If there are multiple matches, column 3 of the table article updated.

    That's what I've tried so far.

    UPDATE TABLE_A

    SET

    TABLE_A.COLUMN3 = (SELECT COLUMN3 OF TABLE_B

    WHERE ((TABLE_B.COLUMN1 = TABLE_A.COLUMN1) AND ( TABLE_B.COLUMN1 IN (SELECT Column1 FROM TABLE_B GROUP BY COLUMN1 , HAVING COUNT (*) = 1)))

    WHERE EXISTS (SELECT * FROM TABLE_A)

    WHERE ((TABLE_A.COLUMN2 = 'X' OU TABLE_A.COLUMN2 = 'Y') AND (TABLE_A.COLUMN4 IS NULL OR TABLE_A.COLUMN4 = ' ')));

    More details on my DB environment:

    Version Info:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production

    PL/SQL Release 11.2.0.4.0 - Production

    Toad, but, depending on whether the query updated all lines. I would really appreciate if someone could tell me how to fix my request.

    Thanks in advance.

    Exists it predicate in the block of update will be set to true if there is at least one row in table_a where column2 is X or Y and column4 is null or a space. You need to correlate exists it with the outer query query (I'm guessing on column1) to get the result I think you want.  However, who would update all rows in table_a who meets the criteria, there is a corresponding row in table_b, affecting Column3 lines form null not matched or not.  (Again), I'm guessing that's not your intention.  If you only want to update the lines in table_a which have a corresponding line in table_b and meet the other predicate, then I think you want something more like:

    Update table_a

    Set table_a.column3 = (select column3 of table_b

    where table_b.column1 = table_a.column1 and

    Table_B.Column1 in (select column1 from table_b

    Group by column1, having count (*) = 1))

    where ((table_a.column2 = 'X' ou))

    table_a.Column2 = 'Y') and

    (table_a.column4 is null or)

    table_a.column4 = ' ')) and

    table_a.Column1 in (select column1 from table_b

    Group by column1, having count (*) = 1)

    John

  • How to divide a single line (all lines) for the use of a few sql

    I have table

    Select * from une_table;

    name_a
    date_a
    name_b

    Date_B

    Sunday01.01.2015Monday02.01.2015
    Tuesday03.01.2015Wednesday04.01.2015

    How to divide this table in all lines after using sql:

    name
    Date
    Sunday01.01.2015
    Monday02.01.2015
    Tuesday03.01.2015
    Wednesday04.01.2015

    Thanks for the replies.

    Trajon,

    You don't have a table. You have a store of garbage. There is a repeating group in your 'table' and column name_a etc is unnecessary, because you can derive the day of the week from your date by a to_char function.

    You can find it in your documentation online.

    Knowing that you can get the ordinal number of a date using to_char, what have you tried to do it yourself?

    Your answer is probably: NOTHING.

    First try to solve it yourself and if you post something here, make sure that this forum is not to throw up, because your code that is terribly bad.

    ------------

    Sybrand Bakker

    Senior Oracle DBA

  • ADF Table retrieves all lines during the loading of the page

    Hello

    We have a requirement where we need run the query programmatically by giving the query column and its value.

    I used the code below in the AMimpl.java and calling this method during the click on the button Search my Search Page.

    I am able to get the features you want on the search page by clicking the search button.

    The question now is when the page initially loads, the table fetches all rows of the VO by default.

    Can you please let me know where I need to change so that the table will get no line on the initial load of the page?

    ' public void setVoParams (String columnName, String columnValue) {}

    ViewObject mapVO = this.getFusionSapMapping1 ();

    String whereClause = "MappingEO." + columnName + "" as: colValue ";"

    mapVO.setWhereClause (whereClause);

    mapVO.defineNamedWhereClauseParam ("colValue", null, null);

    mapVO.setNamedWhereClauseParam ("colValue", columnValue);

    mapVO.executeQuery ();

    }

    Hello

    You don't tell us your version of JDeveloper.

    An easier approach to implement your condition is to use the property refreshCondition of your iterator. Here is an example of how do: https://blogs.oracle.com/shay/entry/delay_method_execution_when_us

    Antonis

  • New path-layers of all lines with the tool pen?

    Hello! I am currently using Illustrator CS6 as a test version, and when I use the tool pen to make a beaver (school work), it all end in a single layer. I want to have a new layer-path of each line with the pen tool, so I can remove rows from the layer panel too. For the moment, it's a layer that has a picture of a beaver, and I can't see the individual lines that I drew. When I used CS5 recently I had no such problem.

    There is a setting that I can change or does have something to do with the news of CS6?

    If you want to see a 'sex' for each object changes the display of the layer panel by choosing Options from the Panel menu in the layer panel. In the lower part of the Panel options window, make sure that groups and objects are both checked. You will then see a 'sex' for each object.

    I quote 'sex' here because technically they aren't the layers. They resemble layers and are in the layer panel, but they do not exactly allow options that allow actual layers. You can select and move objects in the Panel this way however.

  • I want just a bunch of random numbers (about 120 of them) from the list, select 'all' and get the computer to rearrange in CNC

    I try both notepad and wordpad. I'm in Winows XP 2003.  I want just a bunch of random numbers (about 120 of them) from the list, select "all" and reorganize in order digital computer. I can't understand how I've done it before. Google says select the balls feature, but all that is put a point in front of a certain number. There is no arrow down to select. No A - Z. No 1,2,3. what Miss me? is the Notepad or wordpad not the place to do that?

    Use Excel.

  • Select all to delete the email

    How do I "select all" delete several emails?

    At this point, you can't.  K-9 Mail is an application that is in beta version that says he will be able, but it says in the description of this application that you should not run it constantly due to problems with her right now.  Sometimes in a near future we should have hopefully an application with this feature.

  • Select all objects with the same style of object?

    I did some research but empty is come. It is possible to select all the objects on a page that have the same style of applied object?

    What I want to do, is apply an action 'frame content' to a large group of text boxes (labels on a map). But this mounting option doesn't seem to be available as part of the style of the object.

    Any suggestions?

    Thank you.

    Try using the option Auto-size text block rather in the style of the object. This feature (found in the object > text frame Options) is useful to the legends of autosize following certain rules.

    This attribute can be used in object styles.

  • Select all audio in the composition?

    I was wondering how to select all the audio elements, even if they are under a symbol or nested symbols. Thank you!

    If you mean programmatically, use:

    selector of $("audio") which returns an array of audio elements.

    If you mean by selecting from Edge host, you can select that all these elements under a level symbol using only the Panel element.

    HTH,

    Vivekuma

  • Select all content in the indesign document to attach the script

    I have a script that does something useful for my document. But he always need chose the part of the document, as

    If (app.selection.length > 0)...

    Could you ask me how to select all the pages in the indesign document. I have a lot of pages. And I have a lot of files .indd
    I tried to use app.activeDocument.pages.item (0) .allPageItems; but it is not the effect of page = ( )

    Maybe I can use loop 'for', but perhaps there is a function of selection of all the document, is not only one page

    Thank you

    Of course:

    myPages = app.activeDocument.pages.everyItem () .getElements (); Table of references to the pages of the document

    for (var k = myPages.length - 1; k > = 0; k-) {}

    myPages [k] .allPageItems = myItems;

    for (var j = myItems.length - 1; j > = 0; j-) {}

    processItem (myItems [j]);

    }

    }

    It treats everything from BACK to front, which is usually the security approach and is potentially a bit faster that the other direction.

    You must always write the processItem function.

    Dave

  • How, in Illustrator CS5, select all objects with the three points (or nodes)?

    I'm fairly new to Illustrator, but it seems like it should be simple.  (It's trivial in CorelDraw X 4: after selecting an object with three knots, I go to Edition > search and replace > find objects > find objects that correspond to the currently selected object and navigate the menus left.)

    In Illustrator CS5, select options > identical do not seem to include the selection of all objects with the same number of nodes under the currently selected object.

    A double click on the magic wand tool also does not provide such an option.

    Thanks for any help.

    PS also useful would be knowing how to add other criteria to this search, for example, how to select all objects with three points * and * the current fill color.

    advictoriam,

    I'm afraid that you have better luck with the number of anchor Point.

Maybe you are looking for