What is this SQL trick

Can someone help me how do i get a result in one row :
Original Table Looks like below where C1,c2,c3,c4,c5 are columns and 1,2,3,4,A are the rows
C1 | C2 | C3 | C4| C5
1 2 3 4 A
1 2 3 4 B
1 2 3 4 C
I need output using SQL as
C1 | C2 | C3 | C4| C5
1 2 3 4 ABC
thanks in advance
Murali

Hola Murali and Christo la
solucion fue la siguiente em mi caso
particular. Espero que les sirva:
Nota: Esta solucion es para mas
columnas(Quitar Cn-2 y Cn-1)
Donde:
LO_EDIFICIO es C1
LO_PISO es C2 LO_ZONA es C3 LO_CVE_EMP es C4
LO_CC_O_CATEGORIA es Cn-2
LO_NO_ART es Cn-1
FALLO_POR es C5
create table lec_opt_rechazados(
LO_EDIFICIO VARCHAR2(10),
LO_PISO VARCHAR2(10),
LO_ZONA VARCHAR2(10),
LO_CVE_EMP VARCHAR2(10),
LO_CC_O_CATEGORIA VARCHAR2(10),
LO_NO_ART VARCHAR2(20),
FALLO_POR VARCHAR2(100))
TABLESPACE FNDPRO_TMP;
-- Crea Vistas --
Rem ********* Fallo por Edificio ****************
create or replace view FXE as
select
LO_EDIFICIO ,
LO_PISO ,
LO_ZONA ,
LO_CVE_EMP ,
LO_CC_O_CATEGORIA ,
LO_NO_ART ,
decode(fallo_por,'Edif','Edif',null) FXE
from lec_opt_rechazados;
Rem ********* Fallo por Piso *********************
create or replace view FXP as
select
LO_EDIFICIO ,
LO_PISO ,
LO_ZONA ,
LO_CVE_EMP ,
LO_CC_O_CATEGORIA ,
LO_NO_ART ,
decode(fallo_por,'Piso','Piso',null) FXP
from lec_opt_rechazados;
Rem ********* Fallo por Zona *********************
create or replace view FXZ as
select
LO_EDIFICIO ,
LO_PISO ,
LO_ZONA ,
LO_CVE_EMP ,
LO_CC_O_CATEGORIA ,
LO_NO_ART ,
decode(fallo_por,'Zona','Zona',null) FXZ
from lec_opt_rechazados;
Rem ********* Fallo por Cve Empleado **************
create or replace view FXCE as
select
LO_EDIFICIO ,
LO_PISO ,
LO_ZONA ,
LO_CVE_EMP ,
LO_CC_O_CATEGORIA ,
LO_NO_ART ,
decode(fallo_por,'Cve Emp','Cve Emp',null) FXCE
from lec_opt_rechazados;
Rem ********* Fallo por Centro de Costos o Categoria ********
create or replace view FXCC as
select
LO_EDIFICIO ,
LO_PISO ,
LO_ZONA ,
LO_CVE_EMP ,
LO_CC_O_CATEGORIA ,
LO_NO_ART ,
decode(fallo_por,'CC','CC','Categ','Categ',null) FXCC
from lec_opt_rechazados;
Nota: Si C5 tubiera dos valores
Rem ********* Fallo por Duplicados o repetidos ********
create or replace view FXD as
select
LO_EDIFICIO ,
LO_PISO ,
LO_ZONA ,
LO_CVE_EMP ,
LO_CC_O_CATEGORIA ,
LO_NO_ART ,
decode(fallo_por,'Art Dup','Art Dup',null) FXD
from lec_opt_rechazados;
-- Crea Vista General de Rechazados --
create or replace view V_LO_RECHAZADOS AS
select
A.LO_EDIFICIO LO_EDIFICIO ,
A.LO_PISO LO_PISO ,
A.LO_ZONA LO_ZONA ,
A.LO_CVE_EMP LO_CVE_EMP ,
A.LO_CC_O_CATEGORIA LO_CC_O_CATEGORIA ,
A.LO_NO_ART LO_NO_ART ,
max(fxe| |','| |fxp| |','| |fxz| |','| |fxce| |','| |fxcc| |','| |fxd) FALLO_POR
from
fxe a,fxp b, fxz c, fxce d,fxcc e, fxd f
where
a.lo_no_art = b.lo_no_art(+) and
b.lo_no_art = c.lo_no_art(+) and
c.lo_no_art = d.lo_no_art(+) and
d.lo_no_art = e.lo_no_art(+) and
e.lo_no_art = f.lo_no_art(+)
group by
A.LO_EDIFICIO ,
A.LO_PISO ,
A.LO_ZONA ,
A.LO_CVE_EMP ,
A.LO_CC_O_CATEGORIA ,
A.LO_NO_ART ;
Atte: Cualquier duda o aclaracion por favor
de enviarla a [email protected]
Oscar Molina Mexico D. F.
null

