How to check this condition in where clause

WITH t1 AS
    (SELECT 1 empno, 'Sun' name,100 deptno, 'M' Gender  FROM dual
    UNION ALL
    SELECT 2,'Gun',100 deptno, 'F' FROM dual
    UNION ALL
    SELECT 3, 'Run',50,'M' FROM dual
    UNION ALL
    SELECT 4, 'Nun',75,'F' FROM dual
    UNION ALL
    SELECT 5, 'Tun',25,NULL FROM dual)
    SELECT empno,name,deptno,gender FROM t1;

I want to display those dept. data which is having Genders both 'M' and 'F',

You can use two ANDed 'exists' conditions...

...
SELECT empno,name,deptno,gender FROM t1 t1o;
where
exists (select 'x' from t1 t1i where t1o.deptno = t1i.deptno and t1.gender = 'M')
and
exists (select 'x' from t1 t1i where t1o.deptno = t1i.deptno and t1.gender = 'F')

Tags: Database

Similar Questions

  • How to check if condition. ??

    Hello

    Alert (isOtherAlertPresent) / / this fake show

    {if (isOtherAlertPresent)}
    Alert ("Yes");
    document.getElementById('alertIcon').style.visibility = "visible";
                    
    }
    else {}
    Alert ("no");
    document.getElementById('alertIcon').style.visibility = 'hidden ';
                    
    }

    If this condition is false, so it show no., but YES it shows why... ?

    Where is the HTML code that contains the element with the id: alertIcon?

    It is difficult to answer without this piece of code.  Your code is not also look to right.  In this case are that you assign isOtherAlertPresent what anyone?

    Your code should perhaps be something like:

    If (document.getElementById('alertIcon').style.visibility = 'visible') {}

    Alert ("Yes");

    } else {}

    Alert ("no");

    }

    To do this you will need an element with the id in your HTML code, the value alertIcon as:

  • Simple conditional SQL WHERE Clause with two Subselects

    Hi SQL Experts,
    I need some quick help with a query.
    It is a ' select ' for a data source object repository phyiscal table OBI.
    So, I can't put in PL/SQL or in stored procedures. I just need
    have two conditions / selects different according to the user's role (this information comes
    of the session).
    The above does not work:

    -ORA00905. 00000 - 'lack the key word'
    SELECT OFFICENO FROM orgunit
    WHERE

    BOX WHEN "SESSION_VARIABLE' LIKE '% globalmanager %' THEN
    ASSIGNEDOFFICES =
    (
    SELECT DISTINCT ASSIGNEDOFFICES
    FROM USERSTABLE INNER JOIN orgunit WE
    OrgUnit. KEY = USERSTABLE. OFFICE
    WHERE USERSTABLE. USERNAME ='VALUEOF (NQ_SESSION. THE USER)"
    )
    ON THE OTHER
    OFFICENO =
    (
    SELECT DISTINCT USERSTABLE OFFICENO
    INNER JOIN orgunit WE
    OrgUnit. KEY = USERSTABLE. OFFICE
    WHERE USERSTABLE. USERNAME ='VALUEOF (NQ_SESSION. THE USER)"
    )
    END;

    Can anyone help?

    Hello

    I can't tell what you want to do by looking at the code that do not do. Maybe:

    SELECT officeno

    For orgunit

    WHERE (session_variable LIKE '% globalmanager %'

    AND IN assignedofficies

    (

    SELECT assignedoffices

    UserTable U1

    JOIN orgunit o1 ON o1.officekey = u1.officekey

    WHERE u1.username = ' VALUEOF (NQ_SESSION. THE USER)"

    )

    )

    OR (NVL (session_variable

    , '?'

    ) NOT LIKE '% globalmanager % '.

    AND IN officeno

    (

    SELECT officeno

    Of u2 usertable

    JOIN orgunit o2 ON o2.officekey = u2.officekey

    WHERE u2.username = ' VALUEOF (NQ_SESSION. THE USER)"

    )

    )

    ;

    There might be a simpler and more efficient way in function your tables and your limit.

    The condition u2.username = ' VALUEOF (NQ_SESSION. The USER) "almost certainly not what you really want.

    .

    Whenever you have any questions, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • Index Coalesced - how to check this information?

    Hi all

    Can you please help me with this info:

    I'm Coalescing index in a pattern in our database. I know this merges leaves blocks and removes fragmentation but only recover space as in the case of Index rebuild.

    I want to know if there is a way to check / confirm that a particular Index is merged successfully? I don't see any change OF VALUES IN - LEAF_BLOCKS, AVG_LEAF_BLOCKS_PER_KEY, CLUSTERING_FACTOR, SAMPLE_SIZE, dba_indexes LAST_ANALYZED. I think he must have seen there some dictionary that fills this kind of information. Please share your ideas / knowledge.

    Thank you very much
    Kerim

    Kerim says:
    Hello

    This info is helpful. I have not run a standard process to determine which indexes need to merge. We had an important activity DML / deletes in the scheme of the last week. So, rather than rebuild the indexes, we thought merge would be an option to try.

    And what do you hope to achieve by index coalescing/rebuild? Are you facing performance issues? Have you seen that the performance problem is "solved" by coalescing/rebuilding of the index?

    I see that you have demonstrated by example (analyze index validate structure) and then run merge and show how the stats changed in the INDEX_STATS table. This means running (analyze index validate structure) is a mandatory thing to do if we want to merge the indexes or is it just to see the details in the INDEX_STATS? Please confirm

    N ° you have to run INDEX ANALYSER... VALIDATE THE STRUCTURE. It is done only to see details in INDEX_STATS here.
    Your original question was where you can see the effect of the operation coalesce. So I showed you a place where you can see how coalesce affect the index.
    I hope this helps.

  • case of condition in where clause

    Hello

    I am a beginner in SQL, but according to my reading of the manual, this syntax should be acceptable. I'm using application express but tested also in Developer SQL and the conclusion that it fails with an error "invalid relational operator", with the line number pointing to the ELSE clause of the condition, but a number of column pointing to white space.

    This is a select statement nested, but that shouldn't matter. The fragment in question is:

    Select columns
    RES
    where res.villaid =: P605_VILLAID
    and INSTR (: P604_RES_STATES, res.states). = 0
    and (CASE: P604_EXCLUDE_ZERO)
    WHEN 'Y' THEN ' res.rate > 0'
    ELSE ' res.rate > = 0'
    END)
    and res. DEPARTDATE >: P605_STARTDATE
    and res. ARRIVEDATE < =: P605_ENDDATE.

    I hope that this puts ok shaped during the validation. The code is looking for bookings within a range of dates (which works very well when the other conditions are discussed), and should only output offset lines (nights) if the user asks for it in the variable of liaison P604_EXCLUDE_ZERO. There are probably other ways to go about this, but I'm too stubborn to renounce it. Well, not yet anyway.

    Thanks and greetings
    CS
    select some columns
      from res
     where res.villaid = :p605_villaid
           and instr (:p604_res_states, res.states) != 0
           and sign (res.rate) >= case when :p604_exclude_zero = 'Y' then 1 else 0 end
           and res.departdate > :p605_startdate
           and res.arrivedate <= :p605_enddate
    
  • How to pass the parameter in where clause contained in the custom file?

    I have the tracking query

    Blue are the parameters

    I paste this to a custom folder

    and

    Select last_update_date, creation_date

    of ra_customer_trx_all

    "where trunc (last_update_date) = 29-SEP-2012."

    and customer_trx_id = 1109

    in another folder custom return 1 row only and create a different worksheet in the same workbook and create

    3 setting and 2 of them pointing to the 1 row to query and create a calcualtion

    SET_CONTEXT ("Date_From", TO_CHAR(:Date From)) and SET_CONTEXT ('Date_TO', TO_CHAR(:Date To))

    and 1 condition 1 = SET_PARAM3(:Period)

    but this does not work for me, no data back please help

    Select m.party_name TENANT_NAME

    b.interface_line_attribute10 lease_num

    -, b.interface_line_attribute12 «PPS Number.

    b.interface_line_attribute2 LOCATION_CODE

    flexv.description property_name

    INVOICE_NUMBER a2.trx_number

    -, t.nom "Type of Transaction".

    -, e.attribute15 "AS400 Key."

    , b2.description 'BILL_ITEM_INVOCIE_DESCRIPTION '.

    , case when gcc.segment5 like 6% ' then ' P/L '.

    When gcc.segment5 like 7% ' then ' P/L '.

    When gcc.segment5 as 8% ' then ' P/L '.

    When gcc.segment5 like 9% ' then ' P/L '.

    else "B/S".

    end as account_nature

    -, gcc.concatenated_segments as 'account of burden '.

    gcc.segment1 company_code

    gcc.segment2 department_code

    gcc.segment3 property_code

    gcc.segment4 business_segment

    gcc.segment5 account_code

    gcc.segment6 project_code

    gcc.segment7 intercom_code

    gcc.segment8 spare1

    gcc.segment9 spare2

    b2.extended_amount BILL_ITEM_INVOICE_AMOUNT

    to_char (substr(ps.gl_date,4,8)) gl_period

    b.interface_line_attribute11 bill_start_date

    b.interface_line_attribute14 bill_end_date

    decode (a2.invoicing_rule_id, '-2',

    DECODE (TO_CHAR ("b.RULE_START_DATE, ' YYYYMM"), to_char (to_date (to_char (TRUNC (to_date (SETPARAM.) GET_PARAM3, "YYYYMM"), 'Month')-1), "MON-DD-YYYY"), "YYYYMM"), "Current", "Forward").

    'In progress' Bill_nature)

    , to_char (a2.trx_date, ' MON-DD-YYYY "") invoice_date

    pal.lease_commencement_date

    pal.lease_termination_date

    h.user_name created_by

    -, NULL as remarks

    of ra_customer_trx_all one

    ra_customer_trx_lines_all b

    pn_leases_all d

    e pn_tenancies_all

    hz_cust_accounts l

    hz_parties m

    fnd_user h

    ar_payment_schedules_all ps

    RA_CUST_TRX_LINE_GL_DIST_ALL dist

    gl_code_combinations_kfv gcc

    AR_RECEIVABLE_APPLICATIONS_all app

    ra_customer_trx_all a2

    ra_customer_trx_lines_all b2

    RA_CUST_TRX_TYPES_all t

    fnd_flex_values_vl flexv

    pn_lease_details_all pal

    where

    App. APPLICATION_TYPE = "CM".

    and flexv.flex_value = gcc.segment3

    and flexv. FLEX_VALUE_SET_ID = 1014916

    and pal.lease_id = d.lease_id

    and app.applied_customer_trx_id = a.customer_trx_id

    and app.customer_trx_id = a2.customer_trx_id

    and a2.cust_trx_type_id = t.cust_trx_type_id (+)

    and a2.org_id = t.org_id (+)

    and b.customer_trx_line_id = b2.previous_customer_trx_line_id

    and dist. CUSTOMER_TRX_LINE_ID = b2. CUSTOMER_TRX_LINE_ID

    and dist.account_class = 'REV '.

    and dist.account_set_flag = DECODE (NVL(a2.invoicing_rule_id,1)-2, 'Y', 'n')

    and gcc. CODE_COMBINATION_ID (+) is Dist. CODE_COMBINATION_ID

    and b.interface_line_attribute10 = d.lease_num

    and d.lease_id = e.lease_id

    and e.primary_flag = 'Y '.

    and b2.customer_trx_id = a2.customer_trx_id

    and a2.bill_to_customer_id = l.cust_account_id

    and l.party_id = m.party_id

    and a2.created_by = h.user_id

    and ps.customer_trx_id = app.customer_trx_id

    and ps.gl_date between trunc (trunc (TO_DATE (SYS_CONTEXT ('DISCO_CONTEXT', 'Date_From')), 'MM')-1, 'MM') and trunc (TO_DATE (SYS_CONTEXT ('DISCO_CONTEXT', 'Date_To')), 'MM')-1

    What exactly is the problem with the results? Can you do the report include the gl_date, so that you can see exactly what is included?

    The only way to solve this is back to basics. You must be certain that the setting and calculations for the date work 100%. You have granted the Execute permission on the function to your landlord EUL - Yes? I did create the function in a package belonged to EUL_US, then I got no problem with permissions or grant.

    Also, gl_date is a DATE string and not a right? I ask because if it is not a date, but a string then a few dates could be left out.

    Assuming that you are 100% some of the building blocks, you should start by including only the gl_date and the primary key of the table you are using. Once you are sure you have found the right data, you can start adding in addition to fields.

    I note that you use the E-Business Suite objects. I copied the code in my system where I don't use rental. So I put comment references to tables 3 PN. I had 150 lines of data when I asked for it by using the parameter, and then when I hard coded the BETWEEN operator for the gl_date. You don't have to make sure that your landlord EUL got right SELECT all tables and views used in your code and, if you want to share this code with someone else, you must also have LICENSING rights.

    Try your code in a SQL like TOAD tool and see what happens. Are you absolutely sure that each of your transactions has an entry in the tables PN? Maybe it's why you don't get the results you expect. You can try, as I did, to comment these lines out and then see what happens.

    Hopefully this has given you enough to solve your problem

    Michael

    PS. It would be nice to know your name. You have not used once it in your thread.

  • Result of conditional function where clause

    create the table datatest
    (number of primaryid,
    Identification number,
    power varchar2 (4).
    alias varchar2 (15))

    insert into values(1,100,'CNN','NEWS') datatest.
    insert into values(2,100,'BBC','SPORTS') datatest.
    insert into values(3,101,'CNN','INV') datatest
    insert into values(4,101,'ABC','MON') datatest
    insert into values(5,102,'BBC','REAL') datatest
    insert into datatest values (6 103, 'NEC', "TVL")

    I am looking for a query which returns lines with power CNN
    If the CNN feed isn't here then return the line with power BBC
    This is the result I'm looking for.

    1 100, CNN, NEWS
    3 101, CNN, INV
    5 102, BBC, REAL


    Thnx in advance
    create table datatest
    (
      primaryid number,
      secondaryid number,
      feed varchar2(4),
      the_alias varchar2(15)
    );
    begin
    insert into datatest values(1,100,'CNN','NEWS');
    insert into datatest values(2,100,'BBC','SPORTS');
    insert into datatest values(3,101,'CNN','INV');
    insert into datatest values(4,101,'ABC','MON');
    insert into datatest values(5,102,'BBC','REAL');
    insert into datatest values (6,103,'NEC','TVL');
    end;
    
    select *
    from
    (
      select
        primaryid,
        secondaryid,
        feed,
        the_alias,
        row_number() over (partition by secondaryid order by decode(feed, 'CNN', 1, 'BBC', 2) asc) as rn
      from datatest
      where feed in ('CNN', 'BBC')
    )
    where rn = 1
    

    Would be a solution.

  • I need account condition in where clause.

    Hi all

    I have a data

    Product ID AMT

    1100A
    1100B
    1100C
    1100D
    225A
    240E
    255F
    350B
    350A
    350C
    350G
    412H
    413E
    414A
    415I have

    I need following output

    IDAMTProduct
    1100A
    1100B
    1100C
    1100D
    350B
    350A
    350C
    350

    G

    I tried after query, but it does not work

    Select

    ID,

    AMT,

    Product

    t

    Product ID, AMT Group,

    having count (distinct ID) = count (distinct AMT)

    It returns all the rows.

    Help, please

    with t as)

    SELECT id,

    AMT,

    product,

    County (separate amt) over (partition by id) cnt

    of sample_data

    )

    SELECT id,

    AMT,

    product

    t

    where cnt = 1

    order by id

    /

    AMT ID P
    ---------- ---------- -
    1 100 A
    1 100 B
    1 100 C
    1 100 D
    3 50
    3 50
    3 50
    3 50

    8 selected lines.

    SQL >

    SY.

  • where clause with reg_exp

    Hello

    My query is...

    The string is "1,2,3"...

    output must be '1', ' 2 ', ' 3',

    Please help me...!

    Concerning
    SA


    The guru gave the solution...
    select REGEXP_REPLACE('1, 2, 3', '([0-9]+)', '''\1''') from   dual;
    But, I have to use this condition in Where clause on my request. If I put in which the value of the clause does not appear. Any help on that...! Please, I beg you.

    Concerning
    SA

    Hello

    Query: SELECT "' | REPLACE ('1,2,3',',' "',"'). "' val FROM DUAL;

    will convert '1,2,3' string '1', ' 2 ', 3'.

    Run the sub queries first and then run a select statement.

    CREATE TABLE sample_table
    (
    col_a VARCHAR2 (3)
    );

    INSERT INTO sample_table
    VALUES ('1');

    INSERT INTO sample_table
    VALUES ('2');

    INSERT INTO sample_table
    VALUES ('3');

    INSERT INTO sample_table
    VALUES ('4');

    INSERT INTO sample_table
    VALUES ('5');

    COMMIT;

    SELECT col_a
    OF sample_table
    WHERE INSTR ((SELECT ''' ||)) REPLACE ('1,2,3',',' "',"'). "' val
    THE DOUBLE).
    col_a
    ) > 0;

    The select statement above will give you the desired result of "sample_table" as below.

    COL_A
    1
    2
    3

    Kind regards
    Big Boss

  • May I ask where clause to satisfy two conditions at the same time (and)

    Hello

    I wrote a few joins and usually in the final stage where condition with certain conditions be satisfied in where clause. In all conditions where I only want one and condition fulfilled only if both are collected.

    If we look at the this funciton is I should meet (get_order_type (ogr.order_number) <>'R')) AND wh1.third_party_warehouse! = 'Y') but I'm not get rid off both that if order_type is 'R' they are removed and if tooling_group is yes then ther are removed the result. I'm trying with both below pointed out together how can check these conditions? I can do in where clause?

    ((sg.tooling_stock_group <> 'Y'))

    and

    (get_order_type (ogr.order_number) <>'R'))

    Of order_goods_received ogr

    LEFT JOIN part_master pm

    On ogr.part_number = pm.part_number

    -stock_groups sg left join

    SG stock_groups left join

    on pm.stock_group = sg.stock_group

    and ((sg.tooling_stock_group! = 'Y'))

    and (get_order_type (ogr.order_number)! = 'R'))

    -Pm.stock_group = sg.stock_group

    LEFT JOIN batch_record_1 br1

    -A FEW MORE CODE HERE-

    WHERE ((ogr.delivery_date > = trunc (date_départ)))

    AND

    ((ogr.delivery_date < = trunc (end_date)))

    AND

    OGR.goods_received_number <>'1' AND

    get_order_type (OGR.order_number) NOT IN ('L') AND

    OGR.returned_to_supplier_indicator not in('S','L') and

    -sg.tooling_stock_group <>'Y '.

    -((sg.tooling_stock_group <> 'Y') and (get_order_type (ogr.order_number) not in ('R')))

    -(get_order_type (OGR.order_number) <>'R' AND sg.tooling_stock_group <>'Y')

    ((sg.tooling_stock_group <> 'Y'))

    and

    (get_order_type (ogr.order_number) <>'R'))

    AND wh1.third_party_warehouse! = « Y »

    UNION

    (

    Thank you.

    Whenever you have a problem with such logic, you should try and draw a logic state diagram:

    In your case, you are looking to two variables, with two possible States (equal to a value or is not it)

    Then, take this sense of the sg.tooling_stock_group T and O as being the get_order_type (ogr.order_number) and create a state diagram logical based on your description of what you want.  We will use a value of "Y" to indicate we want to record and a value of "N" to indicate the folder should not be returned.

    Start with an empty logical diagram...

    T = 'Y' T! = « Y »
    +---------+---------+
    |         |         |
    |         |         |
    |         |         | O = 'R '.
    |         |         |
    |         |         |


    +---------+---------+
    |         |         |
    |         |         |
    |         |         | O! = « R »
    |         |         |
    |         |         |
    +---------+---------+

    First of all, you said: "If there is the result returned by the defined user function is"R"and the table that has the tooling_stock_group y then it should avoid this record."

    T = 'Y' T! = « Y »
    +---------+---------+
    |         |         |
    |         |         |
    |    N    |         | O = 'R '.
    |         |         |
    |         |         |
    +---------+---------+
    |         |         |
    |         |         |
    |         |         | O! = « R »
    |         |         |
    |         |         |
    +---------+---------+

    Then you said: "If order_type does not return" R' but the tooling_stock_group is 'Y', then I should not avoid recording ".

    T = 'Y' T! = « Y »
    +---------+---------+
    |         |         |
    |         |         |
    |    N    |         | O = 'R '.
    |         |         |
    |         |         |
    +---------+---------+
    |         |         |
    |         |         |
    |    Y    |         | O! = « R »
    |         |         |
    |         |         |
    +---------+---------+

    Now, you have not given any logic for the rest of the diagram, so I made the assumption that you do not want to avoid these records...

    T = 'Y' T! = « Y »
    +---------+---------+
    |         |         |
    |         |         |
    |    N    |    Y    | O = 'R '.
    |         |         |
    |         |         |
    +---------+---------+
    |         |         |
    |         |         |
    |    Y    |    Y    | O! = « R »
    |         |         |
    |         |         |
    +---------+---------+

    Now there are different ways to determine the location of the clause of this diagram.
    We could say that we want the records for all of the T column! = "Y" or all the records for all of the O line! " = R...

    where (sg.tooling_stock_group! = 'Y' or get_order_type (ogr.order_number)! = 'R')

    We say we want to EXCLUDE (using DO NOT) all records where T = "Y" AND O = "O" "

    If not (sg.tooling_stock_group = 'Y' and (ogr.order_number) get_order_type = 'R')

    Those are the two most logical ways to do.
    (In my previous answer, that we can see in this diagram, there is no need of the "or get_order_type (ogr.order_number).) (= 'R' "part, which is superfluous, but would not break it)

    Now let's look at your logic to see what it looks like to in the diagram...

    where ((sg.tooling_stock_group <> «Y»))
    and (get_order_type (ogr.order_number) <> 'R')
    )

    In a logic diagram that looks to...

    T = 'Y' T! = « Y »
    +---------+---------+
    |         |         |
    |         |         |
    |    N    |    N    | O = 'R '.
    |         |         |
    |         |         |
    +---------+---------+
    |         |         |
    |         |         |
    |    N    |    Y    | O! = « R »
    |         |         |
    |         |         |
    +---------+---------+

    As you can see, your logic was only targeting one of the 4 possible results for select records and excluding 3.

  • Cannot run a «BUSINESS...» WHEN ' with a date in a WHERE CLAUSE condition

    Hello

    I need to check for a condition and date according to the date, he would check a set of host names or the other game... so I thought I could write something like this in the WHERE clause:

    AND HOST_NAME IN

    (

    CASE

    WHEN TO_DATE (: StopDate, 'MON-DD-YYYY') > = TO_DATE ('22 - DEC - 2015 "," DD-MON-YYYY ') THEN

    ('SERVERNAMEA', 'SERVERNAMEB', 'SERVERNAMEC') ON THE OTHER

    ("SERVERNAME1", "NAMESERVER2", "SERVERNAME3")

    END

    )

    I get the following:

    ORA-00907: lack of right parenthesis

    00907 00000 - "lack the right parenthesis.

    But there is no missing parentheses!

    If I take the case... when... end, and run the host_name in ('SERVERNAMEA', 'SERVERNAMEB', 'SERVERNAMEC') (separately, they run fine)...

    I also tried:

    AND

    (

    CASE

    WHEN TO_DATE (: StopDate, 'MON-DD-YYYY') > = TO_DATE ('22 - DEC - 2015 "," DD-MON-YYYY ') THEN

    HOST_NAME IN ('SERVERNAMEA', 'SERVERNAMEB', 'SERVERNAMEC') ELSE

    HOST_NAME IN ('SERVERNAME1","NAMESERVER2","SERVERNAME3")

    END

    )

    the error I get is:

    ORA-00905: lack of keyword

    00905 00000 - 'lack the key word'

    What keyword miss me?

    Post edited by: c75d2e42-06a0-4eb1-a576-5652edcbfbe8

    Hello

    c75d2e42-06a0-4eb1-A576-5652edcbfbe8 wrote:

    It was a typo when transferred to the Oracle forum... the version of Oracle is: PL/SQL version 10.2.0.3.0 (10 G)

    I also used IF the statement and that has not worked (in error "missing parenthesis") which I'm sure is a matter of "syntax"... I did not know that the CASE statement returns the value single only, so it's probably the problem.  Is it possible to re - write this?

    ...

    IF only works in PL/SQL.  It does not in SQL, even if that SQL is embedded in PL/SQL.

    There are many ways to re - write the condition.  And here's one:

    AND ((host_name IN ('SERVERNAMEA', 'SERVERNAMEB', 'SERVERNAMEC')

    AND TO_DATE (: StopDate, "MON-DD-YYYY") > = TO_DATE ('22-DEC-2015', "MON-DD-YYYY")

    )

    OR (host_name IN ('servername1","Nameserver2","SERVERNAME3")

    AND TO_DATE (: StopDate, "MON-DD-YYYY")<  to_date="" ('dec-22-2015', ="">

    )

    )

    If: StopDate can be NULL, it must be a bit more complicated.

    You can also use nested, such as CASE expressions

    AND THE CASE

    WHEN TO_DATE (: StopDate, "MON-DD-YYYY") > = TO_DATE ('22-DEC-2015', "MON-DD-YYYY")

    WHILE CASE

    WHEN host_name IN ('SERVERNAMEA', 'SERVERNAMEB', 'SERVERNAMEC')

    AND THEN 'OK '.

    END

    OTHER CASES

    WHEN host_name IN ('servername1","Nameserver2","SERVERNAME3")

    AND THEN 'OK '.

    END

    END = 'OK '.

    I wonder if this in your application is the best way, however.  If SERVERNAMEA was put into service on December 22, maybe that that fact should be recorded in a table.  If you have a table with 1 row per server, you can consider adding 2 columns DATE to show when the server was first and last used.  Then, rather than use a WHERE clause to test servers appropriate, you could do an inner join.

  • [JDev ADF] How is made the ' where clause ' default display criteria "all searchable attributes?

    Hallo,


    on a view object, I create my view of the criteria customized; I'm going to use it to create a "query with the table panel.

    I wish that his beahviour, when I use it to create a "query with the table panel", corresponds to that of "attributes searchable all.

    Unfortunately I'm having some trouble in his creation and I would like to see how is made the "object view where Clause" CV "all searchable attributes.

    My VO motion is:

    Select the username, name, RegisteringDate

    I would like to create my VC in a way that is the result "query with table Panel:

    UserId | ___ |

    Name | ___ |

    RegisteringDate of | ___ | to |_________|

    For each search field, I set a variable binding (PName, PUserId, PRegisteringDateTo, PRegisteringDateFrom).

    Each field must be used in the "query with table Panel" only if it is filled with a value.

    You kindly help me?

    Thank you very much

    F.

    The criteria to view all searchable attributes is implied all the attributes of a vo. Each attribute is used unless you specify a value for it. The problem with this IS, is that you can not change it.

    However, you can build your own RESUME that works in the same way, but allows you to change certain attributes. To do this, you create a new business card and add each attribute, select the operation you want to test the attribute against (equals, start by,...). You do not bind variables for attributes specify. The framework will add them for you automatically.

    The only thing that can not this vc is check varies as you want to do when you check "RegisteringDate." To do this you must use bind variables.

    Once you have create this EGG and it makes you drag onto the page you can use it as the "all attributes searchable.

    Timo

  • Using decode in where clause

    Hello

    I need to use decode condition in where clause in such a way that if the respective column is null then consider the corresponding column

    for example

    Fee_dateFee_refund_date
    10 OCTOBER 05
    12 NOVEMBER 05
    11 JANUARY 06
    16 FEBRUARY 06

    I have a request in place as below where p_fee_flag will be passed as either FEES or set to null, I check another condition as if p_fee_flag is null then fee_date must be set to null when comparing fee_refund_date between TRUNC (BKT. ACT_START_DATE) AND TRUNC (BKT. ACT_END_DATE

    SELECT 1

    BUCKET BKT

    WHERE DECODE (P_FEE_FLAG, 'FEES', TRUNC(FS.) FEE_DATE), TRUNC (FS. FEE_REFUND_DATE))

    BETWEEN TRUNC (BKT. ACT_START_DATE) AND TRUNC (BKT. ACT_END_DATE)

    944524 wrote:

    Hello Alberto,.

    Thank you that's what I ask but is it possible to verify the condition even using decode

    Yes, it is possible, but why?

    Just replace the query in this way:

    select *
      from fee_table f
    where exists(select 1
                    from bucket b
                  where decode(:p_fee_flag, 'FEE', f.fee_date, f.fee_refund_date) between b.act_start_date and b.act_end_date)
      and decode(:p_fee_flag, 'FEE', null, f.fee_date) is null;
    

    Kind regards.

    Alberto

  • long data type in where clause

    Hello

    I need to select in an Oracle table with a column having
    Long data type and Oracle does not use this column in the
    WHERE clause. Doco Oracle suggests that the columns with LARGE data types may
    only be used in the select statement (not in the CASE or any other
    conditional clause).

    Anyone know any work around for this problem?

    What is the way to see the value of long data type?

    How can we use them in where clause?

    We can all utility to display the specified records? There are Lakes of records...


    I ned use it in where clause...

    Thanks and greetings
    VD

    Published by: vikrant dixit on November 23, 2008 22:47

    So can OK we use CLOB/BLOB in where clause?

    Yes, you can query the LOB columns using the package (F.ex.SUBSTR or INSTR) DBMS_LOB functions.

    Why u say that the result is FTS?

    This would result in FTS as you cannot index LARGE data or create a function based on the column index.

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/sql_elements001.htm#sthref149


    LONG columns cannot be indexed.

    No other way to my knowledge.

    You can convert the LOB column with function TO_LOB as described in

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/functions185.htm#i79464

    Published by: Sissi Kandi on November 24, 2008 12:28

  • DB2 where clause problem

    Hello

    I want to use where clause in the View with BindVeriable object.

    How can I use?

    Concerning

    Kiran SANCHEZ

    You cannot use Oracle bind variables when you use DB2. Use JDBC positional Binding Style in your query. You can use something like this in your where clause:

    Where Field1 =? AND Field2 =?

    Then set the 2 variables bind bind positions 0 and 1.

    Make sure that you used DB2 Sql-flavor and a Java type map when creating business logic of your application (the first time you create a component of business adf).

Maybe you are looking for