Conditional SQL

Oracle 11g.

In General to know where sql clause, such as: where account_id = p_acct_id means that for a specific account_id.  Now, I want to build provided that is a flag setting s = p_flag ' use

where ID_compte = p_acct_id, otherwise account_id will be ignored.

For example:

If using mutiple instruction is like this

If (p_flag = the of ') then

Select in...

where account_id = p_acct_id and p_oth_id = other_id

on the other

Select in...

where other_id = p_oth_id

end if;

But, how can I write it in a where clause?



Thank you

Hello

Here's another way:

WHERE (account_id = p_acct_id

OR NVL (p_flag, 'OK'). = s "

)

AND other_id = p_oth_id

This will work even if p_flag and/or account_id is NULL.

CASE expressions are really practical in the SELECT and ORDER BY clauses, because they allow you to do an if-then-else logic in these places.

WHEN the clauses have their own way of doing if-then-else logic, so the CASE expressions are not necessary much in WHERE clauses.

Tags: Database

Similar Questions

  • 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

  • Table - Conditional SQL possible?

    Request Express 4.1.1.00.23

    I was wondering if the following is possible.
    I created users and groups.
    for example;

    User1
    User2
    util_3

    Group1
    group2

    I have assigned users to groups as follows:

    Members of Group 1
    User1
    User2

    Members of the Group 2
    util_3

    In my table, I have a column called visibility values will be either 'Internal only' and 'Public '.
    Is there a way I can use a conditional query that will do the following:

    If apex_util.current_user_in_group ('Group1') then
    Select * from customer where visibility = Public

    and

    If apex_util.current_user_in_group ('Group2') then
    Select * from customer where visibility = internal only

    I've been Googling the hell out of it, I generally use PHP and create the page from scratch, but I think that Apex will be useful if I can learn how to use it!
    Thank you for your time :D

    Create a hidden page item - call him

    P1_VISIBILITY
    

    Create a page of calculation for this element of type PL/SQL function and put the following code:

    BEGIN
       IF apex_util.current_user_in_group ('Group1')
       THEN
          RETURN 'Public';
       ELSIF apex_util.current_user_in_group ('Group1')
       THEN
          RETURN 'Internal Only';
       END IF;
    END;
    

    Your query:

    SELECT *
      FROM customer
     WHERE visibility = :p1_visibility
    

    should now work as expected. There are several ways to do so in the APEX. It's just one of them and easy to understand.

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Apress.com/9781430235125
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    http://www.Amazon.de/Oracle-Apex-XE-Praxis/DP/3826655494
    -------------------------------------------------------------------

  • Is conditional SQL processing of XDL available data models

    Hello

    Is it possible to have a CONDITIONAL STATEMENT in .xml (data model), based on a SQL statement that was going to be executed? Sense, based on a PARAMETER value, only the TWO queries should be run.

    Ex: Lets take a system used, or if the report is run
    SUMMARY = > summary query must be executed
    DETAIL = > detailed queries to run.

    < IF P_REPORT = SUMMARY >
    < DO >
    -THE QUERY SUMMARY
    < END IF >

    < IF P_REPORT = DETAIL >
    < DO >
    -DETAIL QUERY
    < END IF >

    Could if it you please let me know the feasibility of this in XML BI. Ask that you please point me to the documentation, if any.

    Thank you
    Vijaya

    OK, I withdraw,

    If it is required to be achieved. then that,

    1. you need to add a report parameter values valid as 'SUMMARY' and 'DETAIL '.
    2. you have 2 Add two separate petitions, no need to join them.
    3 just put separate way queries in the data model or concatenated sql same datasource.
    4 each of the query, to equate them with the setting something like
    5 ' SUMMARY' =: PARAM_REPORT_TYPE in the query summary
    6 ' DETAIL' =: PARAM_REPORT_TYPE in the query in detail
    7. in execution, that which, one of the query to execute and extract the data.
    8. Similarly, in the model, you can add the conditional creation of models.

  • Conditional SQL statement

    Hi guys,.
    I need to write a SQL statement that performs two checks. For the first check, I need to have both frankly met conditions whereas for 2nd condtion, I need only the second condition honestly satisfied.

    I have a few settings that accepts this SQL query.

    The condition is that, if the first part is not successful, then even if the 2nd condtion is successful, then condition does not return an 'x '.

    However, saying just that the there is this particular forms of student the all stu_flag defined, in which case the first condition must not be verified only look the 2nd conditon (student's 'Assets') and should return an 'x '.
    select 'x' from stu_form f
    where  exists ( select 'x' from stu_form_detail d
                    where  d.form_id = f.form_id
                    and     d.form_id = :p_form_id
                    having count(stu_flag) > 0 )
    and      f.form_status = 'APR'
    and   ( f.stu_acc is not null or :p_stu_acc is not null )
    union
    select 'x'
    from  stu_account
    where stu_acc_num = :p_stu_acc_num
    and     stu_active_flag = 'Y'
    Appreciate all the help.

    Thank you!

    Hello

    Sorry, I don't understand the problem.
    Please post some sample data (CREATE TABLE and INSERT statements) and the results you want to obtain these data for each of a few sets of parameters.

    If the output of deisired is always a line ('x') or 0 rows, then you are probably best to base the main query on doubles and using subqueries EXISTS to check tables. In this case, there is no need of a trade UNION; You can combine the conditions in the WHERE clause using OR.

  • Conditional SQL (you want to avoid having to write a PL/SQL block)

    I have a SQL statement and I was hoping to not have to write an IF-THEN-ELSE condition. Here's the SQL code in hand I need to expand.

    I need to list personal information, including the address of all employees. However, in the case where I meet any address (home or office), where is my State * "NY" *, I should not write the address of "NY" but rather the list the address where my address_location = 'o' and address_state_code = * "CA."

    Here is my code below. Now, the call to DB procedure could recover the last id address as "NY" and thus my question.
    SELECT '"'||emp.employee_name,
                  ||'","'||TO_CHAR(emp.birth_date,'YYYY/MM/DD')
                  ||'","'||emp.gender
                  ||'","'||RTRIM(ead.address_line1)
                  ||'","'||RTRIM(ead.address_line2)
                  ||'","'||RTRIM(ead.address_line3)
                  ||'","'||RTRIM(ead.address_location) -- 'O': Office; 'H': Home
                  ||'","'||RTRIM(ead.adh_city)
                  ||'","'||ead.address_zip_code
                  ||'","'||ead.address_state_code
    FROM    employee             emp,
                employee_address ead
    WHERE  emp.emp_num = ead.emp_num
    -- The proccedure db_get_address_id returns me the most recent Address with Max Effective Date
    AND      ead.address_id = db_get_address_id( emp.emp_num )
    ORDER BY v.effective_date DESC, emp.employee_name ASC;
    {code}
    
    Thanks in advance !                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

  • show/hide the button with the icon enabled when the condition is met

    Hello

    I created a B button with an icon of a sign of the green check mark.
    It must appear next to another A button when a condition is met.

    How can I better get this working B key, without using something else than the APEX.

    The condition is that some data has been inserted by clicking A button or simply exist in the database table.

    I tried conditional display of point with conditiontype "PL/SQL Expression.
    but could not make it work.

    TNX to tide me over.

    Cara

    Hello

    If you use the condition EXISTS (SQL query returns at least one row)?

    This could give idea how
    http://Apex-SMB.blogspot.com/2009/05/How-to-determine-if-user-can-view-apex.html

    BR, Jari

    Published by: jarola 18 November 2009 16:07

    Oh,.
    I paste the wrong link and can not find more good.
    Well anyway in this link is also example to condition EXISTS

    To meet this requirement I can add a condition (SQL Exists) to the Report 2 region on Page 2:
    

    It takes something similar and your table selection

  • Boolean condition on a tab does not

    Hello!
    I have a tab that should only appear if a recording is in the database. I use a condition "PL/SQL function body returning a Boolean" by the following:

    DECLARE
    T1 varchar2 (20);
    BEGIN
    Select the GROUP in t1 from pl_department where userid =: APP_USER.
    If ((t1 = '-') OR (t1 is null) OR (t1 = ") or (t1 = '%' |)) ' %')) null then
    Returns false;
    on the other
    Returns true;
    end if;
    END;

    If no data is found in the database, I get an error at the top of my page "invalid function body condition: ORA-01403: no data found".
    As you can see I tried to check the 4 possible different values, but nothing works.
    Any ideas on what I can try?
    Thank you!
    T

    Published by: 73pixieGirl on December 16, 2008 06:34

    Hello

    You can better use the Exists condition (SQL query returns at least one row)
    You would put in the expression 1: select the GROUP from pl_department where userid =: APP_USER.

    The problem you are experiencing, it is that your code is entering the exception. If you really want to keep your code, you can adapt it as:
    DECLARE
    T1 varchar2 (20);
    BEGIN
    Select the GROUP in t1 from pl_department where userid =: APP_USER.
    If ((t1 = '-') OR (t1 is null) OR (t1 = ") or (t1 = '%' |)) ' %')) null then
    Returns false;
    on the other
    Returns true;
    end if;
    EXCEPTION WHEN NO_DATA_FOUND THEN return false;
    END;

    But I recommend you my first suggestion.

    Kind regards
    Dimitri
    ----------------------------------
    http://dgielis.blogspot.com/
    http://www.apex-evangelists.com/
    http://www.apexblogs.info/
    AWARDS: Don't forget to mark correct or helpful messages on the forum

  • Determine whether a LOV all values

    I have an application that uses a dynamic list of values (LOV), which is based on a component of demand.  This is used in a select list, and there are cases where there is no entry in the LOV.  Is there a function like:

    Function Has_Lov_Rows (lov_name in varchar2) return Boolean;

    (Alternatively, function Has_Lov_Rows(Item_name in varchar2) return a Boolean value ;) )

    or generalizing a bit:

    function Count_Lov_Rows (lov_name in varchar2) return whole;

    (or Count_Lov_Rows(item_name in varchar2) function return whole ;)

    Since I wrote the LOV in question (is be a PL/SQL function in pipeline), I could return PL/SQL package and add a function, or the courage of the definition of LOV and put that in the conditions (SQL returns at least 1...)  But from a coding perspective, I would rather the name LOV or point - so if I change the definition of LOV, my conditions will still work.

    In this particular application, if the user has the appropriate roles, a selection list and the button will be displayed to allow them to do some extra steps.

    You can do this by using a function that retrieves the dynamic LOV query for the LOV, an element is based on views metadata APEX and assesses whether it returns all rows. Something like:

    create or replace function has_lov_rows (p_item_name in varchar2) return boolean
    is
    
      l_lov_exists_sql varchar2(4096);
      l_lov_rows       signtype;
    
    begin
    
      select
          'with lov as (' || lov.list_of_values_query || ') select count(*) n from dual where exists (select * from lov)' lov_exists_sql
      into
          l_lov_exists_sql
      from
          apex_application_page_items item
            join apex_application_lovs lov
              on    item.lov_named_lov = lov.list_of_values_name
                and item.application_id = lov.application_id
      where
          item.item_name = has_lov_rows.p_item_name
      and item.application_id = (select v('app_id') from dual);
    
      execute immediate l_lov_exists_sql
        into l_lov_rows;
    
      return l_lov_rows > 0;
    
    end has_lov_rows;
    
  • Classic apex height custom report with 5 rows as defalut

    I have 4 region with classical reports, each region have with different condition sql query ' s.when the data is null, then the region of report must be displayed with 5 rows of empty default value and apply even in other regions as well. IAM using refresh the report and keep the [plug-in] pagination for each region during the fire on Page load as DA to keep 5 rows at all...

    How can set the size?

    Theme: 21

    Apex in cloud service.

    screenshot

    std template.PNG

    RAM,

    Manually set the height for each region

    region edit and put in the header of the region

    footer area

    to check demo in your workspace Application 18543

    page 4

  • Digital signage using SYS_CONTEXT

    Version 11.2.0.3

    I'm trying to create a view that refers to two identical paintings. The results will be presented only ever among the tables based on a variable SYS_CONTEXT.

    The issue I see is however that the implementation plan is different when I use literals as opposed to a variable SYS_CONTEXT. The plan with literals is what I expect to see when I use SYS_CONTEXT as well. The difference between the 2 plans, is that the filter filter (NULL IS NOT NULL) appears for the SELECT that does not run. The following illustrates the problem:

    create table tbl1 (id number, date_created date);

    create table tbl2 (id number, date_created date);

    insert into tbl1 values (1, to_date('20140114','yyyymmdd'));

    insert into tbl2 values (2, to_date('20140115','yyyymmdd'));

    insert into tbl2 values (2, to_date('20140115','yyyymmdd'));

    COMMIT;

    create or replace context tbl_switch using set_tbl_context;

    create or replace procedure Set_Tbl_Context (p_Tbl_No in varchar2) as
    Start
    DBMS_SESSION.set_Context ('TBL_SWITCH', 'SWITCH_VALUE', p_Tbl_No);
    end Set_Tbl_Context;
    /

    SQL > exec set_tbl_context ('2');

    PL/SQL procedure successfully completed.

    SQL > select sys_context ('TBL_SWITCH', 'SWITCH_VALUE') FROM DUAL;

    SYS_CONTEXT ('TBL_SWITCH', 'SWITCH_VALUE')
    ----------------------------------------
    2

    SQL > set autotrace on
    SQL > select * from tbl1 where 1 = 2
    2 Union all the
    3 select * from tbl2 where 2 = 2
    4.

    ID DATE_CREA
    ---------- ---------
    2 15 JANUARY 14
    2 15 JANUARY 14


    Execution plan
    --------------
    Hash value of plan: 6123662

    ----------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      |     3.    66.     3 (100) | 00:00:01 |
    |   1.  UNION-ALL |      |       |       |            |          |
    |*  2 |   FILTER |      |       |       |            |          |
    |   3.    TABLE ACCESS FULL | TBL1 |     1.    22.     3 (0) | 00:00:01 |
    |   4.   TABLE ACCESS FULL | TBL2 |     2.    44.     3 (0) | 00:00:01 |
    ----------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    2 - filter (NULL IS NOT NULL)

    Note
    -----
    -dynamic sample used for this survey (level = 2)


    Statistics
    ----------
    16 recursive calls
    0 db block Gets
    Gets 36 compatible
    0 physical reads
    0 redo size
    436 bytes sent via SQL * Net to client
    364 bytes received via SQL * Net from client
    2 SQL * Net back and forth to and from the client
    0 sorts (memory)
    0 sorts (disk)
    2 rows processed

    SQL > select * from tbl1
    where the 2 ' 1'= sys_context('TBL_SWITCH','SWITCH_VALUE')
    3 Union all the
    4 Select * from tbl2
    where the 5 ' 2'= sys_context('TBL_SWITCH','SWITCH_VALUE')
    6.

    ID DATE_CREA
    ---------- ---------
    2 15 JANUARY 14
    2 15 JANUARY 14


    Execution plan
    --------------
    Hash value of plan: 687287648

    ----------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      |     5:    66.     6 (50) | 00:00:01 |
    |   1.  UNION-ALL |      |       |       |            |          |
    |*  2 |   FILTER |      |       |       |            |          |
    |   5:    TABLE ACCESS FULL | TBL1 |     1.    22.     3 (0) | 00:00:01 |
    |*  4 |   FILTER |      |       |       |            |          |
    |   3:    TABLE ACCESS FULL | TBL2 |     2.    44.     3 (0) | 00:00:01 |
    ----------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    2 - filter (SYS_CONTEXT ('TBL_SWITCH', 'SWITCH_VALUE') = '1')
    4 - filter (SYS_CONTEXT ('TBL_SWITCH', 'SWITCH_VALUE') = '2')

    Note
    -----
    -dynamic sample used for this survey (level = 2)


    Statistics
    ----------
    7 recursive calls
    0 db block Gets
    Gets 24 consistent
    0 physical reads
    0 redo size
    436 bytes sent via SQL * Net to client
    364 bytes received via SQL * Net from client
    2 SQL * Net back and forth to and from the client
    0 sorts (memory)
    0 sorts (disk)
    2 rows processed

    Can anyone suggest why this is? In addition, the query with the variable SYS_CONTEXT does not two SELECT?

    Thank you

    That's exactly the plan that you want to see (although I must say I don't like the strategy that you are adopting).

    If the sys_context value is 1 then line 2 will call line 3 to run, but line 4 will be short circuit and do not call the line 5

    If the sys_content value is 2, then line 1 will be short-circuit and not dial 3, but call line 4 line 5

    Update: your method is similar to an example I talked some time ago:conditional SQL & #8211; 3. Notebook of the Oracle and something similar is generated internally by the particularly specific optimizer transformation: conditional SQL | Notebook of the Oracle

    It would not have been too difficult to set up a small test to see if this was true.

    Concerning

    Jonathan Lewis

  • Mass, editing a field displaying the value 'No' to 'yes '.

    I can type the following in the "SQL" workshop and update the field 'No' to 'yes '.

    Update
    BS_COURSES_RUN
    The BS_COURSES_RUN value. ORACLE_UPDATED = "Yes".
    Where BS_COURSES_RUN. ORACLE_UPDATED = 'no '.

    How can I update all fields showing 'No' to 'Yes' in a tabular layout with a button somewhere on the same page as the form?

    It would be great if the option to delete all the records that could be made to update the records instead. I tried to create a process page and selecting the 'Type of Condition' > "SQL Expression" and then placing the SQL above in '1 ', but this Expression does not work.

    Someone at - it ideas?


    Kind regards

    Steve Welch

    Hello

    Assuming you just want to replace all the files on the table by Yes where they are has not, you can:

    1. create a button on the page called, for example, "P1_YES_BUTTON".
    2. create a process page PLSQL conditional on the button that is clicked ("when button pressed" = P1_YES_BUTTON). Code of the process would be:

    begin
    Update
    BS_COURSES_RUN
    Set BS_COURSES_RUN.ORACLE_UPDATED = 'Yes'
    Where BS_COURSES_RUN.ORACLE_UPDATED = 'No';
    end;
    

    3 - Make sure you have a branch of page that refers to the same page and is also conditional on the button that is clicked

    Andy

  • SQL Server 2008 - conditional formatting

    Hello

    Please would you be able to help with this problem.

    I have a field within my report, called FormElementDisplayText and here are some answers that I want to do a conditional on formatting.

    Such as:

    Void gas repair location
    Void location of electric repair
    Repair general location of the cancellation.

    How can I me it to fit automatically the fields that contain the word "gas" of a different color?

    Thank you
    Selina

    SQL beyond the scope of this site

    This issue is beyond the scope of this site and to make sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)
  • Condition of licence for SQL Loader?

    Hello

    I have an installing the oracle client that allows me to use SQLPLUS to connect to our Oracle 11g databases. SQL Loader is optional for installation. I would like to make use of this utility. Can anyone confirm if there is a condition of additional license to install SQL Loader?

    TIA

    Oracle allows the tools that usually used to interact with the database. SQL * Plus, SQL Developer, SQL * Loader are all free. If you use a feature optionally licensed in the database that makes the difference. For example, Oracle Partitioning is an extra cost feature. You can use SQL * Loader to load data into an Oracle database without that it costs you nothing more. But if you use SQL * Loader to load into a partitioned table, you will have to pay for the partitioning, but not SQL * Loader.

    See you soon,.
    Brian

  • WHERE condition in a sql statement

    Hello people,

    I have a screen with data grid where one of the columns is STATES_CODES and other VOLUMES one. Grid consists of several lines. I need to create a CUSTOM SEARCH field that will be filtering on this database.

    Unfortunately a customer wants to enter a search string with custom functions: '+' (plus) to include in the selection of the result and "-" (less) to exclude from the selection of the results. For example: "+ IT + -100". Based on this string, I need to return only the States HE and and exclude volumes with a value of 100.

    A tip how to build a query where condition, so it will be more effective as possible?

    Simple example:

    test data:

    with t (select 'IT' State, volume 90 of any union double

    Select 'IT' State, 100 volumes of all the double union

    Select 'IT' State, 100 volumes of all the double union

    Select 'OF' State, 90 volume of all the double union

    Select 'OF' State, in 100 volumes of all the double union

    Select 'OF' State, in 100 volumes of all the double union

    Select 'NL' State, 90 volume of all the double union

    Select 'NL' State, 100 volumes of all the double union

    Select 'NL' State, 100 volumes of all the double union

    Select 'FR' State, 90 volume of all the double union

    Select 'FR' State, in 100 volumes of all the double union

    Select 'FR' State, in 100 volumes of all the double union

    Select 'ARE' State, 90 volume of all the double union

    Select 'ARE' State, in 100 volumes of all the double union

    Select 'ARE' State, 100 volumes of double

    )

    Select * from t

    Search string: "+ IT + - 100".

    I thought to somehow using regular expressions REGEXP_LIKE condition, but do not know how to change the entered search string in above format as long as the regular expression.

    And if you want to be specific about the characters representing the State and the numbers represent the amount then you will need to divide them into more...

    SQL > with t (select 'IT' State, 90 volume of all the double union)
    2 Select 'IT' State, 100 volumes of all the double union
    3 select 'IT' State, 100 volumes of all the double union
    4. Select 'FROM' State, 90 volume of all the double union


    5. Select 'FROM' State, in 100 volumes of all the double union
    6. Select 'FROM' State, in 100 volumes of all the double union
    7 select 'NL' State, 90 volume of all the double union
    8 select 'NL' State, 100 volumes of all the double union
    9 select 'NL' State, 100 volumes of all the double union
    10. Select 'FR' State, 90 volume of all the double union
    11. Select 'FR' State, in 100 volumes of all the double union
    12. Select 'FR' State, in 100 volumes of all the double union
    13. Select 'ARE' State, 90 volume of all the double union
    14 select 'ARE' State, in 100 volumes of all the double union
    15 select 'ARE' State, in 100 volumes of double
    16              )
    17, ch. as (select "+ IT + -100"as the double criterion)
    18, split as (select regexp_substr (trim (', ' regexp_replace (criteria,'([+ -]) ', ', \1')), "[^,] +', 1, level") as a criterion of)
    19 c
    20 connect the regexp_substr (trim (', ' regexp_replace (criteria,'([+ -]) ', ', \1')), "[^,] +', 1, level") is not null
    21                 )
    22, inc_state as (select substr(criteria,2) as a criterion
    23 split
    where the 24 regexp_like(criteria,'^\+[A-Z]+')
    25                     )
    26, inc_vol as (select substr(criteria,2) as a criterion
    27 split
    where the 28 regexp_like(criteria,'^\+[0-9]+')
    29                    )
    30, exc_state as (select substr(criteria,2) as a criterion
    31 split
    where the 32 regexp_like(criteria,'^\-[A-Z]+')
    33                     )
    34, exc_vol as (select substr(criteria,2) as a criterion
    35 split
    where the 36 regexp_like(criteria,'^\-[0-9]+')
    37                    )
    38-
    39 select *.
    40 t
    where the 41 (exists (select 1
    inc_state 42
    43 where inc_state.criteria = t.state
    ((44) or (select count (*) in inc_state) = 0)
    45 and (exists (select 1
    46 by inc_vol
    where the 47 inc_vol.criteria = t.volume
    ((48) or (select count (*) in inc_vol) = 0)
    49 and (not exists (select 1
    50 to exc_state
    where the 51 exc_state.criteria = t.state
    ((52) or (select count (*) in exc_state) = 0)
    53 and (not exists (select 1
    exc_vol 54
    where the 55 exc_vol.criteria = t.volume
    ((56) or (select count (*) in exc_vol) = 0)
    57.

    ST VOLUME
    -- ----------
    HE 90
    90

Maybe you are looking for