Similar Messages

  • What is this sql that is always in my top 10

    Does anybody know why this sql is always in my top 10 on the top activity page?
    SELECT VALUE
    FROM V$SESSION_FIX_CONTROL
    WHERE BUGNO = :B1 AND SESSION_ID = USERENV('SID')
    I started seeing this when we moved to 11gR2. I just want to understand what this is and why it takes up 10% of my resources.
    Thanks, Keith

    Thanks for your response Hans.
    Yes this is question best framed to support. It is just a PITA to get something simple into support. It is akin to going to the dentist. There are so many required boxes which are often irrelevant so you start making up BS just to submit the tar, SR. Then the SR goes to level 1 where someone tries to help you. It'll take them 10 days to understand that the SQL in question is an internal SQL statement submitted inside of Oracle. They will be asking me schema design questions or some other irrelevant stuff. Might as well ask me how I liked the weather. Sorry to rant, so I'll stop.
    Keith :-)

  • What is this SQL Tuning Advisor's Advice means

    HI ,
    I am Tuning a query wit hthe help of ORACLE 10 g 's SQL Tuning Advisor.I got the following recommendation .
    **Consider removing the disconnected table or view from this statement or add a join condition which refers to it.**
    I didn't understand what does this mean.
    Can anyone please help me
    Thanks,
    Pramod.
    Edited by: Pramod Garre on Jul 15, 2009 6:20 AM

    Simply saying if i apply that profile i will get Good plan.But I want to change the SQL itself rather than applying profile.in that case what can be done.Automatic SQL Tuning deals with this problem with its SQL Profiling capability. The Automatic Tuning Optimizer creates a profile of the SQL statement called a SQL Profile, consisting of auxiliary statistics specific to that statement. The query optimizer under normal mode makes estimates about cardinality, selectivity, and cost that can sometimes be off by a significant amount resulting in poor execution plans. SQL Profile addresses this problem by collecting additional information using sampling and partial execution techniques to verify and, if necessary, adjust these estimates.During SQL Profiling, the Automatic Tuning Optimizer also uses execution history information of the SQL statement to appropriately set optimizer parameter settings, such as changing the OPTIMIZER_MODE initialization parameter setting from ALL_ROWS to FIRST_ROWS for that SQL statement.
    If you want to change the SQL, You can re-write the SQL and evaluate the Performance recommendations SQL tuning Advisor.

  • What is this SQL give us

    I am trying to understand the SQL...Can anyone tell me what is SQL do...
    SELECT *
      FROM foms.inspection_task m
    WHERE type_check_code = 'P'
       AND
    EXISTS (
              SELECT 0
                FROM foms.inspection_task X
               WHERE X.TRIPPLANKEY = m.TRIPPLANKEY
                 AND X.dfl_sequence = m.dfl_sequence
                 AND X.ROWID !=M.ROWID)

    Hi,
    SELECT *                 -- Display all columns
      FROM foms.inspection_task m     -- from this table
    WHERE type_check_code = 'P'     -- with this condition
    AND
    EXISTS (               -- only if there's a row
              SELECT 0
                FROM foms.inspection_task X          -- in the same table
               WHERE X.TRIPPLANKEY = m.TRIPPLANKEY     -- with the same tripplankey
                 AND X.dfl_sequence = m.dfl_sequence  -- and the same dfl_sequence
                 AND X.ROWID !=M.ROWID)          -- but a different ROWIDROWID is unique for every row, so the effect is to pick the row "only if there's a *different* row in the same table ..."

  • What does this SQL Exception mean?

    Well I told you guys I'd be back with more questions. The database is now connected and my add User feature is working fine. I am however, receiving an SQL Exception when I try to update or delete. Here's the exception:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6183)
         at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2489)
         at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:329)
         at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:279)
         at UserDM.updateUser(UserDM.java:187)
         at User.updateUser(User.java:271)
         at UserUI.invokeUpdate(UserUI.java:296)
         at UserUI.actionPerformed(UserUI.java:236)
         at java.awt.Button.processActionEvent(Button.java:324)
         at java.awt.Button.processEvent(Button.java:297)
         at java.awt.Component.dispatchEventImpl(Component.java:2588)
         at java.awt.Component.dispatchEvent(Component.java:2492)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:334)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:126)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:93)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:88)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:80)
    java.sql.SQLException: Invalid handle
         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6198)
         at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2489)
         at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:329)
         at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:244)
         at UserDM.populateUser(UserDM.java:130)
         at User.buildUserVector(User.java:301)
         at User.updateUser(User.java:277)
         at UserUI.invokeUpdate(UserUI.java:296)
         at UserUI.actionPerformed(UserUI.java:236)
         at java.awt.Button.processActionEvent(Button.java:324)
         at java.awt.Button.processEvent(Button.java:297)
         at java.awt.Component.dispatchEventImpl(Component.java:2588)
         at java.awt.Component.dispatchEvent(Component.java:2492)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:334)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:126)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:93)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:88)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:80)Here is the method:
         // method to update info for a user in the database
        public static void updateUser(User aUser) throws SQLException
            String query1 = "UPDATE Users SET LastName = " + "'" + aUser.getUserLastName() + "'" + " WHERE Alias = " + aUser.getUserAlias();
              String query2 = "UPDATE Users SET FirstName = " + "'" + aUser.getUserFirstName() + "'" + " WHERE Alias = " + aUser.getUserAlias();
              String query3 = "UPDATE Users SET MiddleInitial = " + "'" + aUser.getUserMiddleInitial() + "'" + " WHERE Alias = " + aUser.getUserAlias();
              String query4 = "UPDATE Users SET Alias = " + "'" + aUser.getUserAlias() + "'" + " WHERE Alias = " + aUser.getUserAlias();
              String query5 = "UPDATE Users SET Password = " + "'" + aUser.getUserPassword() + "'" + " WHERE Alias = " + aUser.getUserAlias();
              String query6 = "UPDATE Users SET Role = " + "'" + aUser.getUserRole() + "'" + " WHERE Alias = " + aUser.getUserAlias();
              String query7 = "UPDATE Users SET Rights = " + "'" + aUser.getUserType() + "'" + " WHERE Alias = " + aUser.getUserAlias();
            Statement statement = connection.createStatement();
              statement.executeUpdate(query1);
            statement.executeUpdate(query2);
            statement.executeUpdate(query3);
            statement.executeUpdate(query4);
            statement.executeUpdate(query5);
            statement.executeUpdate(query6);
            statement.executeUpdate(query7);
              userList.removeAll();
               if( userRS !=null)
               while( userRS.next() )
                         aLastName = userRS.getString(1);
                         userList.add(aLastName);
            statement.close();
              close();
              open();
        }The reason for the multiple queries is that it's just easier with my editor than trying to concatenate to new lines. I still get the same exception with just one query.
    Thanks,
    Shawn

    I changed it to the prepared statement. As for the question about the Alias, I don't know why that would have to be in parentheses since it's a field in the table. I double checked all the table and field names with the one in the code, they are in sync. Here's my new method:
         // method to update info for a user in the database
        public static void updateUser(User aUser) throws SQLException
         String preparedSQL = "UPDATE Users SET " +
                                   "LastName = ?, FirstName = ?, MiddleInitial = ?, Alias = ?, Password = ?, Role = ?, Rights = ?" +
                                  "WHERE Alias = ?";
         PreparedStatement ps = connection.prepareStatement(preparedSQL);
         ps.setString(1, aUser.getUserLastName());
         ps.setString(2, aUser.getUserFirstName());
         ps.setString(3, aUser.getUserMiddleInitial());
         ps.setString(4, aUser.getUserAlias());
         ps.setString(5, aUser.getUserPassword());
         ps.setString(6, aUser.getUserRole());
         ps.setString(7, aUser.getUserType());
         ps.setString(8, aUser.getUserAlias());
         ps.executeUpdate();
    }Here are the exceptions I'm getting now:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect
    java.sql.SQLException: Invalid handle
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Pa_RaM006WHERE Alias = Pa_RaM007'.
    java.sql.SQLException: Invalid handle
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Pa_RaM006WHERE Alias = Pa_RaM007'.
    java.sql.SQLException: Invalid handle
    java.lang.ArrayIndexOutOfBoundsException: 7
    java.sql.SQLException: Invalid handle
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Pa_RaM006WHERE Alias = Pa_RaM007'.
    java.sql.SQLException: Invalid handleWhat could the missing operator be for the Alias? I've tried using the message aUser.getUserAlias instead of the ?, but it gives the same exception.
    I do not have it set up for CONCUR_UPDATABLE, it that necessary for this application? I also heard that a permission statement is supposed to be added to the java.policy file, any input on this?
    Thanks!
    Shawn

  • What's wrong with this SQL?

    what's wrong with this SQL?
    Posted: Jan 16, 2007 9:35 AM Reply
    Hi, everyone:
    when I insert into table, i use the fellowing SQL:
    INSERT INTO xhealthcall_script_data
    (XHC_CALL_ENDED, XHC_SWITCH_PORT, XHC_SCRIPT_ID, XHC_FAX_SPECIFIED)
    VALUES (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT, HH_SCRIPT,'N'
    FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE' UNION
    SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT, HH_SCRIPT,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE');
    I always got an error like;
    VALUES (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT,
    ERROR at line 3:
    ORA-00936: missing expression
    but I can't find anything wrong, who can tell me why?
    thank you so much in advance
    mpowel01
    Posts: 1,516
    Registered: 12/7/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:38 AM in response to: jerrygreat Reply
    For starters, an insert select does not have a values clause.
    HTH -- Mark D Powell --
    PP
    Posts: 41
    From: q
    Registered: 8/10/06
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:48 AM in response to: mpowel01 Reply
    Even I see "missing VALUES" as the only error
    Eric H
    Posts: 2,822
    Registered: 10/15/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:54 AM in response to: jerrygreat Reply
    ...and why are you doing a UNION on the exact same two queries?
    (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS') ,HH_SWITCHPORT ,HH_SCRIPT ,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE' UNION SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS') ,HH_SWITCHPORT ,HH_SCRIPT ,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE');
    jerrygreat
    Posts: 8
    Registered: 1/3/07
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:55 AM in response to: mpowel01 Reply
    Hi,
    thank you for your answer, but the problem is, if I deleted "values" as you pointed out, and then execute it again, I got error like "ERROR at line 3:
    ORA-03113: end-of-file on communication channel", and I was then disconnected with server, I have to relogin SQLplus, and do everything from beganing.
    so what 's wrong caused disconnection, I can't find any triggers related. it is so wired?
    I wonder if anyone can help me about this.
    thank you very much
    jerry
    yingkuan
    Posts: 1,801
    From: San Jose, CA
    Registered: 10/8/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:59 AM in response to: jerrygreat Reply
    Dup Post
    jerrygreat
    Posts: 8
    Registered: 1/3/07
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 10:00 AM in response to: Eric H Reply
    Hi,
    acturlly what I do is debugging a previous developer's scipt for data loading, this script was called by Cron work, but it never can be successfully executed.
    I think he use union for eliminating duplications of rows, I just guess.
    thank you
    jerry
    mpowel01
    Posts: 1,516
    Registered: 12/7/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 10:03 AM in response to: yingkuan Reply
    Scratch the VALUES keyword then make sure that the select list matches the column list in number and type.
    1 insert into marktest
    2 (fld1, fld2, fld3, fld4, fld5)
    3* select * from marktest
    UT1 > /
    16 rows created.
    HTH -- Mark D Powell --
    Jagan
    Posts: 41
    From: Hyderabad
    Registered: 7/21/06
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 10:07 AM in response to: jerrygreat Reply
    try this - just paste the code and give me the error- i mean past the entire error as it is if error occurs
    INSERT INTO xhealthcall_script_data
    (xhc_call_ended, xhc_switch_port, xhc_script_id,
    xhc_fax_specified)
    SELECT TO_DATE (hh_end_date || ' ' || hh_end_time, 'MM/DD/YY HH24:MI:SS'),
    hh_switchport, hh_script, 'N'
    FROM tmp_healthhit_load
    WHERE hh_script != 'BROCHURE'
    UNION
    SELECT TO_DATE (hh_end_date || ' ' || hh_end_time, 'MM/DD/YY HH24:MI:SS'),
    hh_switchport, hh_script, 'N'
    FROM tmp_healthhit_load
    WHERE hh_script != 'BROCHURE';
    Regards
    Jagan
    jerrygreat
    Posts: 8
    Registered: 1/3/07
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 11:31 AM in response to: Jagan Reply
    Hi, Jagan:
    thank you very much for your answer.
    but when I execute it, I still can get error like:
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    so wired, do you have any ideas?
    thank you very much

    And this one,
    Aother question about SQL?
    I thought I already told him to deal with
    ORA-03113: end-of-file on communication channel
    problem first.
    There's nothing wrong (syntax wise) with the query. (of course when no "value" in the insert)

  • Whats wrong with this sql statement ??

    Hello all, I am trying to run the below query out of persheet(tanel poder) performance excel chart...but i get below error...db is on 9.2
    what is wrong with this sql statement ?
    http://blog.tanelpoder.com/2008/12/28/performance-visualization-made-easy-perfsheet-20-beta/
    select * from (
    with fsq as (
      select /*+ materialize */
       i.dbid
        , i.instance_name
        , i.instance_number
    --    , trunc(s.snap_time, 'DD')     DAY
    --    , to_number(to_char(s.snap_time, 'HH24'))  HOUR
    --   -- , to_char(s.snap_time, 'MI')    MINUTE
    --    , 0           MINUTE
        , trunc(
          lag(s.snap_time, 1)
          over(
           partition by
          v.dbid
           , i.instance_name
           , v.instance_number
           , v.event
         order by
          s.snap_time
          , 'HH24'
         )           SNAP_TIME
        , v.event_type        EVENT_TYPE
        , v.event          EVENT_NAME
        , nvl(
        decode(
         greatest(
          time_waited_micro,
          nvl(
           lag(time_waited_micro,1,0)
           over(
            partition by
             v.dbid
              , i.instance_name
              , v.instance_number
              , v.event
            order by v.snap_id
           , time_waited_micro
         time_waited_micro,
         time_waited_micro - lag(time_waited_micro,1,0)
         over (
          partition by
           v.dbid
            , i.instance_name
            , v.instance_number
            , v.event
          order by v.snap_id
         time_waited_micro
           , time_waited_micro
         ) / 1000000         SECONDS_SPENT
        , total_waits         WAIT_COUNT
      from
       (select distinct dbid, instance_name, instance_number from stats$database_instance) i
        , stats$snapshot s
        , ( select
         snap_id, dbid, instance_number, 'WAIT' event_type, event, time_waited_micro, total_waits
        from
         stats$system_event
        where
         event not in (select event from stats$idle_event)
        union all
        select
         snap_id, dbid, instance_number,
         case
          when name in ('CPU used by this session', 'parse time cpu', 'recursive cpu usage') then 'CPU'
          when name like 'OS % time' then 'OS'
          else 'STAT'
         end,
         name , value, 1
        from
         stats$sysstat
    --    where      name in ('CPU used by this session', 'parse time cpu', 'recursive cpu usage')
    --    or  name like('OS % time')
    --    or 1 = 2 -- this will be a bind variable controlling whether all stats need to be returned
       ) v
      where
       i.dbid = s.dbid
      and i.dbid = v.dbid
      and s.dbid = v.dbid
      and s.snap_id = v.snap_id
      and s.snap_time between '%FROM_DATE%' and '%TO_DATE%'
      and i.instance_name = '%INSTANCE%'
    select * from (
      select
       instance_name
        , instance_number
        , snap_time
        , trunc(snap_time, 'DD')  DAY
        , to_char(snap_time, 'HH24') HOUR
        , to_char(snap_time, 'MI') MINUTE      
        , event_type  
        , event_name  
        , seconds_spent
        , wait_count  
        , ratio_to_report(seconds_spent) over (
    --      partition by (to_char(day, 'YYYYMMDD')||to_char(hour,'09')||to_char(minute, '09'))
          partition by (snap_time)
          ) ratio
      from fsq
      where
       snap_time is not null -- lag(s.snap_time, 1) function above will leave time NULL for first snapshot
      -- to_char(day, 'YYYYMMDD')||to_char(hour,'09')||to_char(minute, '09')
      -- > ( select min(to_char(day, 'YYYYMMDD')||to_char(hour,'09')||to_char(minute, '09')) from fsq)
    where ratio > 0
    order by
        instance_name
      , instance_number
      , day
      , hour
      , minute
      , event_type
      , seconds_spent desc
      , wait_count desc
    Error at line 6
    ORA-00604: error occurred at recursive SQL level 1
    ORA-00972: identifier is too long

    Hi Alex,
    Subquery factoring a.k.a. the with-clause should be possible on 9.2:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_103a.htm#2075888
    (used it myself as well on 9.2)
    @OP
    I recall having problems myself using PL/SQL Developer and trying to get the with clause to work on 9.2 some years ago.
    A workaround might be to create a view based on the query.
    Also, your error message is "ORA-00972: identifier is too long"...
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14219/e900.htm#sthref419
    Can't test things currently, no 9.2 available at the moment, but perhaps tomorrow I'll have a chance.

  • Whats wrong in this SQL - Help Required..

    Hi,
    Can you please tell me what is wrong in this SQL Query.
    select
    case
    when
    (SELECT territory_code
    FROM
              fnd_territories
              where territory_code like 'BR') then
    (SELECT description
                        FROM fnd_descr_flex_contexts_tl
    WHERE descriptive_flexfield_name='JG_PO_VENDOR_SITES'
                        AND descriptive_flex_context_code='JL.BR.APXVDMVD.SITES')
    else
    NULL
    end result
    FROM dual;
    Thanks,

    Based on the info supplied, here's a few possibilities,
    you've typed the table name incorrectly
    You've not restricted the results correctly,
    you're using a version of oracle that doesn't support the CASE expression
    You're using SQL server, which doesn't have the dual table.
    you've / someone has manipulated teh dual table so that it now has 4billion and one rows
    The subquery in your case statement returns more than one row.
    1. It's poorly/not formatted.
    2. It's not in code tags
    3. You haven't given us anywhere near enough info e.g. Error messages, what you're actually trying to do etc, etc

  • What is this error java.sql.SQLException: Bad format for number ?

    Dear All,
    I am reading few values from database. Then I get this error "MyError:Error : java.sql.SQLException: Bad format for number 'Sarawak' in column 6. " So what is this error referring to. I have checked the database column and its value fits according the data type. Any hints please?

    I have checked the database column and its value fits according the data type.Check again. Then check again. Keep checking until you find your error. You are trying to read a string containing "Sarawak" as a number. You have "getInt(6)" or other numeric type, and the 6th column in the select statement is not numeric.

  • Sql.log what is this all about

    hi
    i wanted to know why is this sql.log created on any drive on each jar opperation
    contents being
    vin(T)_ fff8382f:ffc73d0f     ENTER SQLAllocEnv
              HENV * 0x0b41f724
    vin(T)_ fff8382f:ffc73d0f     EXIT SQLAllocEnv with return code 0 (SQL_SUCCESS)
              HENV * 0x0b41f724 ( 0x0b70ff24)
    vin(T)_ fff8382f:ffc73d0f     ENTER SQLAllocConnect
              HENV 0x0b70ff24
              HDBC * 0x0b41f688
    vin(T)_ fff8382f:ffc73d0f     EXIT SQLAllocConnect with return code 0 (SQL_SUCCESS)
              HENV 0x0b70ff24
              HDBC * 0x0b41f688 ( 0x0b610194)

    i didnt get the debuggind stuff a little confused on
    who initiates
    that , as i have not.Let me try a slightly different take on what I said before.
    Use "Start" and go to "Settings", then "Control Panel"
    In there find either something that refers to "ODBC" or "Data Sources". You might have to poke around however this will be there. (Let me repeat it is there - it might be in a sub folder in the control panel but it is always there.)
    Open it.
    Look for a tab that says "Tracing", click on that.
    I can't say for sure what you will find there, but on my system there is a big button that says "Start Tracing Now" and then says "Stop Tracing Now" when I click on it. Obviously when it says "Stop Tracing Now" it is no longer tracing. Yours will have something similar. Yours is turned on.
    You will also notice that the file that it uses for tracing is called "sql.log". But once you turn the tracing off that no longer matters.

  • What is native Sql data types and does oracle support this?

    what is native Sql data types
    Does oracle support this?

    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#g31099

  • What this SQL statement is doing?

    Hi ABAPers,
    Can somebody help me in understanding what the below SQL statement is doing..
      SELECT * FROM /BIC/ADSO00 AS tb1
          INNER JOIN /BIC/PMASTER as tbl2
          ON tbl1~field1 = tbl2~field1
          AND tbl12~field2 = tbl2~field2
          INTO CORRESPONDING FIELDS OF TABLE gt_itab
          FOR ALL ENTRIES IN SOURCE_PACKAGE
          WHERE tbl1~field3 = SOURCE_PACKAGE-field3
          AND tbl1~field4 BETWEEN lv_minper AND lv_maxper
          AND tbl1~field5 = SOURCE_PACKAGE-field5
          AND tbl1~field6 = '0100'
          AND tbl2~OBJVERS = 'A'.
    thanks in advance !!
    Bharath S

    Hi Bharath,
    tb1 is your /BIC/ADSO00 table
    tbl2 is your  /BIC/PMASTER second table.
    It is selecting all contents from /BIC/ADSO00 table available and is selecting respective contents from /BIC/PMASTER second table using field 1 and field2 as key(unique in two tables) and moving into an internal table(structures used in program for holding values similar to DB and can hold values till program execution ends) and selection is valid only for entries in source_package another internal table.
    Conditions for the selections are
    tbl1~field3 = SOURCE_PACKAGE-field3
          AND tbl1~field4 BETWEEN lv_minper AND lv_maxper
          AND tbl1~field5 = SOURCE_PACKAGE-field5
          AND tbl1~field6 = '0100'
          AND tbl2~OBJVERS = 'A'.
    Hope it will be helpful.
    Regards,
    Kannan

  • What is the more effective way to run this sql

    I have a sql like this:
    select
    ((select q_avg24 from view1 where years=2009 and qtr=1) - (select q_avg24 from view1 where years=2010 and qtr=1)) as sub_s1_avg24,
    ((select q_avg24 from view2 where years=2009 and qtr=1) - (select q_avg24 from view2 where years=2010 and qtr=1)) as sub_s2_avg24,
    ((select q_avg24 from view3 where years=2009 and qtr=1) - (select q_avg24 from view3 where years=2010 and qtr=1)) as sub_s3_avg24,
    ((select q_avg24 from view4 where years=2009 and qtr=1) - (select q_avg24 from view4 where years=2010 and qtr=1)) as sub_s4_avg24
    from dualAs you can see that, the sql calculate a field value from another views (view1, view2, view3, view4).
    It return the difference between 2 years.
    In this sql, you can see it will request the views for 2x4=8 times to get the result table.
    Each sql (select statement) query return a result within 5 seconds, so...for total = 8X5=40secs...
    40 secs is not so big problem...but in fact, I have at least 5 sets queries (select statements) with other parameters are not input for calculation from this query........
    It is a huge amount of time consuming in resulting SQL: (8X5secs) x 5 sets = 200secs.....
    I would like to know is there any better solution if we face this kind of problems??
    THANKS!!!!

    You can use like.. not tested..
    But if you provide more details on data I think we can think of better solution
    select sum(decode(id,1,decode(yers,2009,av,0),0))-sum(decode(id,1,decode(yers,2010,av,0),0)) av1,
           sum(decode(id,2,decode(yers,2009,av,0),0))-sum(decode(id,2,decode(yers,2010,av,0),0)) av2,
           sum(decode(id,3,decode(yers,2009,av,0),0))-sum(decode(id,3,decode(yers,2010,av,0),0)) av3,
           sum(decode(id,4,decode(yers,2009,av,0),0))-sum(decode(id,4,decode(yers,2010,av,0),0)) av4
    from(
      select 1 id,q_avg24 av,years
      from view1
      where years in (2009,2010)
      and qtr = 1
      union all
      select 2 id,q_avg24,years
      from view2
      where years in (2009,2010)
      and qtr = 1
      union all
      select 3 id,q_avg24,years
      from view3
      where years in (2009,2010)
      and qtr = 1
      union all
      select 4 id,q_avg24,years
      from view4
      where years in (2009,2010)
      and qtr = 1)Edited by: jeneesh on Mar 30, 2012 1:31 PM

  • What are the SQL server versions those are compatible with XI 3.0.

    Hi All,
    Please suggest,
    what are the SQL server versions those are compatible with XI 3.0.
    or with which SQL server versions XI 3.0 will interact using JDBC Adapter.

    Check in the [Product Availability Matrix |https://websmp201.sap-ag.de/~form/handler?_APP=00200682500000001303&_EVENT=DISP_NEW&00200682500000002804=01200314690900000192]in market place for more information on this
    Thanks
    SaNv...

  • How to reduce the fetch time of this sql?

    Here is the SQL, three-table join and joining conditions are:
    ms_ets_cntrl.ims_cntrt_oid=ims_alctn.ims_alctn_oid
    ims_alctn.ims_trde_oid=ims_trde.ims_trde_oid
    SELECT 'MCH' Type, ims_ets_cntrl.STTS tp_stts, count(*) Count  FROM ims_ets_cntrl  where ims_ets_cntrl.ims_cntrt_oid in
    (select ims_alctn.ims_alctn_oid  FROM ims_alctn, ( select ims_trde.ims_trde_oid from ims_trde
    where ( IMS_TRDE.IMS_TRDE_RCPT_DTTM  >= TO_DATE('10/29/2009 00:00', 'MM/DD/YYYY HH24:MI') AND IMS_TRDE.IMS_TRDE_RCPT_DTTM <= (TO_DATE('11/5/2009 23:59', 'MM/DD/YYYY HH24:MI')) )
    AND (IMS_TRDE.GRS_TRX_TYPE IN ('INJECTION','WITHDRAWAL','PAYMENT') OR IMS_TRDE.SSC_INVST_TYPE = 'FC' AND  1=1  and IMS_TRDE.SERVICE_TYPE='FS' )) TRDE
    where IMS_ALCTN.IMS_TRDE_OID=TRDE.IMS_TRDE_OID) and ims_ets_cntrl.outbnd_dest = 'ETD' group by ims_ets_cntrl.STTSOptimizer and related parameter info:
    SQL> show parameter optimizer
    NAME                                 TYPE        VALUE
    optimizer_dynamic_sampling           integer     1
    optimizer_features_enable            string      9.2.0
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_max_permutations           integer     2000
    optimizer_mode                       string      CHOOSE
    SQL>select pname, pval1, pval2 from sys.aux_stats$ where sname='SYSSTATS_INFO';
    DSTART          11-16-2009 10:23
    DSTOP          11-16-2009 10:23
    FLAGS     1     
    STATUS          NOWORKLOADHere is autotrace output:
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE
       1    0   SORT (GROUP BY)
       2    1     VIEW
       3    2       SORT (UNIQUE)
       4    3         TABLE ACCESS (BY INDEX ROWID) OF 'IMS_ETS_CNTRL'
       5    4           NESTED LOOPS
       6    5             NESTED LOOPS
       7    6               TABLE ACCESS (BY INDEX ROWID) OF 'IMS_TRDE'
       8    7                 INDEX (RANGE SCAN) OF 'IMS_TRDE_INDX4' (NON- UNIQUE)
       9    6               TABLE ACCESS (BY INDEX ROWID) OF 'IMS_ALCTN'
      10    9                 INDEX (RANGE SCAN) OF 'IMS_ALCTN_INDX1' (NON  -UNIQUE)
      11    5             INDEX (RANGE SCAN) OF 'IMS_ETS_CNTRL_INDX1' (NON  -UNIQUE)
    Statistics
              0  recursive calls
              0  db block gets
         244608  consistent gets
          58856  physical reads
              0  redo size
            497  bytes sent via SQL*Net to client
            499  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              2  sorts (memory)
              0  sorts (disk)
              1  rows processedHere is TKPROF output:
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      4.85     129.72      53863     244608          0           1
    total        4      4.85     129.72      53863     244608          0           1
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 63 
    Rows     Row Source Operation
          1  SORT GROUP BY
      12972   VIEW 
      12972    SORT UNIQUE
      12972     TABLE ACCESS BY INDEX ROWID IMS_ETS_CNTRL
      46236      NESTED LOOPS 
      19134       NESTED LOOPS 
      19744        TABLE ACCESS BY INDEX ROWID IMS_TRDE
    176922         INDEX RANGE SCAN IMS_TRDE_INDX4 (object id 34099)
      19134        TABLE ACCESS BY INDEX ROWID IMS_ALCTN
      19134         INDEX RANGE SCAN IMS_ALCTN_INDX1 (object id 34094)
      27101       INDEX RANGE SCAN IMS_ETS_CNTRL_INDX1 (object id 34101)
    ********************************************************************************Explain plan output:
    PLAN_TABLE_OUTPUT
    | Id  | Operation                         |  Name                | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT                  |                      |       |       |       |
    |   1 |  SORT GROUP BY                    |                      |       |       |       |
    |   2 |   VIEW                            |                      |       |       |       |
    |   3 |    SORT UNIQUE                    |                      |       |       |       |
    |*  4 |     TABLE ACCESS BY INDEX ROWID   | IMS_ETS_CNTRL        |       |       |       |
    |   5 |      NESTED LOOPS                 |                      |       |       |       |
    |   6 |       NESTED LOOPS                |                      |       |       |       |
    |*  7 |        TABLE ACCESS BY INDEX ROWID| IMS_TRDE             |       |       |       |
    |*  8 |         INDEX RANGE SCAN          | IMS_TRDE_INDX4       |       |       |       |
    |   9 |        TABLE ACCESS BY INDEX ROWID| IMS_ALCTN            |       |       |       |
    |* 10 |         INDEX RANGE SCAN          | IMS_ALCTN_INDX1      |       |       |       |
    |* 11 |       INDEX RANGE SCAN            | IMS_ETS_CNTRL_INDX1  |       |       |       |
    Predicate Information (identified by operation id):
       4 - filter("IMS_ETS_CNTRL"."OUTBND_DEST"='ETD')
       7 - filter("IMS_TRDE"."GRS_TRX_TYPE"='INJECTION' OR "IMS_TRDE"."GRS_TRX_TYPE"='WITHD
                  RAWAL' OR "IMS_TRDE"."GRS_TRX_TYPE"='PAYMENT' OR "IMS_TRDE"."SSC_INVST_TY
                  PE"='FC' AND "IMS_TRDE"."SERVICE_TYPE"='FS')
       8 - access("IMS_TRDE"."IMS_TRDE_RCPT_DTTM">=TO_DATE('2009-10-29 00:00:00', 'yyyy-mm-
                  dd hh24:mi:ss') AND "IMS_TRDE"."IMS_TRDE_RCPT_DTTM"<=TO_DATE('2009-11-05
                  23:59:00', 'yyyy-mm-dd hh24:mi:ss')
      10 - access("IMS_ALCTN"."IMS_TRDE_OID"="IMS_TRDE"."IMS_TRDE_OID")
      11 - access("IMS_ETS_CNTRL"."IMS_CNTRT_OID"="IMS_ALCTN"."IMS_ALCTN_OID")
    Note: rule based optimizationCould you please help tune this sql?
    How can I reduce the elapsed time? How can I reduce query read?
    If there is any other info that you need, please let me know!
    thank you very much!

    What exactly is this logic meant to do?
    AND    (ims_trde.grs_trx_type IN ('INJECTION', 'WITHDRAWAL', 'PAYMENT')
            OR ims_trde.ssc_invst_type = 'FC'
            AND ims_trde.service_type = 'FS')is that really:
    AND    (ims_trde.grs_trx_type IN ('INJECTION', 'WITHDRAWAL', 'PAYMENT')
            OR ims_trde.ssc_invst_type = 'FC')
    AND    ims_trde.service_type = 'FS'or is it maybe:
    AND   (ims_trde.grs_trx_type IN ('INJECTION', 'WITHDRAWAL', 'PAYMENT')
           OR (ims_trde.ssc_invst_type = 'FC'
               AND ims_trde.service_type = 'FS'))?

Maybe you are looking for

  • ..this is annoying me

    Using XCode 2.4 I have the following code: int i; for(i = 0; i < SOMETHING; i++) That compiles just fine. I then shorten this to the more common: for(int i = 0; i < SOMETHING; i++) I get an error on that first line - something about C99. I went and c

  • Drag and drop in RSA1

    Hi all; I am trying to do the drag and drop in RSA1; and it's not working got error msg "Drag  Drop is switched off - switch on in RSADMIN/RSADMINSV"; I am not sure where is the setting for this? anyone pls thanks

  • I cannot download an EBL reader book

    The EBL ebook says it requires Adobe Digital Editions in order to download, but I have already downloaded and installed Adobe and tried everything I can with various online tips. How do I open this online book in Adobe? Whenever I try to download it,

  • MySQL autonumber feature

    I have a site that is using an access database. one feature is the product ID (PID) which is the autonumber created by access. ALl images taht are loaded for products are named with this PID. SO now i want to switch this to mySQL and i have the mySQL

  • My iphone does not respond after upgrading the operating system

    upgrade the operating system to 7.0.2 and iphone 5 will not start, can you help please