Question about WHERE Clause

Hello

I'm doing a conditional clause where clause displays the lines in a report.

The desired control is date of two fields (CIC and announcement) must all be virgins or someone not be an 'Admin' (taken from a global variable stored on connection) for her to no display.

Here's what I have:

WHERE (DATACOLLECT. ANNOUNCEMENT_OF_DEAL_SIGN IS NOT NULL AND DATACOLLECT. CHANGE_IN_CONTROL IS NOT NULL) OR UPPER(:F19959_USER_ROLE) = "ADMIN".

During the test of this query, it hides a field with ONE of the two dates being blank and which is not desirable.

I also tried to write it like this and got an error of analysis for an invalid relational operator:

WHERE (DATACOLLECT. ANNOUNCEMENT_OF_DEAL_SIGN AND DATACOLLECT. CHANGE_IN_CONTROL IS NOT NULL) OR UPPER(:F19959_USER_ROLE) = "ADMIN".

Any help would be greatly appreciated. Please let me know if I need to clarify.

I take what I said back.  Your requirement of "double negative" is odd

DO NOT SHOW: where (X is null and Y is null)

translates

Show: where not (x is null and Y is null)

WHERE NOT (DATACOLLECT. ANNOUNCEMENT_OF_DEAL_SIGN is null AND DATACOLLECT. CHANGE_IN_CONTROL IS NULL) OR UPPER(:F19959_USER_ROLE) = "ADMIN".

MK

PS - this is a thing of database.  PL/SQL and SQL would have been a better choice

Tags: Database

