Export (expdp) with where clause

Hello gurus,

I'm trying to export with where clause. I am getting error below.


Here is my order of export.
expdp "'/ as sysdba'" tables = USER1.TABLE1 directory=DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= “USER1.TABLE1:where auditdate>'01-JAN-10'”
Here is the error
[keeth]DB1 /oracle/data_15/db1> DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= USER1.TABLE1:where auditdate>'01-JAN-10'                    <

Export: Release 11.2.0.3.0 - Production on Tue Mar 26 03:03:26 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TABLE_03":  "/******** AS SYSDBA" tables=USER1.TABLE1 directory=DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= USER1.TABLE1:where auditdate
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 386 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/TRIGGER
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
ORA-31693: Table data object "USER1"."TABLE1" failed to load/unload and is being skipped due to error:
ORA-00933: SQL command not properly ended
Master table "SYS"."SYS_EXPORT_TABLE_03" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLE_03 is:
  /oracle/data_15/db1/TABLE1.dmp
Job "SYS"."SYS_EXPORT_TABLE_03" completed with 1 error(s) at 03:03:58
Version
SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

Hello

You must use the settings file. Another question, I see you are using 11g. Why don't you use a data pump.?
Data pump is faster and has more features and that regular improvement imp and exp.

You can do the following:

sqlplus / as sysdba

Create directory DPUMP_DIR3  for 'Type here your os path that you want to export to';

then tap on a file:
Touch par.txt

In this file, type the following line the following:

tables=schema.table_name
dumpfile=yourdump.dmp
DIRECTORY=DPUMP_DIR3
logfile=Your_logfile.log
QUERY =abs.texp:"where hiredate>'01-JAN-13' "

then proceed as follows
expdp username/password name parfile = 'par.txt'

You will import to Oracle 11 g to 10g version should add 'version = 10' parameter in the above setting file

BR
Mohamed enry
http://mohamedelazab.blogspot.com/

Tags: Database

Similar Questions

  • Cannot export data so WHERE clause AND/OR

    I am able to export the results of a query if the WHERE clause has only one condition. But if there are and AND or a RC, you can right-click and choose export data, but nothing happens.

    For example, the following text exports very well:

    SELECT * FROM DUAL
    WHERE ROWNUM = 1;

    But throw in an 'AND', and it will not be exported:

    SELECT * FROM DUAL
    WHERE ROWNUM = 1 AND ROWNUM < 2;

    I'm running worm 1.5.3 and did not apply the patches.

    Unfortunately, in the framework of trying to solve other problems with the export feature, 1.5.3 presented problems where certain types of SQL statements would not export (nothing happened like you are seeing or reports of the errors like ORA-936). While it is not yet perfect, 1.5.5 manages exporters results much better (it fits your case who fails in 1.5.3), then I would say that you upgrade to 1.5.5.

    theFurryOne

  • 8287 error: manual/refresh operations with Where clause

    Hello

    I defined a group of read-only cache

    CREATE CACHE READONLY ABC GROUP

    AUTOREFRESH INTERVAL 60 seconds

    OF ORACLE_TABLE

    I want to only load the 3 months of the underlying table for Oracle data so I don't


    ABC LOADING CACHE GROUP

    WHEN TRUNC (date_column) > TRUNC (add_months (sysdate,-3))

    COMMIT ALL 256 ROWS

    4 PARALLEL;

    However, I get the error message

    8287: manual LOADING/REFRESH with clauses WITHID or WHERE operations are not be allowed on ABC Group cache because it is specified as AUTOREFRESH

    The command failed.

    What should I do to load the data of 3 months only if possible? Can I use autorefresh?

    Thanks in advance

    Cache AUTOREFRESH groups to include the WHERE clause in the definition of Group of cache. For example, if drop you in Oracle's:

    CREATE TABLE MYDATE

    (

    C1 VARCHAR2 (10) NOT NULL PRIMARY KEY,

    C2 DATE NOT NULL

    );

    Then your cache group definition would look like this:

    CREATE CACHE READONLY ABC GROUP

    AUTOREFRESH INTERVAL OF 60 SECONDS

    OF MYDATE

    (

    C1 VARCHAR2 (10) NOT NULL PRIMARY KEY,

    C2 DATE NOT NULL

    )

    WHEN TRUNC (c2) > TRUNC (add_months (sysdate,-3));

    And then you would load by using

    ABC LOADING CACHE GROUP

    COMMIT ALL 256 ROWS

    4 PARALLEL;

    As auto refreshes occur time passes, all the data that falls outside the range will be removed from the cache and new data that now lying in the range will be added to the cache.

    Chris

  • Case with where clause - ORA-00920: invalid relational operator

    Hi all, when I try to run the following query, I get the following error...

    ORA-00920: invalid relational operator

    00920 00000 - "invalid relational operator.

    * Cause:

    * Action:

    Error on line: column 16: 5

    Anyone know what the problem with my request? Thanks in advance.

    SELECT concat (year, period)

    OF DD_ACTUALS_FACT

    CASE WHERE period

    WHEN 'JAN' THEN '01'

    WHEN 'FEB' THEN '02'

    WHEN 'MAR' THEN ' 03 "

    WHEN "APR" THEN ' 04 "

    WHEN 'CAN' THEN ' 05 "

    WHEN "JUN" THEN '06'

    WHEN 'JUL' THEN '07'

    WHEN 'AUG' THEN '08'

    WHEN 'MS' THEN '09'

    WHEN 'OCT' THEN '10'

    WHEN 'NOV' THEN '11'

    WHEN 'DEC' THEN '12'

    END as number 'months '.

    ORDER OF CONCAT (year, number 'months') / / DESC

    The problem is the number 'month' - you cannot give an "ACE" alias for an expression in a where clause clause.

    You have not really given any condition, that a set of translations of period in a number.

    Also, you didn't say what you're trying to do.

    Maybe you want to:

    SELECT concat (year, period)

    OF DD_ACTUALS_FACT

    WHERE something

    ORDER OF CONCAT (year, period of the CASE

    WHEN 'JAN' THEN '01'

    WHEN 'FEB' THEN '02'

    WHEN 'MAR' THEN ' 03 "

    WHEN "APR" THEN ' 04 "

    WHEN 'CAN' THEN ' 05 "

    WHEN "JUN" THEN '06'

    WHEN 'JUL' THEN '07'

    WHEN 'AUG' THEN '08'

    WHEN 'MS' THEN '09'

    WHEN 'OCT' THEN '10'

    WHEN 'NOV' THEN '11'

    WHEN 'DEC' THEN '12'

    END DESC)

    /

  • Help with Where clause

    Hello world

    I have an argument to function entry, lets call this file number. This argument can be 0 (zero) or any number like 9800. No negative number.

    My where clause, I would like to say, if the number is 0 (zero), then extract all the cases, otherwise just retrieve the lines/records that belong to the passed in file number.

    select * 
    from table1
    where case_num = (if case num is 0 then retrieve all cases, 
                    otherwise retrieve only the records that belong to the number passed in)
    

    Thanks in advance.

    Select *.

    FROM table1

    where case_num = num

    or num = 0;

    SY.

  • Need help with where clause

    Hi all

    Could someone please help me on this one where clause.
    The structure of the table like this:

    < code >
    create table (test)
    primary key ID number,
    TYPE_ID number not null,
    name varchar2 (10));

    insert into test values (1, 10, 'name 1');
    insert into test values (2, 10, 'name 2');
    insert into test values (3, 20, 'name 3');
    insert into test values (4, 20, 'name 4');
    insert into test values (5, 20, 'name 5');
    insert into test values (6, 10, 'name 6');
    insert into test values (7, 10, 'name 7');
    commit;

    SQL * more > select * from test;

    TYPE_ID ID NAMES
    ---------- ---------- ----------
    1 10 name 1
    2 10 2 name
    3 20 name 3
    4 20 4 name
    5 20 5 name
    6 10 6 name
    7 10 7 name

    7 selected lines.
    < code >

    Here are the values of the drop-down list box which the user will be able to select
    0 all the project
    Type of project 10 10
    20 of the Type 20

    Based on the selection of the user, we need a SELECT to get all records or certain types of records.

    Thanks in advance!

    Hello

    If: selected_type_ID is the value in the drop-down list (0, 10, or 20), then:

    WHERE   :selected_type_id IN (test.type_id, 0)
    

    This assumes that test.type_id is never NULL.

  • ORA-01427 with WHERE clause and CASE statement

    Hi guys,.
    I get the error ORA-01427 when you try to select * from my dimension table
    When the parameter: P_HZA is 4. I used the keyword IN but the error still appears.
    no idea why?

    Select * from testtab
    where mycar = 4
    and "coretable". "" HZA ' IN
    CASE
    When: P_HZA = "4" then (button SELECTION OF DIM_HZA)
    other: P_HZA
    END

    Thank you

    you missed table_name and also this can cause several error so lines (ORA-01427: einreihig subquery returns more than one line)

    SELECT *
      FROM tableA
     WHERE mycar = 4
           AND "coretable"."HZA" IN
                  CASE
                     WHEN :P_HZA = '4' THEN (SELECT key FROM DIM_HZA)   ---- may be you need to have max  to get only one value
                     ELSE :P_HZA
                  END
    

    See you soon,.
    Manik.

  • By using a WHERE clause in the tree APEX

    Hi all -

    I have a hierarchical SQL query that I display as a tree of the APEX.

    Here is my sample application:

    https://Apex.Oracle.com/pls/Apex/f?p=32581:29

    Login: guest

    PW: app_1000

    workspace: leppard

    I try to add a WHERE clause so that only nodes with the lowest-level children are displayed, i.e. something like "WHERE connect_by_isleaf = 0 OR level = 5'"

    The tree of query with where clause works very well in the SQL command window, but when I add the WHERE clause to my tree apex page no longer displays anything. Is this a problem with APEX or y at - it another way to filter my results?

    Thanks in advance for your suggestions,

    John

    Connect occurs in the first place, the where the provision is applied to these results, effectively cutting in the hierarchical structure. Since the apex has build a hierarchical structure of the query, it relies on the virtual level, which is butchered by applying the where clause. It's a miracle that you're not even receive errors because I expect almost an incorrect json array was built. With no top-level from and only level 5 or end nodes, there is no structure to present: the two apex cannot set a correct representation and not jstree neither. In your request, you will see your "root nodes", but it is not representable.

    I don't know why you want to present it in a tree? Levels both connect_by_is_leaf = 5 will give you everything just a list of nodes without any hierarchical structure.

    The best thing to do is to use a subquery to limit first your dataset and then use it for the basic tree query, this way you violate one of these vital columns.

    For example if you want only nodes and their immediate parent, you can opt for something like this (fast on some testdata model):

    with dataset as (
    select node_id, parent_id
       from treedata
      where connect_by_isleaf = 0
    connect by prior node_id = parent_id
      start with parent_id = 0
    ),
    dataset2 as (
    select node_id, parent_id
      from dataset
    union all
    select node_id, null parent_id
      from treedata
    where node_id in (select parent_id from dataset)
    )
    select level, node_id
       from dataset2
    connect by prior node_id = parent_id
      start with parent_id is null
    
  • Can I use truncated and where clause in the statement even?

    Hello guys,.

    Can I use truncated with where clause in the same statement.


    For ex:

    TRUNCATE TABLE my_table WHERE id < 500;

    If not, that you recommend me to overtemperature to the level of high water line?


    By the way
    select * from v$version;
    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    "CORE 11.2.0.1.0 Production."
    AMT for 64-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    >

    Thank you very much.

    Published by: 970992 on 11:14 13.Ara.2012

    >
    Okay I need an increasing amount of space. However, at the same time I want to recover the spaces empty below HWM. So, I need to use less amount of space I am inserting. Therefore, shouldn't use retractable for this?
    >
    Why waste the effort. Oracle will reuse the space below the HWM when doing inserts. You already said that you insert more lines you delete so all these will be more accustomed to the top.

    The only time where that oracle may not use space is when the space is too small to be useful. It is documented in the doc, I told you
    >
    Understanding recoverable unused space
    Over time, Update, and Delete on objects within a tablespace can create pockets of empty space that individually are not large enough to be reused for the new data.
    >
    Most uses of CONTRACTION I've seen are totally useless. If you follow the doc and run the Advisor of segment it will tell you if there is space that can be retrieved and how much. But, even once, for your use even if case will get you will Oracle while you need to reassign the new extensions, then the HWM will just go still higher.

    If pay you a heavy price in Oracle did a full table scan, update of many blocks from the table, update THE index, impact performance for other users to access the table during the SHRINK and reallocate extensions (maybe even some of the same areas) when you insert more data.

    Do not SHRINK unless you know it's necessary.

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

  • Need help with dynamic where clause.

    Hello world.  I'm kind of a novice with PL/SQL, so please be patient with me.  I am building a web application using Weblogic Oracle 11 g and Oracle database.

    To make a long story short, I need to generate the complex dynamic WHERE clause.  I don't know what will be the name of the column or the operator of comparison or the value will be until the moment of execution.

    I'm not 100% certain, but I think I need to use dynamic SQL statements.  Unless there is a better way to do it.

    I'm sure that using dynamic SQL opens me up to SQL injection attacks if I use simple string concatenation.  I would like to use bind variable if possible.

    In any case, it seems like trying to build a dynamic where clause does not seem to work as I want it would be...

    bv1 := 'colA = 5 and colB >= 9';
    
    query_str := 'SELECT * FROM view WHERE :bv1';
    
    OPEN CUR FOR query_str USING bv1;
    

    The code above pours out when I try to run it.

    Is there a way to build dynamic where the provisions without the use of concatenation of simple string that leaves me open to attacks by SQL injection?

    Thank you

    Hello.  I have read briefly upward on things, you suggested, but it seems a bit abstract for me since I was a novice.

    Can you give us an explanation or an example of how to use it to accomplish what I need to do?

    Do ypu really plan create a query with a WHERE clause that contains a predicate for all possible columns?

    Variable bind offer performance when the same query is executed several times with different values for bind variables.

    Select * from emp where empno =: v_empno

    After the first run Oracle will always be this query in the library cache. The next running can use the version of the cache even if the bind value is different.

    Select * from emp where empno =: v_empno;

    Select * from emp where ename =: v_ename;

    Select * from emp where sal =: v_sal;

    Each one is a DIFFERENT query. Yes - each of them uses a variable binding, but queries are different.

    So, if your username select EMPNO, an '=', and a value from the first query can be executed. But the next time that the user can select the ENAME column so that 'stored' first request may not be used given that the query does not match.

    The third time your user selects SAL so none of the first two queries can be used in the library cache. The use of bind variables gives performance during the SAME QUERY is used multiple times with DIFFERENT values for the variable binding. Oracle is not to analyze the hard query everything simply because the VALUE is different.

    So bind variables do not help you if most of the queries were completely DIFFERENT sets of predicates. And SYS_CONTEXT will not help either since that simply provides a way to define binds the values of the variables.

    Just for the simple example above, there are at least SIX possible combinations of columns that could choose your user name: empno, ename, sal, empno ename, empno & sal, ename & sal

  • Materialized view does not quickly refresh with sysdate in where clause

    Hi all

    I am trying to create a view, materialized with sysdate in where clause. This makes the complex query, and so I can't create a quick refreshment mview.

    I tried to create with rowid too, but it does not create a quick refreshment.

    I was wondering if someone can advise me, how can I accomplish this task, which would be really appreciated.

    The query is:

    create a materialized view PS_MEETING

    build the DEFERRED payment

    Refresh quickly with rowid

    as

    SELECT *.

    MEETING M

    WHERE state_desc = 'VIC '.

    OR Meet_date < TRUNC (SYSDATE);

    the behavior is documented: http://docs.oracle.com/cd/E11882_01/server.112/e25554/basicmv.htm#DWHSG8201

    General restrictions on update quickly

    The definition of the materialized view query is limited as follows:

    • The materialized view must not contain references to non-repetitive phrases such as SYSDATE and ROWNUM .

    So I guess that you would need a more static than sysdate condition - or another strategy update.

  • T/t with the WHERE clause using a list breaks

    Hello, all,.

    I have a project where I need to use a list as part of the WHERE clause for a t/t, and it is breaking.  I don't know what I'm doing wrong.

    For some pseudo-code, do I have a complete query of a database called 'people '.  A list of values for the t/t with the first query; the second query is my t/t:

    <cfquery name="getDIR" datasource="#request.THISDSN#">
        SELECT thisName dir FROM orgs WHERE thisID in (<cfqueryparam value="#form.org#" cfsqltype="cf_sql_varchar" list="yes" />)
    </cfquery>
    
    <cfquery name="people" database="people">
        SELECT colA, colB, colC, colD
        FROM people
        WHERE 1=1
            AND (
                div IN (<cfqueryparam value="#valueList(getDIR.dir)#" cfsqltype="varchar" list="yes" />)
                OR dir IN (<cfqueryparam value="#valueList(getDIR.dir)#" cfsqltype="varchar" list="yes" />)
                )
    </cfquery>
    
    
    

    I get the error message is "t/t syntax error: encountered" div IN \'thisValue\' ".»  Incorrect conditional expression, waiting for one of [as | null | between | in | comparison] condition. »

    Can support _not_ QoQ lists of WHERE clauses?

    V/r,

    ^_^

    SMH - so much... I just found.

    I forgot to give the lists in the second query bracket.


    (The pseudocode was manually typed, since my dev system is isolated from the internet, and I added the in my pseudo code when they were not in my original code.)

    * headdesk * headdesk * headdesk * headdesk *.

    V/r,

    ^_^

  • Passing the value of the where clause with the page

    Dear friends,

    I have a requirement like when I select a selection list value I should pass this value to sql query where clause without submitting the page

    ex I have a select like: P1_Dept guess I selects the value 10 in this

    then I have a query select * from emp where deptno =: P1_Dept.

    DB. ORACLE 11G

    APEX 4.1.1.00.23

    is this possible? can someone help me please in this topic

    Thanks and greetings

    Vballeda

    Suppose we have the selection list with the name P1_DEPT and query for report

    select * from emp where deptno = :P1_DEPT
    

    We create dynamic Action on the evolution of the P1_DEPT point. We will need two real actions:

    1-> set value action

    Set the Type - > body of the PL/SQL function

    The function of body - > return 1;

    Page item to submit-> P1_DEPT

    Change to delete-> Yes event

    Selecttion Type-> trigger element

    2. action-> Refresh

    Selecttion Type-> region

    Region-> your region of report

  • Group by, with and without where clause

    Do I need to use these two interior views to display the results by group by a line? I can get the same result without having to type the same statement select twice since these two SELECT statements differ only in where clause. This query is a simulation. My actual query is longer. My hope is to make this shorter query (without interior views).
    with tmp as (
    select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual UNION ALL
    select 'COMPLETE' status, 'GERMANY' country, 1 substatus FROM dual UNION ALL
    select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual)
    select v1.status, v1.country, v1.cnt01, v2.cntIncluding0 from 
    (select status, country, count(*) cnt01 from tmp tmp1 group by status, country) v1
    JOIN
    (select status, country, count(*) cntIncluding0 from tmp tmp2 where substatus=0 group by status, country) v2
    on v1.status=v2.status and v1.country=v2.country;
     

    totalnewby wrote:
    Do I need to use these two interior views to display the results by group by a line? I can get the same result without having to type the same statement select twice since these two SELECT statements differ only in where clause. This query is a simulation. My actual query is longer. My hope is to make this shorter query (without interior views).

    with tmp as (
    select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual UNION ALL
    select 'COMPLETE' status, 'GERMANY' country, 1 substatus FROM dual UNION ALL
    select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual)
    select v1.status, v1.country, v1.cnt01, v2.cntIncluding0 from
    (select status, country, count(*) cnt01 from tmp tmp1 group by status, country) v1
    JOIN
    (select status, country, count(*) cntIncluding0 from tmp tmp2 where substatus=0 group by status, country) v2
    on v1.status=v2.status and v1.country=v2.country;
    
    SQL> with tmp as
      2  (
      3  select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual UNION ALL
      4  select 'COMPLETE' status, 'GERMANY' country, 1 substatus FROM dual UNION ALL
      5  select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual
      6  )
      7  select status,
      8         country,
      9         count(substatus) cnt01,
     10         sum(decode(substatus, 0, 1, 0)) cntincluding0
     11    from tmp
     12   group by status, country
     13  ;
    
    STATUS   COUNTRY      CNT01 CNTINCLUDING0
    -------- ------- ---------- -------------
    COMPLETE GERMANY          3             2
    

Maybe you are looking for