How to compare in Where clause

Hello

I need help comparing the value in where clause


There is a table called productivity which has columns as
OBJECT_TYPE, COMPLEXITY, OBJECTIVE


Now my requirement is I have a query like this


SELECT
PRO. PROJECT NAME,
POBJ. OBJECT_NAME,
POBJ.COMPLEXITY,
PRO. EFFORT
Of
PROJECT PRO, PROJECT_OBJECTS POBJ
WHERE
PRO.ID = POBJ.ID

I have to compare data between the effort of columns in the query and target in the table of productivity

SELECT
PRO. PROJECT NAME,
POBJ. OBJECT_NAME,
POBJ. OBJECT_TYPE,
POBJ.COMPLEXITY,
PRO. EFFORT
Of
PROJECT PRO, PROJECT_OBJECTS POBJ
WHERE
PRO.ID = POBJ.PRO_ID



now I change the query to compare


SELECT
PRO. PROJECT NAME,
POBJ. OBJECT_NAME,
POBJ.COMPLEXITY,
-case when
POBJ. OBJECT_TYPE IN (SELECT OBJECT_TYPE OF PRODUCTIVITY) AND
POBJ.COMPLEXITY (SELECT COMPLEXITY OF PRODUCTIVITY)
PRO. EFFORT > (SELECT GOAL OF PRODUCTIVITY WHERE type_objet =? AND
COMPLEXITY =? ) / / here instead of? I have to say
POBJ. OBJECT_TYPE and POBJ.COMPLEXITY
then
10
ON THE OTHER
0
END "Effort."
Of
PROJECT PRO, PROJECT_OBJECTS POBJ
WHERE
PRO.ID = POBJ.PRO_ID


How to specify this POBJ column. OBJECT_TYPE and POBJ.COMPLEXITY in please of? I put please suggest.

Is there a way where we can spend the value of POBJ. OBJECT_TYPE and POBJ.COMPLEXITY to a variable binding and select it in the where clause

Indicate please let me know if this issue is not understood.


Thank you
Sudhir

Something like that, maybe?

SELECT PRO.PROJECT_NAME,
       POBJ.OBJECT_NAME,
       POBJ.COMPLEXITY,
       case when PRO.EFFORT > PROD.GOAL
                 then 10
            ELSE 0
       END "Effort"
FROM   PROJECTS PRO,
       PROJECT_OBJECTS POBJ,
       PRODUCTIVITY PROD
WHERE  PRO.ID = POBJ.PRO_ID
AND    POBJ.OBJECT_TYPE = PROD.OBJECT_TYPE (+)
AND    POBJ.COMPLEXITY = PROD.COMPLEXITY (+)

I did an outer join; don't know if that's what you want - if not, just get rid of the (+) {noformat} {noformat}

Tags: Database

