Select IFF all rows satisfy the condition

Hi,
I am not able to figure out how to go about this requirement of mine. I am using APEX 3.1.
I have a table with expiration dates. I would like to select only the company_id, all of whose dates have been expired(to_date(sysdate,'DD-MON-YY') < = to_date(expiration_date,'DD-MON-YY').
Table:
table_id | company_id | expiration_date
1 | 2 | 10-APR-09
2 | 3 | 10-APR-09
3 | 2 | 10-AUG-10
4 | 1 | 10-APR-09
5 | 1 | 10-APR-09
required output:
table_id | company_id
2 | 3
4 | 1
4 | 1
Thanks,
Medha
Edited by: user11267485 on Aug 18, 2009 11:31 AM
Edited by: user11267485 on Aug 18, 2009 11:32 AM

hI,
user11267485 wrote:
This is the formatted code i am running
select company_id
from table outer
where not exists (
select table_id
from table inner
where inner.company_id = outer.company_id
and inner.expiration_date > sysdate) order by company_idNo it's not: that's unformatted code, exactly the kind of thing you should never ask anyone else to read.
It may have been formatted before you posted it. When posting on this site, type these 6 characters:
(small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
This would make your output easier to read, also.
When I run those two queries with the sample data you posted, they both work.  The first one only displays one column, but it's correct.
When you run those queries with the sample data you posted ( *not* with your real table) what results do you get?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Selecting an entire row with the help of Checkbox

    Hi and Evening to Everybody,
    I have a Scenario where i need to select an entire row using the check box. Let me first define the Situation. I created a Simple Sql-report where the first column is a Simple Checkbox and the second column is a display only name and followed by the rest 5 columns as a checkbox.
    my table structure is :
    **create table satt (SELECT_ALL VARCHAR2(10), Name VARCHAR2(50), Object1 VARCHAR2(10), Object2 VARCHAR2(10), Object3 VARCHAR2(10), Object4 VARCHAR2(10), Object5 VARCHAR2(10));**
    Now i had a requirement where i need to Check All or Uncheck All Checkbox by clicking SELECT_ALL column header and i made it using
    simple java-script :
    "<input type="Checkbox" onclick="$f_CheckFirstColumn(this)">"
    Now i need to Check all checkbox in a row by clicking any of the SELECT_ALL check boxes. (Say i have 5 checkboxes in SELECT_ALL column and if i click 3rd checkbox... i need the entire 3rd row checkbox to be checked on click of that 3rd check box).
    I hope i was clear with my question. i did my best. Please help me out with this... Im eagerly lookin for the solutions.
    Thanks & Regards,
    - The Beginner.
    Edited by: 854477 on Jul 13, 2011 4:57 AM
    Edited by: 854477 on Jul 13, 2011 5:01 AM

    Solomon Yakobson wrote:
    There is no row order in relational tables unless ORDER BY is used, so there is no way to decide if 3 Mathematics belongs to 100 or to 200.
    SY.That's not how I interpretted it. I thought he was saying that in the first row column B has the value:
    '1 Physics'||chr(10)||'2 Chemistry'||chr(10)||'3 Mathematics'
    in which case something like this would work
    select a,replace(b,chr(10),chr(10)||a||' ') from table;

  • Default selection of a row in the table

    Dear all,
    I have given output of one table as the  input to an RFC and the output of this RFC is given to a table and the same scenario we followed for the graphs also. By default first row of the table is getting selected because of that the second table or graph is getting displayed without any user interaction. Please tell us how can we avoid the above. I tried by using guard condition of select but i am unable to control it. Please tell us detailed procedure by which directly i can follow the same.
    Regards,
    Suman.

    Hello Suman,
    Please, look at 'No First Select from Table' section of this blog: [/people/jarrod.williams/blog/2006/12/14/visual-composer-tips-and-tricks|/people/jarrod.williams/blog/2006/12/14/visual-composer-tips-and-tricks]
    Good luck,
    Ola

  • How to select values frm table giving the condition value at runtime in SQL

    Hi All,
    How to select values from a table by giving the condition value at runtime in SQL
    My SQL statement is select * from employee where empno=<empno>, this empno I want to provide at run time. Also I don't have any bind variables defined. Can anyone please tell how can I achieve this. Also do I have to write a SQL or pl/sql statement.

    Hi Roshni Shankar,
    You can use substitution variable in case of SQL.
    SQL> select * from employees where emplployee_id = &emp_id;
    Enter value for emp_id: 100
    old   1: select * from employees where emplployee_id = &emp_id
    new   1: select * from employees where emplployee_id = 100If you want to put condition on varchar values then eighter provide values in single quotes or use single quote for substitution variable.
    SQL> select * from employees where last_name = &emp_name;
    Enter value for emp_name: 'King'
    old   1: select * from employees where last_name = &emp_name
    new   1: select * from employees where last_name = 'King'
    no rows selected
    SQL> select * from employees where last_name = '&e_name';
    Enter value for e_name: King
    old   1: select * from employees where last_name = '&e_name'
    new   1: select * from employees where last_name = 'King'In case of pl/sql you can pass values to procedure and you can use those values at run time.
    create or replace procedure test (p_emp_id number)
    as
       v_last_name      varchar2(100);
    begin
       select last_name
       into    v_last_name
       from  employees
       where employee_id = p_emp_id;
       dbms_output.put_line(p_emp_id ||'    ->    '||v_last_name);
    end;
    show errors
    SQL>exec test(100);
    SQL>exec test(101);Edited by: Gaurav Bhide on Oct 29, 2012 4:07 AM

  • Select 2 records (rows) in the results.

    I am using Oracle R12- Forms.
    After searched for all orders for a specific Customer, on the Results, I need to select 2 different rows.
    Also tried ft object,but failed.
    If manual, I use Keep holding the Ctrl Key, and Click for the first row, and Click 2nd row.
    In OATS, I could not do this with the code below:
    int rone=2;
    int rtwo=5
    Robot robot = new Robot();
    robot.delay(5000);
    // press and hold CONTROL key
    robot.keyPress(KeyEvent.VK_CONTROL);      
    forms.textField("//forms:textField[(@name='MY_ORDER_NUM_"+rone+"')]").click();          
    forms.textField("//forms:textField[(@name='MY_ORDER_NUM_"+rtwo+"')]").click();
    robot.keyRelease(KeyEvent.VK_CONTROL);
    Any help is greatly appreciated.
    Thanks,

    What you need is a tree.
    See Tomahawk (www.myfaces.org)

  • JComboBox doesn't show all Rows in the View Object

    Hi,
    I've got a JComboBox which shows only 25 rows of the VO and I'm sure there are at least 50 or more rows.
    I'm also sure this is not JComboBox.maximuRowCount's fault, which just in case i've set to Integer.MAX_VALUE.
    Why is this happening? How could i change it?
    Thanks in advance. Pablo.

    set the RangeSize attribute of the iterator that is populating the
    list values to minus one (–1). This will ensure that all of the possible list
    items will appear in the list. Failure to do this will restrict your lists to a
    maximum of 25 entries, the default value of the RangeSize property.

  • Best approach to select multiple/all photos from the iOS CameraRoll?

    I want to use FlashBuilder 4.5.1 to build a flex mobile photo organizer project that lets me select multiple photos from the iPhone Camera Roll.
    I've seen the flash.media.CameraRoll class, but it only seems to provide CameraRoll.browseForImage() that opens a dialog to pick ONE photo.
    Has anyone built an app that lets users select multiple photos or select all from the CameraRoll? Can you access the embedded thumbnail DB or do you have to import all the photos into the ApplicationStorageDirectory first? Am I better off writing a native iOS application?
    Does flex mobile allow something like this:
    // is this a security violation?
    var cameraRoll:File = new File('/var/mobile/Media/DCIM');
    var photos:Array = [];
    var folders:Array = cameraRoll.getDirectoryListing();
    for (var i:int=0 ; i<folders.length; i++) {
        var files:Array = folders[i].getDirectoryListing();
        for (var j:int=0 ; j<files.length; j++) {
            var photo:File = files[j];
            photos.push(photo);
    // show photos, somehow...
    However, this method does not provide access to thumbnails managed by: '/var/mobile/User/Media/Photos/Photo Database'
    from: http://stackoverflow.com/questions/6936881/how-do-you-access-the-ios-camera-roll-from-a-fl ex-mobile-project

    I paid someone to write a Native iOS app that works ok, but it's hard for me to extend. The "select multiple/all" photos component works fine, but loading the photos into the app sandbox is VERY SLOW, and not properly threaded.
    I would like to move my dev to FlexMobile and am willing to contribute my current code if someone wants to take a hack at it. Please feel free to fork https://github.com/mixersoft/odesk-11563930
    I'd help, but I only know scripting languages.
    m.

  • How to hide the all rows except the result row in a report?

    Hi Experts,
    We have a report in which the user is interested to see only the result rows and I need to HIDE the characteristics in the rows. I was successfull in doing the same for Key figures in columns using "Calculate single value as suppress result". But I am not finding a way out to hide the characteristics in the rows.
    If I move the characteristics in rows to Free characteristics, the result row is not getting dispalyed. Also, the characteristics are  used dynamically by the formulae in columns and hence i cant remove these characteristics from the query. . The user wants the query to contain only one characteristic in the row and the result row for the key figures in columns. The report currently displays Invoice level data for each customer and this needs to be eliminated and it should display the summarised  data for every customer. Please suggest how this can be accomplished
    Regards,
    Kavitha

    Moving the char to free char will show the equivalent of result.
    Your issue likely is that this breaks the calculations since you do want the calculations done at detail level.
    To achieve this, move your char to free char (say it is 0CUSTOMER).
    For the CKF/Formula, go to aggregation tab, set the exception aggregation as Total (or whatever it was in standard behavior) and specify reference characteristic (in this case 0CUSTOMER), also check the 'Before aggregation' if you have that checkbox there.
    This will ensure the calculation is done at detail level even though the char is not included in the rows.
    If you have multiple chars to be moved to free char but included in detailed calculation, you will need to build cascading CKFs (CKF1 with ref char1, CKF2 eq to CKF1 with exception aggr on ref char2...and so on).
    Added:
    I understand you do want 0CUSTOMER in there, but something else (let us say 0DOCNO) removed. Use 0DOCNO in place of 0CUSTOMER in the case described above.
    Edited by: Ajay Das on Aug 5, 2009 8:57 AM

  • Selecting a one row from the database is not working

    Hi all I am having a small problem with getting a row from my database to show up. Here is the code for the search that I want to do
                            String item; String columnName; String result; columnName = (String)searchBox.getSelectedItem(); item = searchField.getText().trim(); String tableName = "employee"; if(item == null || item.equals("")){ System.out.println("No Text entered"); }else{ try { result = sql.retrieve_From_Database(columnName, tableName, item); System.out.println(result); } catch (SQLException e1) { sql.displayErrors(e1); }
    Here is the code for the retrieve_From_Database function.
    protected String retrieve_From_Database(String columnName, String tableName, String item) throws SQLException{ ResultSet rs = null; Statement sm = null; sm = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = sm.executeQuery("select * from " + tableName + " where " + columnName + " = " + item); result = rs.getString(columnName); if(result == null){ System.out.println("Error in retrieve"); return new String("No results in DB"); }else{ System.out.println(result); return result; } }
    When I run the first code I get an error of SQL Exception: Unknown column 'anthony' in 'where clause'. But yet when I run the query of
    Select * from employee where FirstName = 'anthony'
    within the mysql commandline I get the proper result. So my question is why when running this in the command line do I get the proper result but when running the code I do not?

    jo**** wrote:
    Hi. The problem is clear in the original post. The OP is trying to use PreparedStatement
    parameters to fill out general portions of the SQL query, instead of only data values.
    He is hoping to put in a column name. That will never work. Only data values are settable.
    HTH,
    Joe WeinsteinActually, no. There's no PreparedStatement there at all. It appears that his problem is that, while the working query entered directly in the client is
    Select * from employee where FirstName = 'anthony'the query he's constructing in his code is
    Select * from employee where FirstName = anthonySince there are no quotes around anthony, it's treated as a column name.
    If he had properly used PreparedStatment as suggested in reply 1, that would not be an issue. My guess, however, is that when he claims he's using PS, it's as Tolls suggested a couple of posts ago--he's simply replacing the Statement with a PreparedStatement, but not using the parameters as suggested.
    The wrong thing for OP to do at this point is see my above comment about the quotes and explicitly add them in the query string. The right thing to do, of course, is to actually use PS's parameters.
    Edited by: jverd on Oct 11, 2010 10:08 AM

  • Display all rows in the report

    Hi all,
    I've a report which requires all the rows to be displayed even if no data is present.
    For e.g. I've agebucket classification in my rows. Certain agebucket classification has no ppl in it.so i want it to be displayed with 0 as its value. could anyone please help?
    Thanks in advance.

    Hi,
    If you have taken <i>agebuckets</i> as selections , then you will get balnk cells if there are no records satisfies the restrictions given in those selections. So to get zero in place of Blank value , you need to dependent on Formulas as shown below:
    Lets say you have selections like <i>agebucket1</i>,<i>agebucket2</i>.
    Then you need 2 formulas .And you need to hide   <i>agebucket1</i>,<i>agebucket2</i>.
    1st formula:
    ( <i>agebucket1</i> == 0 ) * 0 + ( <i>agebucket1</i> <> 0 ) * <i>agebucket1</i>
    2nd formula:
    ( <i>agebucket2</i> == 0 ) * 0 + ( <i>agebucket2</i> <> 0 ) * <i>agebucket2</i>
    With rgds,
    Anil Kumar Sharma .P

  • How to display all rows in the report in one page in Oracle APEX 3.2

    Friends -
    We are using Oracle Applications Express 3.2 on oracle database 10.2.0.5 on solaris environment.
    One of our report contains total no of rows 50000. when we ran report by default it is showing 15 and i can go search and change display no of rows to different numbers and click go.
    My question is it possible to display all 50000 rows during first time report launching without going to change rows. Is there any option that we can set how many number of rows that we can display during report design.
    Please advise
    VSH

    Hello VSH,
    >> My question is it possible to display all 50000 rows during first time report launching without going to change rows
    As vee pointed out it is possible, however the question you need to ask yourself is is it wise?
    Bear in mind that displaying 50,000 rows on a single HTML page means a lot of code that must be loaded by the client browser all at once. What it will do to your page loading time? Browser memory? Network bandwidth? Also, do you really believe that it is effective to let an end user look for a specific row among 50,000 rows?
    Regards,
    Arie.
    &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    &diams; Author of Oracle Application Express 3.2 – The Essentials and More

  • Selecting cells and rows in the Spark DataGrid control

    This question was posted in response to the following article: http://help.adobe.com/en_US/flex/using/WS0ab2a460655f2dc3-427f401412c60d04dca-7ff8.html

    "Note: While the selectedCells, selectedIndices, and selectedItems properties are all writable, Adobe recommends that you use methods of the DataGrid to change selection programmatically."
    OK.. So how do I programmatically select multiple items?
    The setSelectedIndex method will only add a single item.
    I have tried to ''push" an index onto the selectedIndicies but that won't work either...
    Please help me.. this is driving me nuts...

  • Need a query,which will do a comparison and if it doesnt satisfy the condition it should raise an error by using raiserror statement

    I have a Table called Test_ X in which there are two fields:
    1) date_value
    2)Application_Name
    requirement: we have to calculate the number of days ramaining through date_value field and  compare it to  with n days.
    if it is less than n days it should raise an error through raiserror statement.
    I get the below logic to get the no of days before expiry:
    select GETDATE() 'Today Date',
    date_value 'expiry date',
    abs(DATEDIFF(dd,date_value,getdate()))'No of days before expiry'
    from dbo.Test_X
    where Application_Name='xyz'
    With above satatement am able to get the Number of days before expiry .
    my question is how to comare it with a variable say n days and if is less than n days it should raise an by using raiserror statement .
    Please help or advice.

    You can use variables in the RAISERROR, but not expressions, e.g.
    DECLARE @Days INT;
    SET @Days = ABS(datediff(day, '19000101', CURRENT_TIMESTAMP));
    RAISERROR (
    N'This is message %s %d.'
    ,-- Message text.
    10
    ,-- Severity,
    1
    ,-- State,
    N'number'
    ,-- First argument.
    @Days
    );-- Second argument
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • DB / Integation adapter returning duplicate rows on select [not all rows]

    I am seeing some unusal behavior, we have Application adapter invoking BEPL and which invokes DB adapter to make a select call to ERP database. Select should return 2 different records, where as in the response xml it has same record [only first record] listed twice. On DB adapter wsdl, -"Return Single Resultset " is unchecked. Should this be checked? or is there any other reason why the first record may be cached. I have not seen this in other connectors, restarted server but still same issue. connector is in prod environment. Any help/ideas are welcome.
    Edited by: user3622460 on Aug 5, 2009 10:23 PM

    Can you tell us more about the options you have selected in the Adapter to select the records ?

  • Delete the rows if the check box is selected.

    Dear all,
    i have a block (not database block). i added a check box to the same block. now i want to delete the row against which the check box is selected.
    i wrote the following code in when-button-pressed trigger.
    IF Checkbox_Checked('CHK_DEL') THEN
         delete from fa_01_11
         where as_id = :as_id;
    END IF;
    commit;
    but when i select only one check box it delete the all rows from the table if the condition is satisfied.
    here is the data in my table
    as_id year month
    63     2006     4     0     -1183.92     1
    63     2006     5     0     -1183.92     1
    63     2006     6     0     -1183.92     1
    63     2006     7     0     -1183.92     1
    63     2006     8     0     -1183.92     1
    63     2006     9     0     -1183.92     1
    63     2006     10     0     -1183.92     1
    63     2006     11     0     -1183.92     1
    63     2006     12     0     -1183.92     1
    what's the proble?
    Regards:
    Muhammad Nadeem
    Message was edited by:
    Muhammad Nadeem

    You need to run the code for each record and you need to find something which is unique. as_id is not unique.
    untested:
    declare
      last_rec boolean := false;
      deleted boolean := false;
    begin
      first_record;
      loop
        deleted := false;
        last_rec := :system.last_record = 'TRUE';
        IF Checkbox_Checked('CHK_DEL') THEN
          delete from fa_01_11
            where as_id = :as_id
            and year = :year
            and month = :month;
          clear_record;
          deleted := true;
        END IF;
        exit when last_rec;
        if not deleted then
          next_record;
        end if;
      end loop;
      commit;
    end;

Maybe you are looking for