Equivalent to the Pivot command on Oracle 10g

Hi,
I have a requirement where i want change the below statement so it pivots on the day of the week
select periodid, entrydate, duration
from period
where period_id = xxxx
The above statement will return 7 records for each of the days of the week.
I want these 7 days to become columns.
Is there a way I can change this so is it
select period_id_monday, monday_duration, period_id_tuesday, tuesday_duration,
period_id_wednesday, wednesday_duration, period_id_thursdayday, thursday_duration,
period_id_friday, friday_duration
without having 7 separate sub queries.
Pivot command in SQL server is only for group functions from what I remember
Regards
Stephen

You could have googled or searched the forums! The method is
select max(decode(to_char(entrydate, 'fmDAY', 'nls_date_language=english'), 'MONDAY', periodid)) monday_perodid,
       max(decode(to_char(entrydate, 'fmDAY', 'nls_date_language=english'), 'MONDAY', duration)) monday_duration,
from   perod
where  period_id = xxxxleaving you to fill in the blanks...
Edited by: Boneist on 01-Jul-2009 12:01

Similar Messages

  • Does SAP offer an equivalent of the PREPARE  command in ORACLE

    Hi Experts,
    Does anyone knows the equivalent of PREPARE statement in SAP. I'm currently coding using Native SQL & the DB is ORACLE. Here is the code:
    SQLSTMT = 'SELECT PARTNER FROM BUT000'.
    EXEC SQL.
       PREPARE STATEMENT_NAME FROM :SQLSTMT
       DECLARE C1 SCROLL CURSOR FOR STATEMENT_NAME
       OPEN C1
       FETCH NEXT C1 INTO :GPARTNER
    ENDEXEC.
    How do I make this work in SAP?

    But once I had the problem to be "quite dynamic" in ABAP
    well it may be it's not that general: I want to select on a table.
    The tricky part was to what to fetch into ? At least I was dealing with one
    table so I could get the structure into a work area using dereferencing it.
    ABAP:
    data :
    dref type ref to data.
    FIELD-SYMBOLS: <wa> type any.
    don't know the table structure so I do it dynamically:
    CREATE DATA dref TYPE (TABLENAME).
    ASSIGN dref->* to <wa>.
    OPEN CURSOR curs FOR
              SELECT     (PART_COLUMNS)
                FROM     (TABLENAME)
                WHERE    (l_where)
                GROUP BY (PART_COLUMNS).
      DO.
              FETCH NEXT CURSOR curs into CORRESPONDING FIELDS OF <wa>.
    do whatever you need to do with <wa>
    ENDDO.

  • SYSTEM HANGS WHILE RUNNING EXP COMMAND IN ORACLE 10G

    WHEN WE ARE RUNNING THE EXP (EXPORT) COMMAND IN ORACLE 10G
    TO TAKE THE BACKUP IT GETS HANGED FOR A LONG TIME AND THEN IN THE LOG FILE WE FIND THE FOLLOWING ERROR MESSAGE.
    SOMETIMES AFTER RESTARTING THE SERVER WE ARE ABLE TO RUN THE EXP COMMAND.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    About to export specified users ...
    . exporting pre-schema procedural objects and actions
    . exporting foreign function library names for user MANHAR
    . exporting PUBLIC type synonyms
    . exporting private type synonyms
    . exporting object type definitions for user MANHAR
    About to export MANHAR's objects ...
    . exporting database links
    . exporting sequence numbers
    . exporting cluster definitions
    *********************************** AT THIS POINT THE SYSTEM HANGS FOR A LONG TIME.
    EXP-00056: ORACLE error 24324 encountered
    ORA-24324: service handle not initialized
    EXP-00056: ORACLE error 24324 encountered
    ORA-24324: service handle not initialized
    EXP-00000: Export terminated unsuccessfully
    THE EXP COMMAND THAT WE USE IS AS FOLLOWS:
    EXP MANHAR/MANHAR FILE=F:\BACKUP\MANHAR.DMP LOG=F:\BACKUP\MANHAR.LOG BUFFER=1000000 GRANTS=Y CONSTRAINTS=Y
    WE ARE RUNNING THE EXP COMMAND ON THE SERVER ITSELF.
    THE SERVER OPERATING SYSTEM IS WINDOWS 2003 SERVER.
    Kindly give us a solution at the earliest.

    You should ask Oracle support for help. There's only one entry for this error stack (Bug 3361288 - Export of XMLSCHEMA may fail with ORA-24324 in UTF8), but it should have been fixed for your DB version and , as far as I can see, you don't have a Unicode database.
    Werner

  • Errors in impdp command on oracle 10g database

    Hi,
    could you plz help me to solve below errors which are coming while doing import with impdp command in oracle 10g 10.1.0.4.0 os: Red Hat Enterprise Linux ES release 4
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Job "DCA"."SYS_IMPORT_SCHEMA_01" stopped due to fatal error at 15:31
    i tried to restart job but the following errors coming
    UDI-00008: operation generated ORACLE error 39078
    ORA-39078: unable to dequeue message for agent KUPC$A_1_20081111155728 from queue "KUPC$C_1_20081111155728"
    ORA-06512: at "SYS.DBMS_DATAPUMP", line 2356
    ORA-06512: at "SYS.DBMS_DATAPUMP", line 3261
    ORA-06512: at line 1
    thanks in advance

    NAME TYPE VALUE
    streams_pool_size big integer 0
    sga_target big integer 200M
    what could be the value for avoiding errors! thanks in advance

  • Errors in impdp command on oracle 10g database-urget help needed

    Hi,
    could you plz help me to solve below errors which are coming while doing import with impdp command in oracle 10g 10.1.0.4.0 os: Red Hat Enterprise Linux ES release 4
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Job "DCA"."SYS_IMPORT_SCHEMA_01" stopped due to fatal error at 15:31
    i tried to restart job but the following errors coming
    UDI-00008: operation generated ORACLE error 39078
    ORA-39078: unable to dequeue message for agent KUPC$A_1_20081111155728 from queue "KUPC$C_1_20081111155728"
    ORA-06512: at "SYS.DBMS_DATAPUMP", line 2356
    ORA-06512: at "SYS.DBMS_DATAPUMP", line 3261
    ORA-06512: at line 1
    thanks in advance

    Can you check Metalink Note 376022.1? Your STREAMS_POOL_SIZE parameter may be too small.
    If you don't have Metalink access, try this :
    sql> alter system set STREAMS_POOL_SIZE=100M scope=spfile;
    sql> shutdown immediate
    sql> startup
    Note : the Portal Applications forum may not be the appropriate forum for this datapump issue. Try one of the database forums as you'll have a wider audience there.

  • Can we rename the database name in oracle 10g

    Hi,
    Can we rename the database name in oracle 10g.
    Please help

    Yes as already said, using DBNEWID Utility can renamed the database name.
    You can also take a look at the Oracle Metalink Note:429674.1 (Which was written by me) - Subject: How We Used the Oracle DBNEWID Utility to Change the Database Name
    Regards,
    Sabdar Syed.

  • Can't Create the ODBC connection for Oracle 10g

    Hi,
         I am working with Oracle 10g Database Release 2 in windows XP professional. I am trying to create an ODBC connection for oracle but become failure because its generating the following errors:
    system error code 998
    could not locate the setup or translator library
    Please help me how can I solve this problem and create the ODBC connection for oracle 10g database.
    Best Regards,

    mwz wrote:
    I am trying to create an ODBC connection for oracle but become failure because its generating the following errors:
    system error code 998
    could not locate the setup or translator libraryThe symptom described is typical of an incorrect system env PATH setting (used by the data source admin tool), compared to that of the Oracle Home (specifically, path $OH/bin). The odbc driver config routine will search directories listed in PATH variable for necessary libraries (Client dll's). If some library fails to load (from e.g. oraoci*.dll or oraclient10.dll) it will probably error out, as in your case.
    Are you creating the odbc dsn on the databse server host or on some other machine? I.e. are you using the db host as a client or not?

  • Where can I download the ODBC driver for Oracle 10g XE?

    where can I download the ODBC driver for Oracle 10g XE?
    I need the ODBC drivers for windows 7 x64, I installed Oracle Database 10g Express Edition, the use and connects with RazorSQL well, I just want to make a connection THROUGH ConnectionString language using the ODBC driver

    already checked these http://www.connectionstrings.com/oracle, I need Help Please.

  • What are the new features of Oracle 10g over Oracle9i

    Hi Grus..
    i want to know what are the new features of oracle 10g over Oracle 9i as well oracle 11g over 10g.. can any one give me the detailed document.
    Because I'm struggling each and every time while the interviewer asked above question.
    It's very helpful for me if any one give me the detailed document regarding above question
    Thanks In Advance
    Arun
    Edited by: Arun on Oct 23, 2010 10:19 AM

    Hi,
    Just check below link..would be helpful..
    http://www.oracle.com/global/ap/openworld/ppt_download/database_manageability%2011g%20overview_230.pdf
    and
    Each release of Oracle has many differences, and Oracle 10g is a major re-write of the Oracle kernel from Oracle 9i. While there are several hundred new features and other differences between 9i and 10g, here are the major differences between Oracle9i and Oracle10g:
    Major changes to SQL optimizer internals
    Oracle Grid computing
    AWR and ASH tables incorporated into Oracle Performance Pack and Diagnostic Pack options
    Automated Session History (ASH) materializes the Oracle Wait Interface over time
    Data Pump replaces imp utility with impdp
    Automatic Database Diagnostic Monitor (ADDM)
    SQLTuning Advisor
    SQLAccess Advisor
    Rolling database upgrades (using Oracle10g RAC)
    dbms_scheduler package replaces dbms_job for scheduling
    and you need to refer oracle documentation for sql, plsql references where you will know particular enhancements made...
    thanks
    Prasanth
    Edited by: Onenessboy on Oct 23, 2010 10:22 AM

  • Give me the sql query which calculte the table size in oracle 10g ecc 6.0

    Hi expert,
    Please  give me the sql query which calculte the table size in oracle 10g ecc 6.0.
    Regards

    Orkun Gedik wrote:
    select segment_name, sum(bytes)/(1024*1024) from dba_segments where segment_name = '<TABLE_NAME>' group by segment_name;
    Hi,
    This delivers possibly wrong data in MCOD installations.
    Depending on Oracle Version and Patchlevel dba_segments does not always have the correct data,
    at any time esp. for indexes right after being rebuild parallel (Even in DB02 because it is using USER_SEGMENTS).
    Takes a day to get the data back in line (never found out, who did the correction at night, could be RSCOLL00 ?).
    Use above statement with "OWNER = " in WHERE for MCOD or connect as schema owner and use USER_SEGMENTS.
    Use with
    segment_name LIKE '<TABLE_NAME>%'
    if you like to see the related indexes as well.
    For partitioned objects, a join from dba_tables / dba_indexes to dba_tab_partitions/dba_ind_partitions to dba_segments
    might be needed, esp. for hash partitioned tables, depending on how they have been created ( partition names SYS_xxxx).
    Volker

  • Need to have more info about the latest patch on Oracle 10g Release 2

    Please this is the follwing answer that was given to explain the purpose of patching the latest release of Oracle 10g release 2.
    We are applying the patch to the 32bit environment to resolve memory errors.
    This patch should be applied to the 64bit environments too as to maintain consistency in our database versions
    Personaly I don't believe the response is accurate to patch the database.
    Does someone can tell me where to find more information about the latest path of Oracle 10g release 2?
    Thanks a lot

    You can find more information about a patchset by going over the readme document associated with the patch. As such, it is not exactly clear what kind of information you are looking for.
    Login into Metalink=>Patches&Updates=>Simple Search=>
    Product or Family=> RDBMS
    Select your OS
    if will your a link to the readme file...
    Hope this helps
    Thanks
    Chandra

  • How to filter the "delete" command in oracle streams ?

    How to filter the "delete" command in oracle streams ? (oracle 9i R2 )
    Message was edited by:
    user507013

    Hello
    write a procedure doing "nothing" for delete transcation :
    connect adminstrm/..
    CREATE OR REPACE PROCEDURE write_delete_lcr (
    message IN SYS.ANYDATA,
    error_stack_depth IN NUMBER,
    error_numbers IN DBMS_UTILITY.NUMBER_ARRAY,
    error_messages IN EMSG_ARRAY )
    AS
    s_id sys.anydata ;
    ad SYS.ANYDATA;
    lcr SYS.LCR$_ROW_RECORD;
    ret PLS_INTEGER;
    vc VARCHAR2(30);
    apply_name VARCHAR2(30) ;
    errlog_rec log_errors%ROWTYPE ;
    ov2 SYS.LCR$_ROW_LIST;
    BEGIN
    return;
    End;
    for your apply do :
    BEGIN
    DBMS_APPLY_ADM.SET_DML_HANDLER(
    object_name => TABLE_NAME,
    object_type => 'TABLE',
    operation_name => 'DELETE',
    error_handler => true,
    user_procedure => 'write_delete_lcr',
    apply_database_link => NULL);
    END;
    Hafedh KADDACHI
    Oracle DBA

  • What's the latest patch for oracle 10g client?

    what's the latest patch for oracle 10g client? 6810189?

    The same as the patch for the Oracle database of the same version and operating system. Since you didn't specify the operating system or the particular Oracle version (10g could mean 10.1 or 10.2), it's hard to be more specific.
    Justin

  • Stopping the Enterprise Manager Console (Oracle 10g on SuSE 9.1)

    I'm trying to stop the Enterprise Manager Console by issuing the command:
    ${ORACLE_HOME}/bin/emctl stop dbconsole
    Unfortunately, the command fails to stop the EM Console. Here's the output I get:
    TZ set to US/Pacific
    Oracle Enterprise Manager 10g Database Control Release 10.1.0.2.0
    Copyright (c) 1996, 2004 Oracle Corporation. All rights reserved.
    http://<hostname>:5505/em/console/aboutApplication
    Stopping Oracle Enterprise Manager 10g Database Control ...
    --- Failed to shutdown DBConsole Gracefully ---
    failed.
    The only way I can stop the EM Console (and related services--i.e., emagent) is to kill its process.
    Everything (Listener, DB Instance, EM Console) starts fine. I can stop the Listener and DB Instance without any problems. It's just the EM Console shutdown that doesn't happen cleanly.
    Has anyone else encountered the same condition? If so, what was the solution?
    Here's my operating environment:
    SuSE 9.1 (Kernel 2.6.5-7.108-default)
    Oracle 10g
    Thanks in advance for any help/insight.

    Has anyone else encountered the same condition? If so, what was the solution?Yes. Shutdown/reboot of the system made the error go away.
    Sorry, no better clues,
    Toni

  • Pivot function in Oracle 10g???

    Hello everybody,
    at the beginning of the week I had a simple problem (I thought that...), but now after trying and trying, I can't find a solution for it. First of all I'm working on Oracle 10g with the version 10.2.0.4.0. I can't change the version, it's standard in the whole company...
    At the beginning I have a table like the following one, but please note, that the compartment, the type and the amount are flexible and can change at any time:
    comp type amount
    a1 6280 10
    a2 6280 20
    a2 4810 15
    a2 1147 12
    a3 6280 33
    Now I want the table to look like this:
    a1 a2 a3
    1147 0 12 0
    4810 0 15 0
    6280 10 20 33
    A simple question in Excel for example, I just use the pivot function and have it fixed within 10seconds. But how can I do sth. like this in Oracle with simple SQL? Or it can be PL/SQL too, cause I will use this in an APEX application.
    Can you please give me a hint or a solution? But as stated before a1, a2, a3 are just examples it is possible that tomorrow a4, a5 and so on are coming. If it is necessary I can also create additional tables and views of course!
    Thanks for your help!
    Regards
    hoge

    Hi Hoge!
    Here is your solution:
    SELECT TYPE,
           sum(a1) AS a1,
           sum(a2) AS a2,
           sum(a3) AS a3
      FROM (SELECT TYPE,
                   decode(comp, 'a1', amount, 0) AS a1,
                   decode(comp, 'a2', amount, 0) AS a2,
                   decode(comp, 'a3', amount, 0) AS a3
              FROM test)
      GROUP BY TYPE
      ORDER BY TYPE; And here is my test case setup:
    CREATE TABLE test
        (comp VARCHAR2(255),
         TYPE NUMBER,
         amount NUMBER);
    INSERT INTO test(comp, TYPE, amount) VALUES('a1', 6280, 10);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 6280, 20);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 4810, 15);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 1147, 12);
    INSERT INTO test(comp, TYPE, amount) VALUES('a3', 6280, 33);
    commit;Best regards,
    Matt

Maybe you are looking for

  • Is BI Publisher 11g compatible with CC&B 2.3.1

    Dear All, Is BI Publisher 11g compatible with CC&B 2.3.1. In the Oracle support and forums, its mentioned that the BI Publisher 10g can be integrated with CC&B 2.3.1 and the sample reports provided with the application can be used for online bill dis

  • DMS - view authorization control

    when users have view authorization in DMS, can i control print and save / "save as" options. Do not want users to print the originals or save the originals.

  • 5800 Charging problem?

    Hi everyone, I recieved my 5800 on Tuesday, I charged it up fine then, but the next day it needed charging again and the phone wouldn't recognise I had put the charger in... I left it and phoned the company I got it from and they have sent a new char

  • AGP and PCI interact?

    is it likely that AGP slots and PCI slots interact in some way? I had my monitor acting strangely depending on which PCI slots were placed PCI cards...

  • Suche ein Alternative App zum Galaxy Tab Note 10.1

    Suche ein guten App der mit der Galaxy Tab, Note 10.1 vergleichbar ist. Wer kann helfen?