Similar Questions

  • Question of WHERE Clause.

    All, I was just doing some checking at random and came across the following query

    SELECT * FROM emp WHERE +empno > 0;
    

    My question is that oracle runs the query above without any error. What is the use of such expressions in where clause and why the compiler does not throw error for these?

    I've never met such scenario. Just tried your query and it works. The reason is below.

    Look at what makes this request.

    SELECT - empno FROM emp;

    OUTPUT:

    -EMPNO
    ----------
    -7369
    -7499
    -7521
    -7566
    -7654
    -7698
    -7782
    -7788
    -7839
    -7844
    -7876

    -EMPNO
    ----------
    -7900
    -7902
    -7934

    14 selected lines.

    So you might see if you add a minus sign before the name of the column, it converts only for negative values.

    So, even if you add a sign "+", since these are positive values (> 0), your condition succeeds and gives the result. See what would happen if you used - empno in which your condition.

    SQL > SELECT * FROM emp WHERE empno - > 0;

    OUTPUT:

    no selected line

    Hope you clear how it works.

  • Statement UPDATE of SQL TIP about WHERE CLAUSE

    (1) Oracle does support SQL UPDATE statement of SUSPICION for WHERE CLAUSE
    (2) if so, then please give example.
    Thank you.

    Hello

    Yes, it is possible to use the "tips" in the Update statement

    Sake example

    Update
    / * + rowid * /.
    tableX
    Set char_date = '19' | char_date
    where nvl (length (char_date), 0) = 6
    and rowid between chartorowid ('000927.0000.0008')
    and chartorowid('000A3F.) FFFF.0008');

    http://Stanford.edu/dept/ITSS/docs/Oracle/10G/server.101/b10752/hintsref.htm#27647

    -Pavan Kumar N

  • Question about the clause for the EVE of BACKUP command

    Hello

    I would like to know the exact difference between BACKUP CONTROLFILE CURRENT and BACKUP CONTROLFILE CURRENT for INTELLIGENCE in Oracle 11 g. I searched the docs and My Oracle Support OTN, but still I have not found an answer. I would be grateful for any explanation or references.

    Thanks in advance.

    Hello

    Allows to consider from scratch,

    What is a controlfile :--> its a small binary file that records the physical structure of the database.
    The control file includes:
    The name of the database
    The names and locations of the partners of the data files and redo log files
    The timestamp of the creation of the database
    The current sequence number
    Control point information

    Now, down to backup controlfile--> will have the exact backup of the controlfile used by the database (including the role of the database) Please note that this controlfile cannot serve as a controlfile standby when you try to use it it will return the error

    Backup controlfile as Eve--> will anything similar as for the previous command except for the role of database that are not primary indicator but would be pahysical Eve, all other information would be same.. like with it it will not be an exact replica of the primary database.

    It is the only difference from what I understand concepts.

    Regrads

  • Question about the order of evaluation of the clause WHERE CLAUSE when the Oracle OF the syntax used to join tables

    Hello

    Oracle version: 11.1.0.7.0 - 64 bit

    I read the documentation online at joins. The page is avialable here: joins at

    My question is about the join order of evaluation of the conditions in clause and the conditions of those

    are not the join conditions and are placed in the WHERE clause.

    Consider the following pseudocode

    SELECT

    T1. Col1,

    T2.Col1

    Of

    Table1 t1 LEFT OUTER JOIN table2 t2

    WE

    (condition_expression1)

    WHERE

    (condition_expression2)

    Is it correct to say that if there is no column on the status of join (condition_expression1) in condition_expression2, then condition_expression2 is executed before condition_expression1? In other words, oracle always trying to filter based on the WHERE clause individually each table as much as possible before joining them based on the conditions on the article?

    Thanks in advance,

    Hello

    dariyoosh wrote:

    Hello

    Oracle version: 11.1.0.7.0 - 64 bit

    I read the documentation online at joins. The page is avialable here: joins at

    My question is about the join order of evaluation of the conditions in clause and the conditions of those

    are not the join conditions and are placed in the WHERE clause.

    Consider the following pseudocode

    SELECT

    T1. Col1,

    T2.Col1

    Of

    Table1 t1 LEFT OUTER JOIN table2 t2

    WE

    (condition_expression1)

    WHERE

    (condition_expression2)

    Is it correct to say that if there is no column on the status of join (condition_expression1) in condition_expression2, then condition_expression2 is executed before condition_expression1? In other words, oracle always trying to filter based on the WHERE clause individually each table as much as possible before joining them based on the conditions on the article? ...

    The reverse is actually closer to the truth, but we can't really make general statements like that.

    SQL is not a language of the proceedings.  Looking at the code SQL, we could say that the code does, but we cannot say much about how that code it.  In other words, SQL is a language that describes the results you get, not the way to get them.

    The optimizer will do everything what he thinks is faster if it does not change the results.  If any order in which they are applied (in outer joins or CONNECT BY queries, for example), then think of the join is done first, and the value of the WHERE clause is applied to the result of the join.

    Here is a query looks very much like you posted:

    SELECT d.deptno

    e.ename, e.sal

    OF scott.dept d

    LEFT OUTER JOIN scott.emp e ON e.deptno = d.deptno

    WHERE e.sal > = 3000

    ORDER BY d.deptno

    ;

    Output:

    DEPTNO ENAME SAL

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

    10 KING 5000

    20 FORD 3000

    20 3000 SCOTT

    The scott.dept table contains deptnos 30 and 40; Why are they not in the result set?  The query behaves as if the outer join is made first (production 15 rows), then the WHERE clause has been applied.  All lines with deptno = 30 had sals down han 3000 and all single line with deptno = 40 was NULL in the sal column, then these lines are excluded (as well as other lines of deptnos 10 and 20), and only 3 lines above are left.

  • Where and how do I ask questions about Email?

    The Commission opening thingy is complicated, I have trouble finding my way around it.  I don't know where or how questions about email.  Is there an easier way than trawling through all these icons?  Like a list or something - as you get on all other forums on the internet?

    It would be a good starting point: Mac mini

    Or the appropriate under MAC Os and system software section.

    You might also find this useful: find answers and new questions

  • where to post a question about iTunes on the iPhone?

    I have a question about a problem with iTunes on the iPhone (iOS), but I do not see a 'Community' with this title (or anything close;  I have no idea what "iTunes U" means).

    For lack of a better idea, I just posted to the community "iTunes for Mac", but I don't think that's true.

    Please let me know where I should post to an iTunes on iPhone issue.  Thank you.

    It should probably be posted in the community Using iPhone Apple Support communities. I'll ask a host spend your question in iTunes for Mac, if it has not already been moved.

    EDIT: Just read your message, and I think it's probably better where it is (because you need help syncing your songs via iTunes on your Mac). He should be fine here, but if the moderators believe that he should be somewhere else, they will move for you.

  • Where can I post a question about wmp?

    Where can I post a question about wmp?

    This place you have chosen is the right place, you can ask here questions about windows media player

  • Where should questions about the JDEV/ADF positions?

    Hello

    Where should questions about the JDEV/ADF positions?

    JDeveloper and ADF or

    JDeveloper and ADF?

    I found there may be some different advantageous:

    https://forums.Oracle.com/message/11109674?TSTART=0#11109674

    Thank you.

    Well, the other forum you mentioned is the Korean equivalent of the English forum.

    You have already discovered, it is not controlled to many users. I didn't know that it exists at all.

    In general it is to you where you ask your questions. All for one here are driven by the community and some employees of the Oracle, you cannot wait has answered all your questions. If you really need to answer you go through paid support.

    A tip for getting help is to provide a well-defined use cases, information relating to your environment and documented code showing what you have already tried.

    Timo

  • WHERE clause order ox performance question

    I do not understand order of execution of a WHERE clause, the use of a complex database

    I want to write a SELECT statement with the following condition

    ... WHERE (branch = 'main') AND (type = 1) OR (AND the costs-1 = 2).

    My question is

    < 1 > yoyu can use parentheses within a WHERE clause

    < 2 > how you would write such a clause as above if you cannot use parenthesis

    Thank you

    Hello

    Yes, you can have parentheses in a WHERE clause.
    I highly recommend to use when you need to use both AND and or in the same WHERE clause, since

    WHERE  (    x
            AND y
            )
    OR      z
    

    is not the same as

    WHERE   x
    AND     (   y
            OR  z
            )
    

    As others have said:

    ( charge -1 AND charge = 2 )
    

    will cause a compilation error.
    Here's the syntax valid and quite reasonable (although somewhat obscure):

    WHERE     (     branch = 'main'
         AND     type    = 1
         )
    OR          (     charge != -1
            AND     charge !=  2
         )
    
  • Where can I ask a handful of general order questions about Firefox OS as a consumer and get the answers? (a forum or something similar)

    I have about seven questions about Firefox OS. I'm potentially interested in opting for a tablet that works instead of Android or iOS. I couldn't find a place to ask questions like that. Thank you!

    https://support.Mozilla.org/en-us/forums/Firefox-OS-English-Forum

    There is another option.

  • Where should I post questions about Windows 8?

    I intend to install the Windows 8 consumer overview once it is published next week. What forum is used for questions about W8?

    Noel

    Thanks for all the suggestions. Just for the sake of the of the cleanliness, here's the answer:

    Overview of Windows 8 consumer

    Noel

  • Where-Clause-Question by using "defined values.

    Hello

    I use 10 gr 2

    It is possible to filter the lines using sets of values in the where clause?

    As for example:
    SELECT a, b, c
      FROM mytable
      WHERE (b,c) IN
        (
          (3,4),
          (6,7),
          (9,1),
          (0,2)
        )
    .. must retrieve only the rows from myTable with sets (pairs) over the top of the list

    It is not difficult to test:

    with my_tab as (select 1 a, 2 b, 3 c from dual union all
                    select 2 a, 2 b, 2 c from dual)
    select * from my_tab
    where (b, c) in ((1,2), (2,3));
    
             A          B          C
    ---------- ---------- ----------
             1          2          3
    
  • Binds a parameter in WHERE clause throws error (ORA-00920)

    Good day to you all.  Hope everything goes well.

    Ok.  Here's the deal.  I am trying to bind a parameter in a where clause clause, but I continue to get the error invalid relational operator (ORA-00920).  It seems as if Oracle is looking for a correct syntax before you pass the variable (bind value).

    For example:

    SELECT LAST_NAME, FIRST_NAME FROM MYTABLE
    WHERE OBSOLETE IS NULL
    and :P_MY_BIND_VALUE
    

    What is the right way to get around this?

    Thanks for all your help!

    AquaNX4 wrote:

    Thank you for the reply.

    I use simple SQL.  The variable binding will be used in the APEX and an item that is based on a LOV with where condition stored there.  Make sense?

    Logic you want... doesn't have a sense of how you try to do.

    Bind variables are for the passage of the 'values' to a question, only not for the passage of the SQL statements or sections of objects such as the names of tables etc.  It is not a substitution string such as the use of '&' in SQL * more and should not be treated this way.

    If you could provide more details on exactly what you're trying to do (some data would help) then perhaps we could tell how best to go about this.

  • Case statement in a WHERE clause

    Gurus,

    Im trying to avoid Union of several select statements using a CASE inside a WHERE clause. When the parameter is defined as "What's new" it is advisable to use a code and for "Update Items" another condition.

    Having a problem with the following... I know that BOX in WHEREs instructions are allowed only can not make it work for this one.

    and case  when 'New Items' = 'xxx' --p_item_status 
             then  msi.creation_date = msi.last_update_date
          when 'Updated Items' = 'bbb' --p_item_status  
             then  msi.creation_date != msi.last_update_date
          else 1=1
    end;  
    Points for correct and helpful answers!

    Published by: sreese on March 27, 2012 17:51

    Hello

    The great thing about CASE expressions, is that they allow you to use a login IF-THEN-ELSE in the clause SELECT, the ORDER BY clause or anywhere else. The WHERE clause has its own way to IF-THEN-ELSE logic, so even if you can use a CASE expression in a clause WHERRE, it usually does not help anything. You can do somehting like this:

    WHERE     (     :p_item_status        = 'New Items'
         AND     msi.creation_date  = msi.last_update_date
         )
    OR     (     :p_item_status        = 'Updated Items'
         AND     msi.creation_date  != msi.last_update_date
         )
    OR     (     :p_item_status        NOT IN ( 'New Items'
                               , 'Updated Items'
                               )
         )
    

    This guess: p_item_status is not NULL.
    If: p_item_status can be NULL, and you want to include all the lines where it is, and then change the last condition to

    OR     ( NVL (:p_item_status, 'OK') NOT IN ( 'New Items'
                                 , 'Updated Items'
                                 )
         )
    

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions), some values of the parameter and the expected results of these data for each value of the parameter.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

Maybe you are looking for