Several COUNTY statements in a query

Hello

I have to do the query that counts number of subjects on different criteria. I did it with the COUNT (case when... then 1 end to another null) name_of_count, another similar leader, and so on until the clausule WHERE at the end of the page and the commune OF. And it works, but I am concerned by the representations.

Is it possible to make these requests without BREAKAGE?

Usually the FROM and WHERE clauses will determine performance, instructions in the SELECTION list BOX should have a minimal impact or performance.

Tags: Database

Similar Questions

  • Many of the statements in a query

    Hello

    I wonder if it is possible to have several similar statements in a query.

    Suppose that instead of

    Select * from someTable where of remarks like '% ab % '.

    I want to search for the many models of string as "edi %" '% odi' '% di %' '% gf' 'od %' '% % podi' etc. in a single query.

    BTW, the table contains millions of records.

    Concerning

    Crusoe

    Published by: Crusoe on January 19, 2009 00:25

    If you use regular expressions, you can make simple, rather than using many conditions GOLD...

    for example

    select *
    from someTable
    where regexp_like(remarks,'^.*(edi|odi|di|gf|od|podi).*$')
    
  • Several SELECT statements with COUNTY with different WHERE clauses.

    OK, so for a bit of background on what this is trying to accomplish...
    I have a small group of people in my team and I will use GROUP BY for their names.
    If each person will be on their own line. Next to their names, I want to be able to have several columns that use the ACCOUNT for the different search criteria (no duplicates)

    Overall, it should have their names, and I would like to add the number of tickets that each person has which meet certain criteria (all in different columns)
    I have applications that can do each of these tasks, but is it possible that I can group together on a single table statements, or use subqueries for these results?

    Do you mean you want something like that?

    SQL > ed
    A written file afiedt.buf

    1 with the team (emp_id, emp_name)
    2 (select 1, 'Fred' from dual union all
    3. Select 2, 'Bob' Union double all the
    4. Select 3, 'Jim' to double
    5            )
    6, tickets (emp_id, ticket_type, ticket_id, ticket_desc)
    7 (select 1, 1, 'BUG', 'First billet Freds' double Union all)
    8. Select 2, 1, 'CHANGE', "Freds second ticket" of all the double union
    9 select 3, 1, 'BUG', ' Freds third ticket "of any double union
    10. Select 4, 2, "CHANGE", "Bobs first ticket" of any double union
    11. Select 5, 3, "CHANGE", "Jims first ticket" of any double union
    12. Select 6, 3, "BUG", "Jims second ticket" of all the double union
    13. Select 7, 1, 'BUG', ' Freds fourth ticket ' from dual
    14            )
    15-
    16 END OF TEST DATA
    17-
    18 select emp_name
    19, count (case when ticket_type = 'BUG' then 1 end to another null) and bugs
    20, count (case when ticket_type = 'CHANGE' then 1 end to another null) as changes
    21 of the team t
    22 a left join external tickets tk (t.emp_id = tk.emp_id)
    23 * emp_name group
    SQL > /.

    EMP_ CHANGES OF BUGS
    ---- ---------- ----------
    Bob           0          1
    Fred 3 1
    Jim           1          1

  • eHref and a Case statement in Sql query

    Hi all

    I have a select statement that looks like this:

    Select

    case when dbms_desc = 'ORACLE' and then ' < a href = "f? p = & APP_ID.:115: & SESSION. : & DEBUG. : & PAGE. : 53 "> #DATABASE_NAME # < /a > '

    When dbms_desc = "SQL SERVER" and then "< a href =" f? p = & APP_ID.:115: & SESSION. : & DEBUG. : & PAGE. : 59 "> #DATABASE_NAME # < /a > '"

    Another null

    end as database_name,

    Decode(databases.inactive_flag,'Y','Yes','N','No',null) inactive_flag, servername,.

    application name, decode(application.critical_flag,'Y','Yes','N','No',null) critical_flag,

    Decode(application.inactive_flag,'Y','Yes','N','No',null) app_inactive_flag, databases.database_id

    application, database, server, application_database_int

    where databases.database_id = application_database_int.database_id (+) and

    application_database_int.application_id = application.application_id (+) and

    databases.server_id = server.server_id and: P54_DBMS_DESC = dbms_desc and

    (upper (database_name) like '%' | upper(:P54_DATABASE_NAME) |) '%')

    order by database_name

    This query creates a report of classis. The result is the following:

    I wanted to see was the name of the database in the first column in the form of links. What is the problem with the query?

    INKA says:

    I use Apex v5 and I don't see where I can put the attributes column for the column database_name "display under" for "Standard report column.

    In the designer of the Page, select the report column in the browser on the left pane and change the properties in the property editor on the right, the column definition Type plain text and special escape characters No. See the Release Notes for the naming of the differences column property in the APEX 5.0.

  • Several SQL statements with zero executions in the region of SQL

    Hello

    one of my databases has a large number of statements in the SQL box with zero executions. Some of them analyzed several times without a single run. Why the database stores these statements and how to avoid or reduce them?

    My problem is that the only time or zero time sql statements take the largest part of the area of sql:

    -sql statement and only once and without executing sql statements

    Select

    Count (1) num_sql_total,.

    sum (decode (executions, 1, 1, 0)) num_one_use_sql,.

    sum (decode (executions, 0, 1, 0)) num_no_use_sql,.

    Sum (RUNTIME_MEM) / 1024/1024 mb_used,.

    sum (decode (executions, sharable_mem, 1, 0)) / 1024/1024 mb_for_one_use_sql,.

    sum (decode (executions, 0, sharable_mem, 0)) / 1024/1024 mb_for_no_use_sql

    Of

    GV$ sqlarea

    where

    RUNTIME_MEM > 0;

    NUM_SQL_TOTAL NUM_ONE_USE_SQL NUM_NO_USE_SQL MB_USED MB_FOR_ONE_USE_SQL MB_FOR_NO_USE_SQL

    23318

    8739

    8027

    1420,95619106293

    381,41183757782

    530,999855041504

    Concerning

    Thomas

    This is not unusual. Another app could analyze for example hard the most often used SQLs in upstairs app - making benefit of further processing (in theory) of sweet analysis when you use these SQLs.

    In fact, I remember reading something to this effect as a performance for some factor or another Oracle document or note?

    So unless you have serious questions of shared pool, why bother with these sliders? What would be the problem?

  • Using several 'if' statement parameters in the propertyy to apply for creationComplete

    In my application, I have several user profiles that are initially all hidden but are made visible to the user adds and then saved when the application is closed.

    What I want is however a menu (that I already created as addProfileWindow) appear as soon as the application starts if no user profile has already been added.

    For this I plan to use the creationComplete of the tag main application with an if statement, but I don't know how to put multiple parameters in a single case statement. My 5 profiles are named Profile1, Profil2, profile3, profile4 and profile5.

    Basically, I want an if statement that runs on creationComplete of the PPA and the addProfileWindow to bring up if all profiles are not currently visible. I thougt it would be something like this, but I guess not: -.

    creationComplete = "if (profile1.visible = false profile2.visible plus false + profile3.visible = false + profile4.visible = false + profile5.visible = false) addProfileWindow.visible = true;" "

    If this post has answered your question or helped, please mark it as such.

    You better put that in a creationComplete event handler function:

    creationComplete = "creationCompleteFunction ()" "

    private function creationCompleteFunction (): void {}

    If (profile1.visible = false & profile2.visible = false & profile3.visible = false & profile4.visible = false & profile5.visible = false) {}

    addProfileWindow.visible = true;

    }

    }

    Note the use of & instead of +.

    You could also do this:

    private function creationCompleteFunction (): void {}

    If (! profile1.visible &! profile2.visible &! profile3.visible &! profile4.visible &! profile5.visible) {}

    addProfileWindow.visible = true;

    }

    }

  • Several Select statements fill Horizontal

    Hello
    I wonder how to fill these three instructions select a line, horizontal. The data does not correctly from my code below.
    The first statement returns 4 rows
    The second statement returns 27 lines
    The last third statement returns 31 rows
    My problem is that when the code below runs more than 500 rows are returned. What I do wrong to not fill the
    results.
    Example of how the data should look like, I don't understand the third declaration for space.
    CUSTOMER NAME - CUST_FIRST_NAME -CUST_LAST_NAME - CUST_CITY | CUSTOMER NAME - CUST_FIRST_NAME -CUST_LAST_NAME - CUST_CITY 
             1                           JOHN                   DOE                 HOUSTON                1                       CHERYL                   JONES                WACO  
             1                           BOB                     BOBBY                DALLAS                 1                       ANNETTE                JONES                AUSTIN
              --this data should not be repeating since the other select statements             1                       TOM                       BOBBY               JACOB
              --has more rows, these rows should be empty                                             1                       TOMMY                   BANKS               ROB
                                                                                                                           1                       BILLY                      HANK                 TOM  
    select distinct x.*, y.*, z.*
    from
    (select count(*) as "CUSTOMER NAME", 
    CUST_FIRST_NAME,
    CUST_LAST_NAME,  
    CUST_CITY
    from DEMO_CUSTOMERS
    where CUST_FIRST_NAME  like '%A%'
    --and HIRE_DATE BETWEEN TO_DATE(:P10_START_DATE, 'MM/DD/YYYY') AND TO_DATE(:P10_END_DATE, 'MM/DD/YYYY')
    GROUP BY CUST_FIRST_NAME, CUST_LAST_NAME, CUST_CITY
    ORDER BY CUST_FIRST_NAME ASC) x,
    (select count(*) as "CUSTOMER NAME", 
    CUST_FIRST_NAME,
    CUST_LAST_NAME,  
    CUST_CITY
    from DEMO_CUSTOMERS
    where CUST_FIRST_NAME  not like '%A%'
    --and HIRE_DATE BETWEEN TO_DATE(:P10_START_DATE, 'MM/DD/YYYY') AND TO_DATE(:P10_END_DATE, 'MM/DD/YYYY')
    GROUP BY CUST_FIRST_NAME, CUST_LAST_NAME, CUST_CITY
    ORDER BY CUST_FIRST_NAME ASC) y,
    (select count(*) as "CUSTOMER NAME", 
    CUST_FIRST_NAME,
    CUST_LAST_NAME,  
    CUST_CITY
    from DEMO_CUSTOMERS
    --where HIRE_DATE BETWEEN TO_DATE(:P10_START_DATE, 'MM/DD/YYYY') AND TO_DATE(:P10_END_DATE, 'MM/DD/YYYY')
    GROUP BY CUST_FIRST_NAME, CUST_LAST_NAME, CUST_CITY
    ORDER BY CUST_FIRST_NAME ASC) z;
    I hope someone can help me with this, thanks a lot.

    Hello

    The best is probably the cross join the demo_customer table will be a table that has 3 lines (so that the demo_customers data can be repeated up to 3 times, that the conditions are met), assign a number line (r_num) for the data replcated and pivot so that data on a line by r_num like that :

    WITH     cntr     AS
    (
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL     <= 3
    )
    ,     got_criteria     AS
    (
         SELECT     d.cust_first_name, d.cust_last_name, d.cust_city
         ,     CASE
                   WHEN  c.n     = 1
                   AND   cust_first_name         LIKE '%A%'
                         THEN  c.n
                   WHEN  c.n     = 2
                   AND   cust_first_name     NOT LIKE '%A%'
                         THEN  c.n
                   WHEN  c.n = 3
                   AND   cust_first_name     >= 'A'
                         THEN  c.n
              END     AS crit_num
         FROM          demo_customers     d
         CROSS JOIN     cntr          c
    --     WHERE   hire_date     BETWEEN     TO_DATE (:p10_start_date, 'MM/DD/YYYY')      -- Filter as much as possible here
    --                    AND     TO_DATE (:p10_end_date,   'MM/DD/YYYY')
    )
    ,     got_r_num     AS
    (
         SELECT     got_criteria.*
         ,     DENSE_RANK () OVER ( PARTITION BY  crit_num
                                   ORDER BY          cust_first_name
                             ,                cust_last_name     -- Be sure to include these
                             ,             cust_city
                           )      AS r_num
         FROM    got_criteria
         WHERE     crit_num     IS NOT NULL
    )
    SELECT       r_num
    ,       NULLIF (COUNT (CASE WHEN crit_num = 1 THEN 1 END), 0)          AS cnt_1
    ,       MIN   (CASE WHEN crit_num = 1 THEN cust_first_name END)     AS first_name_1
    ,       MIN   (CASE WHEN crit_num = 1 THEN cust_last_name  END)     AS last_name_1
    ,       MIN   (CASE WHEN crit_num = 1 THEN cust_city       END)     AS city_1
    ,       NULLIF (COUNT (CASE WHEN crit_num = 2 THEN 1 END), 0)          AS cnt_2
    ,       MIN   (CASE WHEN crit_num = 2 THEN cust_first_name END)     AS first_name_2
    ,       MIN   (CASE WHEN crit_num = 2 THEN cust_last_name  END)     AS last_name_2
    ,       MIN   (CASE WHEN crit_num = 2 THEN cust_city       END)     AS city_2
    ,       NULLIF (COUNT (CASE WHEN crit_num = 3 THEN 1 END), 0)          AS cnt_3
    ,       MIN   (CASE WHEN crit_num = 3 THEN cust_first_name END)     AS first_name_3
    ,       MIN   (CASE WHEN crit_num = 3 THEN cust_last_name  END)     AS last_name_3
    ,       MIN   (CASE WHEN crit_num = 3 THEN cust_city       END)     AS city_3
    FROM       got_r_num
    GROUP BY  r_num
    ORDER BY  r_num
    ;
    

    The result of your sample data is:

    .R_ CNT FIRST    LAST                CNT FIRST    LAST                CNT FIRST    LAST
    NUM  _1 _NAME_1  _NAME_1  CITY_1      _2 _NAME_2  _NAME_2  CITY_2      _3 _NAME_3  _NAME_3  CITY_3
    --- --- -------- -------- ---------- --- -------- -------- ---------- --- -------- -------- ----------
      1   1 ABBY     DUNN     MOBILE       1 JOHN     EDDY     DALLAS       1 ABBY     DUNN     MOBILE
      2   1 EDWARD   TODD     AUSTIN       1 JOHN     JAMES    HOUSTON      1 EDWARD   TODD     AUSTIN
      3                                    1 JOHNNY   GEORGE   CINCY        1 JOHN     EDDY     DALLAS
      4                                    1 MILLY    BROOKS   DE RIDDER    1 JOHN     JAMES    HOUSTON
      5                                                                     1 JOHNNY   GEORGE   CINCY
      6                                                                     1 MILLY    BROOKS   DE RIDDER
    

    This has only to make a pass through the demo_customers table, so I think it will be faster to do a self-join, where you have to make a separate pass mark for each criterion.
    Make sure that the analytical got_rnum.r_num ORDER BY clause contains all the columns that have been in your original GROUP BY, even if you don't really care to their order. The main request will make a GROUP BY r_num, so including the columns in this clause ORDER BY to include in the GROUP BY.

    The problem with the full outer join is that you still do not put join conditions after the individual tables. After that the each keyword JOIN there will be a table name or a alias and immediately after that must come the key word WE followed by a coindition to join.
    I made a mistake earlier: when full outerer joining several tables, would better meet you each new table in each of the previous tables, because it is unclear which of these tables may be missing due to the outer join. In other words, the join condition for f had better be:

    ON           f.r_num = COALESCE (d.r_num, e.r_num)
    

    because d.r_num or e.r_num could be NULL, because the outer join.

  • Use the CASE statement in a query of LOV

    Hello

    I wrote a select statement to be used in my list of values query, and it works fine when I run with SQL Developer. But when I put it in the LOV I get the LOV query is invalid error message. Here's the query I use:
    select 
        case when nt.COMMON_NAME is not null then nt.COMMON_NAME || ' (' || nt.TAXON_NAME || ')'
            else nt.TAXON_NAME
        end display_species
       ,case when nt.COMMON_NAME is not null then nt.COMMON_NAME || ' (' || nt.TAXON_NAME || ')'
            else nt.TAXON_NAME
        end return_species
    FROM NBN_TAXON nt
    WHERE lower(nt.INPUT_CATEGORY) = decode(lower(:P312_TAXON_GROUP_ADD), 'fish', 'fishes', lower(:P312_TAXON_GROUP_ADD))     
    order by 1;
    If the CASE statement is the source of the problem?

    Hello

    Try to remove the colon semi at the end.

    See you soon

    Ben

  • Using syntax for the 'If' statement in the query?

    Hi, I work at the end before the PS 9.2 via the request handler and need help

    What I want to do, it's a field of expression to create
    another field of expression that I can use to group on. Maybe the query like
    expressions based on expressions...? Maybe because I'm on an Oracle database, I need to use Decode? If so, how can I use decode?

    Details:

    The field I created Gets the length of the employee in
    service and it works very well

    MONTHS_BETWEEN (SYSDATE, A.SERVICE_DT) / 12

    It works as a character or a numeric field.

    This is the problem... The next field, I would like that the query is one that goes like this...

    IF ((MONTHS_BETWEEN(SYSDATE,A.SERVICE_DT)/12))
    < = 4.99, "minus 5"

    ELSE IF ((MONTHS_BETWEEN(SYSDATE,A.SERVICE_DT)/12)) > = 5 AND
    ((MONTHS_BETWEEN(SYSYDATE,A.SERVICE_DT)/12)) < = 9.99, "5 to 9".

    ELSE IF ((MONTHS_BETWEEN(SYSDATE,A.SERVICE_DT)/12)) > = 10 AND
    ((MONTHS_BETWEEN(SYSYDATE,A.SERVICE_DT)/12)) < = 14.99, '10 to 14', "15 and"
    More»

    I get an error message that "a SQL error has occurred. For more details, please see your system log. Error in running because the SQL query is 972. Message = ORA-00972 identifier is too long (50 380)

    Can you tell me what expression should I use? And please keep in mind that I do not have access to the SQL Developer, so I have to use the query. Thank you!... Mary



    I would recommend using BOX WHEN if you're on an Oracle database.  Something like:

    CASE WHEN ((MONTHS_BETWEEN(SYSDATE,A.SERVICE_DT)/12)) <=4.99 then="" 'less="" than="" 5'="" when="" ((months_between(sysdate,a.service_dt)/12))="">= 5 AND

    ((MONTHS_BETWEEN(SYSDATE,A.SERVICE_DT)/12)) <=9.99 then="" '5="" to="" 9'="" when="" ((months_between(sysdate,a.service_dt)/12))="">= 10 AND ((MONTHS_BETWEEN(SYSDATE,A.SERVICE_DT)/12))<=14.99 then="" '10="" to="" 14'="" else="" '15="" and="" over'="">

    You can find more on the syntax of the CASE on the Oracle's Web site:

    http://docs.Oracle.com/CD/B19306_01/AppDev.102/b14261/case_statement.htm

  • NVARCHAR2 column in the select statement of the query


    Hello

    I have table

    xx_test / / DESC

    Name of Type Null

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

    COL1 NOT NULL NVARCHAR2 (100)

    COL2 NOT NULL NVARCHAR2 (100)

    COL3 NOT NULL NVARCHAR2 (100)

    I am able to interview

    Select * from xx_test

    However if the query as

    Select col1 from xx_test

    Then it is in error.

    ORA-00904: "COL1": invalid identifier

    00904, 00000 - '% s: invalid identifier '.

    * Cause:

    * Action:

    Error on line: column 3-131: 13

    Let me know how interrogate NVARCHAR2 column and how can we put in WHERE condition?

    Thank you

    Abhijit

    Abhijit,

    Now that you have already re-created the table, it would be difficult to find the exact cause. But I suspect it could happen due to the creation of table in a way not recommended the use of quotes.

    If you use double quotes while creating the table/column names, you must always use capital letters. Better is not not to use quotes in all. Here is an example of a test that could be the cause of your error.

    SQL > drop table test;

    Deleted table.

    SQL > create table test ("col1" nvarchar2 (200), col2 varchar2 (200));

    Table created.

    SQL > select Col1 from test;

    Select Col1 from test

    *

    ERROR on line 1:

    ORA-00904: "COL1": invalid identifier - it is him you got. Even if there is col1 column in the table, but I'm unable to select due to the bad way to appoint.

    SQL > drop table test;

    Deleted table.

    SQL > create table test ("COL1" nvarchar2 (200), col2 varchar2 (200));

    Table created.

    SQL >

    SQL > select col1 from test;

    no selected line

    The test case above apply to the tables as well.

    Ishan

  • Exclude results by using the WHERE statement in the query

    Hello!

    I use JDeveloper 11 g Release 2 (11.1.2.3.0).

    I have a complex query to display some products in different stores. I am trying to exclude some results, but I'm not be able to do. I have a table that looks like this:
    ProName     ProColor     ProSize      ShopName      ShopAddress
        Pro1        col1         10           Shop1         Address1
        Pro2        col2         12           Shop2         Address2
        Pro3        col3         12           Shop1         Address1
        Pro3        col3         12           Shop2         Address2
    And the query (essential):
    SELECT Products.ProId, Products.ProName, Products.ProColor, Products.ProSize, Shop.ShopId, Shop.ShopName, Shop.ShopAddress Stock.StockId, Stock.StoProId, Stock.StoShopId
        FROM Products, Shop, Stock
        WHERE ((Stock.StoProId = Products.ProId) AND (Stock.StoShopId = Shop.ShopId))
    The above table has 4 columns. When the product and color and size are equal, but I have the product in different stores, I want to only show once in the table as this (no matter which ShopName shows, but one only):
    ProName     ProColor     ProSize      ShopName      ShopAddress
        Pro1        col1         10           Shop1         Address1
        Pro2        col2         12           Shop2         Address2
        Pro3        col3         12           Shop1         Address1
    Please, can someone help me? Thanks in advance!

    Try this

    select t.*
      from (
         select products.proid
              , products.proname
              , products.procolor
              , products.prosize
              , shop.shopid
              , shop.shopname
              , shop.shopaddress
              , stock.stockid
              , stock.stoproid
              , stock.stoshopid
              , row_number() over(partition by products.proname, products.procolor, products.prosize order by shop.shopid) rno
           from products
              , shop
              , stock
          where stock.stoproid  = products.proid
            and stock.stoshopid = shop.shopid
           )
     where rno = 1
    
  • Several select increased in 1 query

    Team of hell,

    I am new to this SQL world. Please help me with this: -.

    I have following queries: -.
    #select name from v$ database;
    #select log_mode from v$ database;
    #select take into account (*) "INVALID_OBJECTS" from dba_objects where status = 'INVALID ';
    count (*) '_INDEXES INVALID_ n/d' #select from dba_indexes where status! = 'VALID ';
    #select take into account (*) invalid 'triggers' from user_objects where OBJECT_NAME like 'TRIGGERS %' and status = 'VALID ';
    #select count (*) 'Jobs broken' from dba_jobs where broken! = « Y » ;
    #select count (*) "Block of Corruption" from v$ database_block_corruption;

    I want a table that can be generated just select cmd and it will list the result of all of the above queires as follows: -.

    DB_NAME ARCH_MOD INV_OBJ INV_IDX INV_TRG B_JOB BLK_CRP
    ---------- -------------------------------------- -------------------------------------- ---------- ---------- ---------- ----------
    NOARCHIVELOG PROD 0 86 6 3 0


    I mean I want several select queries in the 1 table (note:-I'm not saying to create a table and then insert, update (use of select other tables), it's just a sheel script who will pick up these recordings in a txt file)

    Something like that?

    SQL> ed
    Wrote file afiedt.buf
    
      1  select a.name,
      2  a.log_mode,
      3  b."INVALID_OBJECTS",
      4  c."INVALID_N/A_INDEXES",
      5  d."Invalid Triggers",
      6  e."Broken Jobs",
      7  f."Block Corruption"
      8  from
      9  v$database a,
     10  (select count(*) "INVALID_OBJECTS" from dba_objects where status ='INVALID') b,
     11  (select count(*) "INVALID_N/A_INDEXES" from dba_objects where status !='VALID') c,
     12  (select count(*) "Invalid Triggers" from user_objects where OBJECT_NAME like '%TRIGGERS%' and status='VALID') d,
     13  (select count(*) "Broken Jobs" from dba_jobs where broken!='Y') e,
     14* (select count(*) "Block Corruption" from v$database_block_corruption) f
    SQL> /
    
    NAME      LOG_MODE     INVALID_OBJECTS INVALID_N/A_INDEXES Invalid Triggers Broken Jobs Block Corruption
    --------- ------------ --------------- ------------------- ---------------- ----------- ----------------
    ORCL      ARCHIVELOG                 1                   1                0           3                0
    
    SQL>
    

    Now, just try to replace your script with this:

    #! / bin/bash
    export hostname = $2;
    echo 'export has started. "
    export ORACLE_SID = $1;
    export ORACLE_HOME=/$1db/db/10.2.0;
    export LD_LIBRARY_PATH = / lib: / usr/lib: / usr/local/lib: $ORACLE_HOME/lib.
    export TNS_ADMIN=/$1db/db/tech_st/11.2.0/network/admin/$1_$2;
    PATH = / usr/bin: / usr/sbin: / usr/ccs/bin: / usr/local/oracle/bin: / usr/local/bin: / usr/dt/bin: / usr/openwin/bin: / usr/ucb: $ORACLE_HOME/bin: $ORACLE_HOME/OPatch;
    export PATH = $PATH: $ORACLE_HOME/bin.
    echo $ORACLE_HOME
    echo 'export complete.
    #export var1=/$1db/db/tech_st/11.2.0/$1_$2.env
    #export var2=/$1db/db/tech_st/11.1.0/$1_$2.env
    export var3=/$1db/db/10.2.0/$1_$2.env
    #. /$1dB/DB/tech_st/11.2.0/$1_$2.env
    #. /$1dB/DB/tech_st/11.1.0/$1_$2.env
    #./$1db/db/10.2.0/$1_$2.env

    sqlplus / as sysdba<>
    Select b.SID,
    a.log_mode,
    b."INVALID_OBJECTS."
    c.' INVALID_ N/A _INDEXES. "
    d."invalid triggers."
    e."broken jobs."
    (f)"Block Corruption".
    Of
    v$ database.
    (select count (*) "INVALID_OBJECTS" from dba_objects where status = 'INVALID') b.
    (select count (*) "_INDEXES INVALID_ n/d" from dba_objects where status! = 'VALID') c,.
    (select count (*) 'invalid triggers' from user_objects where OBJECT_NAME like 'TRIGGERS %' and status = 'VALID') d.
    (select count (*) 'jobs broken' from dba_jobs where broken! = 'Y') e,.
    f (select count (*) "Block of Corruption" from v$ database_block_corruption);
    "exit"; > filename.txt

    Let us know if it works for you or not.

    Concerning
    Girish Sharma

  • CASE statement in a query

    I have a following business rule:
    SELECT DISTINCT Clnt_id
    IN saverr
    WHERE trim (cove_cd) IN ('I' ' d "," R "" ")
    AND (trim (med_cd) IN ('B ','d ', 'X', ',' don't))
    GOLD trim (spend_down_cd) = 'Q')
    OR pt_a <>'000000';

    I must point out above clients as 'Y' else ' n

    I have written following statement but doesn't seem to work for <>clients '000000' pt_a.

    SELECT client_id, nvl(cove_cd,'$'), nvl(med_cd,'$'), nvl(spend_down_cd,'$'), nvl(pt_a,'$').
    CASE

    WHEN pt_a not in ('000000') or
    (TRIM (nvl(cove_cd,'$')) IN ('I' ' d ',' R' "))
    AND (trim (nvl(med_cd,'$')) IN ('B ','d ', 'X', ',' don't) GOLD trim (nvl(spend_down_cd,'$')) = 'Q'))

    THEN
    « Y »
    ANOTHER "N".
    END as dual_eligible
    IN saverr
    where pt_a like "000000";

    I always get the customers marked as "n" for pt_a as '000000'

    Any help is appreciated.

    Concerning
    Jay

    Published by: J1604 on July 17, 2012 15:26

    a little lost in all the ANDS and ors, and where to go the parenthesis.

    might be easier to work if you try something like that

    /* Formatted on 7/17/2012 4:58:14 PM (QP5 v5.185.11230.41888) */
    WITH T
         AS (SELECT client_id,
                    TRIM (NVL (cove_cd, '$')) cove_cd,
                    TRIM (NVL (med_cd, '$')) med_cd,
                    TRIM (NVL (spend_down_cd, '$')) pt_a
               FROM saverr)
    SELECT t.*,
           CASE
              WHEN pt_a NOT IN ('000000')
              THEN
                 'Y'
              WHEN     pt_a = '000000'
                   AND cove_cd IN ('I', 'D', 'R')
                   AND med_cd IN ('B', 'D', 'X', 'M', 'N')
              THEN
                 'Y'
              WHEN pt_a = '000000' AND spend_down_cd = 'Q'
              THEN
                 'Y'
              ELSE
                 'N'
           END
              col
      FROM t
    
  • Merger of statement: with several Update statement.

    Hello

    I'm trying under the merge statement. However to get the error "not correctly completed 0ra-00933 sql command.

    In fact, my join conditions are the same, but I wanted to update the different columns based on the different places where clause in the update statement.

    for example.

    FUSION
    IN abc3 tgt
    With the HELP of abc CBC
    WE (src.cust = tgt.cust)
    WHEN MATCHED
    THEN
    UPDATE
    SET tgt.sales = src.sales
    where tgt.cust = 'Cust3'
    UPDATE
    SET tgt.sales1 = src.sales
    where tgt.cust = 'Cust2';

    Please let me know if there is no work around for this.

    Hi, pm

    You can try this please.

    MERGE
     INTO ABC3 TGT
     USING ABC SRC
      ON (src.cust = tgt.cust)
    WHEN MATCHED THEN
    UPDATE SET TGT.SALES = DECODE(TGT.CUST,'Cust3',SRC.SALES,TGT.SALES),
               TGT.SALES1 = DECODE(TGT.CUST,'Cust2',SRC.SALES,TGT.SALES1)
    WHERE TGT.CUST='Cust3' OR tgt.cust='Cust2';
    
  • Calendar of transition control in several multi-state objects

    How can you control the timing of multiple transitions multistate DPS? If you have two slide shows with a single button by telling everyone to go to a particular State, the transitions go in sequence rather than simultaneously. You can adjust the schedule so that everyone goes at the same time and for the same duration?

    Currently, you cannot run two actions button at the same time.

Maybe you are looking for