Similar Questions

  • How to dynamically generate where clause in Linq

    Hi all


    Oracle DB: 11 gR 2
    Oracle Client: 11.2.0.3.0 (ODP.NET)
    Oracle Developer Tools for Visual Studio
    VS 2010 (C#)

    In a Windows Form, it must query the data based on the values in list dropdown listboxes, which the user selects.
    Let's say two combox, one Department and one for salary
    Department:
    -1 all the
    10 Department 1
    20 Department 2
    30 Department 3

    Salary:
    -1 all the
    1 < 20000
    2 20000 to 50000
    3 50000 to 100000
    4 > 100000


    Here is the c# code to query data:
    using (var myEDMctx = new HREntities())
    {
    var LINQrslt = from emp in myEDMctx.EMPLOYEES
    Select emp;

    }


    The default values for the two combox should be everything.
    How to write dynamic where clause for this LINQ?

    Thanks in advance!

    That's what I do.

    var query = from c in customers
    Select c;

    If (where1 > - 1).
    Query = query. Where(c.Where1 > where1);

    If (where2 > - 1).
    Query = query. Where(c.where2 == where2);

    to return the query;

    Published by: Invincible on July 4, 2012 09:25

    Published by: Invincible on July 4, 2012 09:27

  • [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

  • How to define a WHERE clause of the subquery in a bean managed?

    Hi people,

    is it possible to define the place where clause of a subquery in a bean managed?
    For example, it is more SQL charly:

    SELECT * FROM
    (SELECT Person.Name
    OF the person)

    To change or add a WHERE clause, I use following code for the 'viewObject: view

    String whereClause = "ROWNUM < =: numberOfRows;
    viewObject.setWhereClause (whereClause);

    viewObject.defineNamedWhereClauseParam ("numberOfRows", null, null);
    viewObject.setNamedWhereClauseParam ("numberOfRows", new Number (100));

    AttributeList myattr = this.getNamedWhereClauseParams ();
    viewObject.setNamedWhereClauseParams (myattr);

    For example, this code works well for the first SELECT statement limit the output to the first 100 results. But how do I add a WHERE clause of the subquery in a managed bean? For example, when I want to limit the names of people that begin with the letter "A"?
    The query should look like this:

    SELECT * FROM
    (SELECT Person.Name
    OF the person
    WHERE Person.Name LIKE 'A %')

    Anyone know more?

    Thank you!

    Put a variable binding in your query, something like:

    where (: bv is null) or (xxx love: bv)

    John

  • How only include a WHERE clause only when a connection variable has a value?

    I use JDeveloper 11 g using business components of the tables. I'm now modify the auto-generated SQL code to include WHERE clauses which depend on the values of bind variables. For example I have something like this:
    SELECT mytable.firstColumn
    FROM myTable 
    WHERE myTable.secondColumn= :VariableValue
    However, this means that when VariableValue is null SQL would fail and I get an error. Is there a way I can include the WHERE clause (or clause AND according to the position in SQL) only when a bound variable has a value (or a particular value)?

    Or use: WHERE NVL(:VariableValue,myTable.secondColumn) = myTable.secondColumn

  • How to set a null column in a where clause clause involving a statement box

    In oracle APEX, I a (selection list) element called: P32_STATUS. It contains two values of interest (for this discussion): 'Available' and 'checked '. In my report, I have a column called vc_status that contains two values: "Checkbox" and NULL. In my application I want to use a case statement in my where clause similar to the lines of

    where

    .

    .

    .

    AND (vc_status = CASE WHEN: P32_STATUS = "Checkbox" THEN : P32_STATUS )

    WHEN : P32_STATUS = 'Available' THEN NULL END)

    The 'box' filtering works but the filtering to try to vc_status the NULL value does not work. Can someone help me? Thank you!

    (P.S. My intuition says that there because I can not put vc_status = NULL, but I must say that vc_status IS NULL... However, I don't know how to do execution IS ZERO inside a CASE statement)

    Hello

    Your intuition is right...

    In Oracle NULL is a bit special:

    NULL = NULL is false

    NULL <> NULL is false

    Thus, instead of the parameter a NULL value in the CASE WHERE there is just set a value on the other side:

    NVL (vc_statut, 'Available') =: P32_STATUS

    That's all! Simple, clean and functional

  • [ADF, JDev12.1.3] How to set a variable to bind a VO (where clause) in a managed bean?

    Hallo,

    I have a request based on VO.

    The query contains a where clause clause and a bindi variable.

    In a managed bean I would like to access the iterator of VO setting the value of the bind variable and read the result.

    I found this code it is good start, but I do not know how to set the variable binding.

    BindingContext bctx = BindingContext.getCurrent();
    BindingContainer bindings = bctx.getCurrentBindingsEntry();
    DCIteratorBinding iter = (DCIteratorBinding ) bindings.get("MyVO1Iterator");
    iter.execute();
    
    
    

    You kindly help me?

    Also, I would like to know if it is generally advisable to use VO directly in controlled beans or whether it would be best to create in the AppModuleImpl methods that do this and return the result.

    In my case for example of the VO will return max 1 plug so I'm in doubt, if the creation of a method in the AM that returns a custom class, which attributes contain values of the line of VO.

    Sorry if these questions may seem artificial, but I am a beginner, I have many doubts and so I would be happy to receive some tips regarding best practices.

    Thank you

    Federico

    You can use:

    iter.getViewObject().setNamedWhereClauseParam("yourBindVar", value);
    

    Note that this approach is used if you have bind variable in the where clause.

    To set variables bind to ViewCriteria, you must use VarableValueManager.

    This post may be useful for you: binary: how to set the Bind variable values at run time?

    Also, I would like to know if it is generally advisable to use VO directly in controlled beans or whether it would be best to create in the AppModuleImpl methods that do this and return the result.

    You must set "use VO directly.

    For example, from the point of architecture, is probably best to use the method in the model project which will set the bind variable and execute the query.

    Or you can use the ExecuteWithParams operation in your the view layer.

    In my case for example of the VO will return max 1 plug so I'm in doubt, if the creation of a method in the AM that returns a custom class, which attributes contain values of the line of VO.

    Not to complicate your life

    All VO lines are represented as ViewRowImpl class if you already have "custom class".

    Finally, you can generate your own ViewRowImpl class if it is necessary for this.

    Dario

  • How to use the instruction box in where clause

    Hi all


    I need to use cases where clause guide me please how I can do it.


    AND WHEN BOX: KAPCO = "KAPCO" THEN cla. CLASS_NAME LIKE '% KAPCO % '.
    WHEN: KAPCO = "NON_KAPCO" THEN SUPERIOR (cla. CLASS_NAME) NOT LIKE '% KAPCO % '.
    WHEN: KAPCO = 'ALL' GOLD: KAPCO IS NULL SO SUPERIOR (cla. CLASS_NAME) LIKE '% '.
    END



    Concerning

    Published by: user10941925 on March 4, 2012 22:31

    Hello

    CASE expressions return a single value, for example a VARCHAR2. They do refer to code fragments.

    You usually don't need (or want) an expression BOX in a WHERE clause, or any other condition. I think that you were trying to do the equivalent of:

    AND     (     (:KAPCO = 'KAPCO'          AND cla.CLASS_NAME       LIKE '%KAPCO%')     -- Don't you want UPPER on this line?
         OR     (:KAPCO = 'NON_KAPCO'           AND UPPER(cla.CLASS_NAME) NOT LIKE '%KAPCO%')
         OR     (NVL (:KAPCO, 'ALL') = 'ALL'       AND cla.CLASS_NAME IS NOT NULL)
         )
    

    If you would care to post some sample data (CREATE TABLE and INSERT statements) and the results desired from this data, I was able to test this.

  • How to create a procedure for REF CURSOR output with any WHERE clause?

    I have a requirement like this: I have a huge question that need to reuse in my code over 10 times. This SQL has about 50 lines. Here for these 10 odd times sometimes changes in WHERE clause (columns are the same). So I can't create a view as SQL is not static.

    I thought to write a procedure with a para of WHERE_CLAUSE entry. I pulled out a refcursor sys by adding where clause. But I can't do it because you cannot add a clause like this where clause.

    i.e.
    PROCEDURE dynamyic_query (p_where_clause IN VARCHAR2, p_out_query OUT SYS_REFCURSOR ) IS
    BEGIN
    
      OPEN p_out_query FOR SELECT ......... FROM table WHERE || ' ' || p_where_clause;
    
    END;
    The foregoing gives an error.

    How to handle such a situation? Any help would be greatly appreciated.

    Hello

    Channa wrote:
    ... However, when I change the procedure like this:

    PROCEDURE FORMS_TEXT_DYN_SQL_TEST(p_where_cluase IN VARCHAR2, p_out_cursor OUT SYS_REFCURSOR) IS
    v_stmt VARCHAR2(1000);
    BEGIN
    v_stmt := 'SELECT tname FROM tab_test WHERE tname LIKE ''%ABS_V4%'' AND :y';
    
    OPEN p_out_cursor FOR v_stmt using p_where_cluase;
    
    END;
    

    And run this block of code:

    declare
    v_tname varchar2(200);
    out_cursor sys_refcursor;
    begin
    forms_text_dyn_sql_test(' 1 = 1 ', out_cursor );
    LOOP
    fetch out_cursor INTO v_tname;
    exit when out_cursor%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(v_tname);
    END LOOP;
    end;
    /
    

    I get the error:

    [1]: (Error): ORA-00920: invalid relational operator ORA-06512: at "ABS.FORMS_TEXT_DYN_SQL_TEST", line 6 ORA-06512: at line 5
    

    Looks like you can only set column_name =: z, column_name =: values of type y. You can not it seems to replace it with no WHERE CLAUSE?

    A bind variable, such as: it, represents a single value.
    If: is the VARCHAR2 '1 = 1', then

    SELECT tname FROM tab_test WHERE tname LIKE '%ABS_V4%' AND :y
    

    takes the value

    SELECT tname FROM tab_test WHERE tname LIKE '%ABS_V4%' AND '1 = 1'
    

    I think you want something like this:

    CREATE OR REPLACE PROCEDURE FORMS_TEXT_DYN_SQL_TEST
    (     p_where_clause      IN      VARCHAR2
    ,      p_out_cursor      OUT      SYS_REFCURSOR
    ) IS
      v_stmt VARCHAR2(1000);
    BEGIN
      v_stmt := 'SELECT ename FROM scott.emp WHERE ename LIKE ''%A%'' AND '
              || p_where_clause;
    
      OPEN p_out_cursor FOR v_stmt;
    
    END;
    /
    show errors
    
    SET  SERVEROUTPUT  ON
    
    declare
      v_tname varchar2(200);
      out_cursor sys_refcursor;
    begin
      forms_text_dyn_sql_test(' 1 = 1 ', out_cursor );
      LOOP
        fetch out_cursor INTO v_tname;
        exit when out_cursor%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(v_tname);
      END LOOP;
    end;
    / 
    

    Output:

    ALLEN
    WARD
    MARTIN
    BLAKE
    CLARK
    ADAMS
    JAMES
    
  • How to pass a value LOV to where clause of another LOV

    Hello

    I have the two LOV project and activity. When I select a value of project LOV this value project to switch to the 2nd activity LOV where clause. How can I achieve this.

    I tried to use the code in the process CO request by getting the value of project with the command below.

    int v_project = Integer.parseInt ((String) passiveCriteria.get ('Project')); grab the critirea project

    and set this value in the setwhereclauseparams of the VO LOV. But the above command is throwing an exception with the exception of null pointer.

    This approach is correct, or should I use any other method.

    Thank you
    HC

    Below you will find the article interesting

    http://oracleanil.blogspot.com/2010/12/dependent-lov-in-OAF.html

    Thank you
    AJ

  • How to solve where clause matter when it can have a value or be null.

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

    Hello, I am trying to understand how a query in which I have a where clause clause that can be null or a value, that is to say:
    SELECT   supply,
                  duration,
                  count,
                  action
    FROM     MDR
    WHERE    (client     = gbl_client OR (group = gbl_group AND section = gbl_section ))
    AND      (prov_code   = gbl_prov_code );
    In the query, the gbl variables can have a value or be null, based on the results of a previous cursor. The problem is that if they have the value NULL, I don't get the correct results because where clause will have to be modified to be checked IS NULL instead of = gbl. Is it possible to do it by modifying select it?

    Hello

    Because these columns are all strings, the CONCAT method will work fine:

    SELECT     *
    FROM     mdr
    WHERE     '?' || grp       = '?' || glb_grp         -- GROUP is not a good column name
    AND     '?' || section    = '?' || glb_section
    AND     '?' || prov_code  = '?' || prov_code
    ;
    

    I think that the code is a little nicer with the '?' before the actual data. No matter whether it is before or after, just be consistent.

    Published by: Frank Kulash, January 25, 2011 15:59

  • How to use a function in a Where Clause?

    Hello
    I have a doubt. If MY_FUNCT is a function that returns a Boolean value, can I use in a where clause clause to write a query like this? :

    Select...
    table one
    where the...
    *...*
    and MY_FUNC (a.field) = true
    *...*
    *;*

    Thank you!

    Published by: Mark1970 on 3.27 lug-2-2010

    But is it possible that the function does not return a Boolean value?

    Yes (as sysdate, substr and instr etc.) you can also use your own function in a where clause clause, as long as it does not return a BOOLEAN value.

    I mean how to use a function in a where clause clause?

    Your own pseudocode seems a good example for me.
    So, just give it a try.

  • How to set SQL that contains 'in' where clause in VO?

    I don't want to set "in" would adopt a kind of programatical in VO as below. I want to use a method declariable to set in the clause using bindings varaible.

    It can be implemented?

        private String getInClauseWithParamNames(List termCodes) {
               //logic to form the in clause with multiple bind variables
               StringBuffer inClause = new StringBuffer(); 
               if(termCodes !=null){
                   for (int i = 1; i < termCodes.size() + 1; i++) { 
                       inClause.append(":termC" + (i));
                       if (i < termCodes.size()) { 
                          inClause.append(","); 
                       } 
                   }
               }
               return inClause.toString();
        }
            
        public Row[] getYardFixedSlots(List termCodes) {
            if(termCodes != null && !termCodes.isEmpty()){
                String inClause = getInClauseWithParamNames(termCodes);
                //setting the where cluase to use the generated in clause
                this.setWhereClause("YardFixedSlot.TERMINAL_C in (" + inClause + ")");
                ////clearing all existing where clause params if any 
                this.setWhereClauseParams(null);
                if(getVariableManager() !=null){
                   this.getVariableManager().clearVariables();
                }
                //setting values for all bind variables one by one in the in clause
                for (int i = 0; i < termCodes.size(); i++) { 
                    //defining the named bind variables programatically 
                    this.defineNamedWhereClauseParam("termC" + (i + 1), null, null);
                    //setting the value for each named bind variable 
                    this.setNamedWhereClauseParam("termC" + (i + 1), termCodes.get(i)); 
                }
                this.setRangeSize(-1); 
                //executing the query 
                this.executeQuery(); 
            }
            //returning the rows from query result 
            return this.getAllRowsInRange(); 
        }
    

    You can only use the link as a parameter to the in clause. You must divide the string inside the binding variable. Sample can be found at decompilation binary ADF: using bind variable for SQL statements with the paragraph

    Timo

  • How to change where clause in VO interview at the bean

    Hi experts

    I need to change vo object query where clause execution... is - it possible?

    If so please suggest me.

    as mentioned by Timo, it is quite possible

    See this link-

    Change in the WHERE clause or query on VO when running in Oracle ADF | Techartifact

    Dynamically change the query in the view object in Oracle ADF | Techartifact

  • How can I extract a substring in WHERE Clause &lt; CFQUERY &gt;?

    Is it possible to extract a substring in the WHERE clause of either < CFQUERY > or in a query of queries?  I try to use the following query to find all e-mail addresses with the domain "comcast.net" (i.e., everything that follows the '@' in the email address).  I ask an MS-Access database table.

    < cfquery name='test' datasource='membership'>
    SELECT Email_address
    OF tblMembers
    WHERE the MID (email_address, INSTR (email_address, ' @') + 1) = "comcast.net"
    < / cfquery >


    If I try this as a query, I get the error message "[Macromedia] [SequeLink JDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver] data type incompatible in criteria expression."


    If I try it as a t/t, I get the error message " " Met 'MID (e-mail1.,. Incorrect conditional expression, waiting for one of [as | null | between | in | comparison] condition,'.

    I would be very grateful for any help on finding something that works!  Thanks for your help!


    You couldn't do a LIKE in where clause instead:

    SELECT Email_address

    OF tblMembers

    WHERE email_address LIKE ' %@comcast.net'

    You should get the addresses you're looking for.

    -Carl V.

Maybe you are looking for

  • Satellite A300-1MC is slow using Win XP

    I recently spent 400 odd quid on this laptop.Hated Vista and installed XP Pro. However, I find when I get my screen 'connect' on XP, my office rises and it takes 10 years before you can start applications like Firefox, etc (hourglass, etc.). In fact

  • Age of Empires 2 compatibility

    What new laptops / processor can play the old AOE2 series?

  • change of file user name

    I want to change the name of the C: user / lisa to C: user / adam I am running windows 7

  • PROBLEM activating PSE 7.0

    Hello, PSE 7.0 does not validate my key of activation on Windows 10. Uninstalled Windows seven from the old pc to LUNHelp me please! Thank you

  • phys ESX 5.1 switch

    HELO, I'm new in this world.I want to connect a 5.1 esx and one with win 2008 r2 with hp procurve 2800 series.what can do to connect with switch.configure switch? because I don't see esx through the windows when they are with the connected.when switc