Pivot and Unpivot in Oracle 10g

Hi,
This is my table structure
CREATE TABLE TESTTABLE
REVENUE1 NUMBER,
REVENUE2 NUMBER,
REVENUE3 NUMBER,
YEAR DATE
insert into testtable(revenue1, revenue2, revenue3, year) values(100,200,300,'1-Jan-2009') ;
insert into testtable(revenue1, revenue2, revenue3, year) values(250,350,450,'1-Jan-2010') ;
insert into testtable(revenue1, revenue2, revenue3, year) values(300,400,500,'1-Jan-2011') ;
The resultant should be on oracle 10g.
The result should be like
1-Jan-2009 1-Jan-2010 1-Jan-2011
Revenue1 100 250 300
Revenue2 200 350 400
Revenue3 300 450 500
Thanks in advance

Hi,
Naveen wrote:
...Thanks for the reply but this will not make the year as the column header it will be shown as a row in the result set.That's exactly what I thought you wanted, based on your first message:
Naveen wrote:
The result should be like
1-Jan-2009 1-Jan-2010 1-Jan-2011
Revenue1 100 250 300
Revenue2 200 350 400
Revenue3 300 450 500It would have been clearer if you had said: "The result set should be like these 3 rows:
{code}
Label 1-Jan-2009 1-Jan-2010 1-Jan-2011
Revenue1 100 250 300
Revenue2 200 350 400
Revenue3 300 450 500
{code}
When posting formatted text (such as results) on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
Column names are hard-coded into the query.  To get variable data, such as '1-Jan-2009' as a column header, you must use dynamic SQL.  This is probably best done in your front-end.  SQL*Plus, for example, has substitution variables, that you can define with data from your table at run-time using the COLUMN ... NEW_VALUE command.  (SQL*Plus also has a COLUMN ... HEADING command that can do what you want, , but it doesn't simplify this particular problem.)
What front-end tool are you using?  Can you use SQL*Plus?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • How to integrate from MS SQL SERVER 2005 and Flatfile to Oracle 10g.

    Hi
    I am new to ODI. I am trying to load sample data from MS SQL Server 2005 and Flatfile to Oracle 10g.
    1. I have created three models.
    1-1. SQL2005 (SRC_CUSTOMER table)
    1-2. Flatfile (SRC_AGE_GROUP.txt & SRC_SALES_PERSON.txt)
    1-3. Oracle 10g (TRG_CUSTOMER table)
    You may know I got those environments from the ODI DEMO environment.
    2. I could able to reverse the tables also.
    3. I have created an interface which contains source table (from MSSQL 2005), Flatfile and target table from ORACLE model.
    4. I have imported the knowledge modules. But I am confusing in selecting the knowledge modules to source and target tables.
    I've selected LKM File to SQL for flatfile model.
    I've also selected LKM SQL to SQL for MSSQL 2005 model and IKM Oracle Incremental Update for the target table (ORACLE).
    I've also implemented the interface that I created. It worked without errors. But there is no data in target table which is TRG_CUSTOMER.
    I really would like to know what happened and what the problems are.
    You can email me [email protected]
    Thanks in advance
    Jason Lee

    what did give for SRC_AGE_GROUP SRC_CUSTOMER join condition
    if it is
    (SRC_CUSTOMER.AGE=SRC_AGE_GROUP.AGE_MIN) AND SRC_CUSTOMER.AGE=SRC_AGE_GROUP.AGE_MAX
    give it as
    (SRC_CUSTOMER.AGE>SRC_AGE_GROUP.AGE_MIN) AND SRC_CUSTOMER.AGE<SRC_AGE_GROUP.AGE_MAX

  • How to store photo images and thumbimpressions in oracle 10g database

    Hi all
    I have an web application running in Oracle 10g rel 1 database server in RHEL3. It has application server with forms and j2ee component as middle tier. I need to store centrally photo images and thumb impressions and use it in our application without any overhead on retrieval and performance of web application. what will be optimized method of storage of photo and thumb impressions. Awaiting your valuable suggestions.
    Regards
    Vijay Kumar

    Hi Vijay,
    How to store photo images and thumbimpressions in oracle 10g database I have working code here for storing photos in Oracle tables that you may find useful:
    http://www.dba-oracle.com/t_storing_insert_photo_pictures_tables.htm
    Hope this helps . . .
    Donald K. Burleson
    Oracle Press author
    Author of "Oracle Tuning: The Definitive Reference"
    http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm

  • Evaluated order of Pivot and UnPivot in select statement

    My research which evaluated order of select statement is below.
    1 from
    2 where (Join condition)
    3 start with
    4 connect by
    5 where (filter of rows)
    6 group by
    7 having
    8 model
    9 select
    10 order byMy question is Where Pivot clause and UnPivot clause ?
    http://download.oracle.com/docs/cd/E16338_01/server.112/e10592/statements_10002.htm

    Provided that you can specify columns created by the PIVOT clause both in the select and in the Order By clause, I think the pivot must be executed before them:
    SQL> r
      1  select job, d10,d20,d30 from emp
      2  pivot (sum(sal) for deptno in (10 as D10, 20 as d20, 30 as d30))
      3* order by d20
    JOB              D10        D20        D30
    CLERK                       800
    CLERK                      1100
    MANAGER                    2975
    ANALYST                    3000
    ANALYST                    3000
    SALESMAN                              1600
    PRESIDENT       5000
    MANAGER         2450
    SALESMAN                              1500
    SALESMAN                              1250
    CLERK           1300
    MANAGER                               2850
    SALESMAN                              1250
    CLERK                                  950
    Selezionate 14 righe.
    Piano di esecuzione
    Plan hash value: 1739977809
    | Id  | Operation            | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |      |    14 |   518 |     5  (40)| 00:00:01 |
    |   1 |  SORT ORDER BY       |      |    14 |   518 |     5  (40)| 00:00:01 |
    |   2 |   HASH GROUP BY PIVOT|      |    14 |   518 |     5  (40)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL | EMP  |    14 |   518 |     3   (0)| 00:00:01 |
    -----------------------------------------------------------------------------Max

  • Backing Up Database Table and Records in Oracle 10g

    Hi All,
    I created database for my company with Oracle 10g Database Server and want to backup all my database tables and records within (i.e creating another username inside the data and transfer them) and outside (i.e transfering them in another destination outside the database server) the database. Could you please instruct me on how to achieve?
    I look forward to hearing from you all.
    Thank you.
    Jc

    Hi, use RMAN utility
    do this
    rman target sys/*** nocatalog
    run {
      allocate channel t type disk;
      backup
        format '/app/oracle/backup/%d_t%t_s%s_p%p'
          (database);
       release channel t;
    {code
    Also read backup and recovery guide at http://download.oracle.com/docs/cd/B19306_01/backup.102/b14192/toc.htm
    regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to archive and Purge in Oracle 10g based on data

    Hi,
    Our requirement is that based on some rules stored in static tables we want to perform Archiving, purging and compression of data in Oracle 10g.
    Can anyone guide me to proper information material for how to go about this?
    Thanks!
    Avinash.

    Hi,
    Thanks for the information.
    But this traditional way of doing is archiving is for maintenance and backup operations.
    We want to have this process online, without taking db offline. In this case will this approach work?
    In our case, the rules can be like -
    1. For table 'A', if rows exceed 10Million, then start archiving of the data for that table.
    2. For table 'B', if data is older than 6 motnhs start archiving of the data for that table.
    3. Archiving should be on for 15 minutes only after that should pause, and should resume whenever user wants to resume.
    4. Archiving should start on specified days only... ETC...

  • Where do i see all the default tables and views in oracle 10g

    hi,
    I have installed oracle 10g in the linux os.
    I just wanna see the list of deffault tables and views created by oracle.
    can anyoone hlep me on this
    thanx in advance....

    Check DBA_OBJECTS for all seeded objects in an Oracle database. For tables, check DBA_TABLES. For views, check DBA_VIEWS. All of this is documented in the fine documentation - take some time out to read thru it.
    http://docs.oracle.com/cd/E11882_01/server.112/e25513/statviews_4156.htm#REFRN23146
    http://docs.oracle.com/cd/E11882_01/server.112/e25513/statviews_5056.htm#sthref2482
    http://docs.oracle.com/cd/E11882_01/server.112/e25513/statviews_5085.htm#sthref2521
    HTH
    Srini

  • Backing up all data and objects of Oracle 10g Express Edition...

    Hi,
    I have tables, packages, views, procedures, etc. in Oracle 10g Express Edition, running on Windows XP. I would like to create a backup of the complete database (objects, relationships, all data, etc) into a file that I can restore in case the database crashes.
    What do I do?
    Thanks.

    markk2 wrote:
    I am actually using it for Production. Yes, I would need objects and data.I would suggest to look at the Standard Edition as well if you are using it for production.
    Is there a way to backup everything without data and then backup everything with data? Also, is there a way to restore everything without data and then restore everything with data?What's the meaning of "backup everything withiut data" and "then backup everything with data" ? The data is in the tables alone. The rest of the objects are not containing data but are using it, be it views, procedures etc. There is no such restore like without data. Without data, all what you would be getting would be structures of the tables which is going to be of no use. The export/import tool, is a simple tool which can put the tables (and other objects as well) along with their data in your dumpfile . In the situation of loss of a table, you can do an import from that dump file and you can restore the table back(with or without data, depends on the choice of yours while running Import command) . But this is just going to be a logical recovery of the object(s). For a complete database, it's better to use RMAN which would copy the datafiles and keep it with itself. Later, when you have a crash, you can restore those files to get teh database recovered. But if you want complete security, its better to put your db in the archive log and then do the backup along with the archive log files.
    HTH
    Aman....
    How to do this exactly? Thanks!

  • Data replication and synchronization in Oracle 10g XE.

    We are trying to do data replication and synchronization sort of thing for all our servers. We are using Oracle 10g. XE. I guess there are some features in oracle already for replication but I am not very sure about them.
    To explain it more clearly - we will have individual database servers in our sub-divisions and then divisions and centers and then main server. We need to synchronize at various levels. So If any body is aware of any techniques, please let me know.

    Hi,
    Could you tell me what exactly synchronisation your talking about..?
    we will have individual database servers in our sub-divisions and then divisions >>and centers and then main serverIf you have mulitple DB servers then you can connect it by DB links. also if you are talking DB synchronisation then you can have Triggers,Materialized views.
    we also have two independent severs which are synchronised(atleast schema levels).
    Regards!

  • Trigger-Body isnt remaped during IMPDP and REMAP_SCHEMA in Oracle 10g

    Hello,
    we are facing the following problem:
    During an IMPDP we are remaping the schema. The schema includes triggers. The trigger bodys are of normal syntax without a relation to the schema/user.
    If we start the import with datapump using the remap_schema option the triggers are remap to the new schema. But the trigger bodys point to the old schema.
    For example:
    CREATE OR REPLACE TRIGGER "OLD_SCHEMA".NAME_OF_TRIGGER
    BEFORE INSERT ON "OLD_SCHEMA"."TABLE_NAME" REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN
    END;
    After using the REMAP_SCHEMA option:
    CREATE OR REPLACE TRIGGER "NEW_SCHEMA".NAME_OF_TRIGGER
    BEFORE INSERT ON "OLD_SCHEMA"."TABLE_NAME" REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN
    END;
    So the Trigger Body in the NEW_SCHEMA uses a link to the OLD_SCHEMA and the trigger doesn't work. We wrote the trigger without referencing to a schema. So the OLD_SCHEMA resp. NEW_SCHEMA syntax must be added by datapump.
    The question: Is there a way to remap the triggers correctly in the new schema or is this behavior "normal" to Oracle 10g Datapump?
    We are using Oracle 10g Database 10.2.0.4 with the latest Patches on Windows Server 2003 SP2.
    Thank you for you attention.

    Hello,
    I had the same problem and you can't fix it by changing a parameter of impdp. You really need to change the source of those triggers so they don't use hard-code schema references.
    Solution would be to change the source code of those triggers. Or to use the "script" parameter of impdp and recreate the triggers yourself after the impdp has finished.
    For more info check Metalink note: 750783.1
    I hope this helps.
    Regards,
    Michiel.

  • User name and password for oracle 10g

    Hi Guys,
    I downloaded oracle 10g and installed on my computer but when i try to work on SQL plus it's asking for an username and password, i tryed as scott/tiger,system/manager but unable to login please help me what to do...??

    When u install Oracle 10g, it forces u to enter new passwords for System as well as scott user and it does not allow u to keep old know passwords as manager and tiger.
    If u installed with new passwords successfully, u must be knowing those new passwords and there is no reason to try with system/manager. Instead try to connect with new passwords. We never faced such problems.
    If the problems still persits, check that
    a) Oracle service is running
    b) Instance is running by and whether u are able to connect / as sysdba
    Suresh Bansal

  • Pros and Cons af Oracle 10g upgrade to 11g

    Hi Basis Expert,
    We have an requirement of SAP upgrade which includes BW 3.5, CRM and R/3 (4.7).
    These components needs to be upgraded to the latest version
    BW 3.5 to BI 7.0
    R/3 (4.7) to ECC 6.0
    and also CRM upgrade to the new version
    The OS used is AIX and DB used is oracle 10g.
    Can anybody share the pros and cons of oracle DB upgrade from 10g to 11g after SAP upgrade.
    Regards,
    Anil.

    Hi DatabaseSAP and others,
    Thanks for your reply
    I started with the Oracle 11g software installer. But it gave an error during 71%. Error is
    Error in invoking target 'rat_on part_on dm_on olap_on sdo_on' of makefile '/oracle/DBW/112_64/rdbms/lib/ins_rdbms.mk'.
    See '/oracle/DBW/oraInventory/logs/installActions2011-10-10_12-04-03PM.log' for details.
    Abort      Retry         Continue
    But when i was going thorough the installActions2011-10-10_12-04-03PM.log . I could find that there are 7 arguments which is failed.
    Below are the argument  details
    1)INFO: Hard Limit: maximum user processes: This is a prerequisite condition to test whether the hard limit for "maximum user processes" is set to at least 16384.
    INFO: Severity:IGNORABLE
    INFO: OverallStatus:VERIFICATION_FAILED
    INFO: -
    Verification Result for Node:p19849dev136
    INFO: Expected Value:1024
    INFO: Actual Value:9223372036854775807
    INFO: -
    INFO: *********************************************
    INFO: Hard Limit: maximum user processes: This is a prerequisite condition to test whether the hard limit for "maximum user processes" is set to at least 16384.
    INFO: Severity:IGNORABLE
    INFO: OverallStatus:VERIFICATION_FAILED
    INFO: -
    INFO: Verification Result for Node:p19849dev136
    INFO: Expected Value:16384
    INFO: Actual Value:3048
    INFO: Error Message:PRVF-4354 : Proper hard limit for resource "maximum user processes" not found on node "p19849dev136" [Expected = "16384" ; Found = "3048"]
    INFO: Cause: Hard limit for the resource does not meet the requirement on the specified node.
    INFO: Action: Modify the resource limits to meet the requirement.
    2)INFO: OS Kernel Parameter: ncargs: This is a prerequisite condition to test whether the OS kernel parameter "ncargs" is properly set.
    INFO: Severity:IGNORABLE
    INFO: OverallStatus:VERIFICATION_FAILED
    INFO: -
    INFO: Verification Result for Node:p19849dev136
    INFO: Expected Value:128
    INFO: Actual Value:6
    INFO: Error Message:PRVF-7543 : OS Kernel parameter "ncargs" does not have proper value on node "p19849dev136" [Expected = "128" ; Found = "6"].
    INFO: Cause: Kernel parameter value does not meet the requirement.
    INFO: Action: Modify the kernel parameter value to meet the requirement.
    3)INFO: OS Kernel Parameter: tcp_ephemeral_low: This is a prerequisite condition to test whether the OS kernel parameter "tcp_ephemeral_low" is properly set.
    INFO: Severity:IGNORABLE
    INFO: OverallStatus:VERIFICATION_FAILED
    INFO: -
    INFO: Verification Result for Node:p19849dev136
    INFO: Expected Value:9000
    INFO: Actual Value:32768
    INFO: Error Message:PRVF-7543 : OS Kernel parameter "tcp_ephemeral_low" does not have proper value on node "p19849dev136" [Expected = "9000" ; Found = "32768"].
    INFO: Cause: Kernel parameter value does not meet the requirement.
    INFO: Action: Modify the kernel parameter value to meet the requirement.
    4)INFO: OS Kernel Parameter: tcp_ephemeral_high: This is a prerequisite condition to test whether the OS kernel parameter "tcp_ephemeral_high" is properly set.
    INFO: Severity:IGNORABLE
    INFO: OverallStatus:VERIFICATION_FAILED
    INFO: -
    INFO: Verification Result for Node:p19849dev136
    INFO: Expected Value:65500
    INFO: Actual Value:65535
    INFO: Error Message:PRVF-7543 : OS Kernel parameter "tcp_ephemeral_high" does not have proper value on node "p19849dev136" [Expected = "65500" ; Found = "65535"].
    INFO: Cause: Kernel parameter value does not meet the requirement.
    INFO: Action: Modify the kernel parameter value to meet the requirement.
    5)INFO: OS Kernel Parameter: udp_ephemeral_low: This is a prerequisite condition to test whether the OS kernel parameter "udp_ephemeral_low" is properly set.
    INFO: Severity:IGNORABLE
    INFO: OverallStatus:VERIFICATION_FAILED
    INFO: -
    INFO: Verification Result for Node:p19849dev136
    INFO: Expected Value:9000
    INFO: Actual Value:32768
    INFO: Error Message:PRVF-7543 : OS Kernel parameter "udp_ephemeral_low" does not have proper value on node "p19849dev136" [Expected = "9000" ; Found = "32768"].
    INFO: Cause: Kernel parameter value does not meet the requirement.
    INFO: Action: Modify the kernel parameter value to meet the requirement.
    INFO: -
    6)INFO: OS Kernel Parameter: udp_ephemeral_high: This is a prerequisite condition to test whether the OS kernel parameter "udp_ephemeral_high" is properly set.
    INFO: Severity:IGNORABLE
    INFO: OverallStatus:VERIFICATION_FAILED
    INFO: -
    INFO: Verification Result for Node:p19849dev136
    INFO: Expected Value:65500
    INFO: Actual Value:65535
    INFO: Error Message:PRVF-7543 : OS Kernel parameter "udp_ephemeral_high" does not have proper value on node "p19849dev136" [Expected = "65500" ; Found = "65535"].
    INFO: Cause: Kernel parameter value does not meet the requirement.
    INFO: Action: Modify the kernel parameter value to meet the requirement.
    7)INFO: Users With Same UID: This test checks that multiple users do not exist with user id as "0".
    INFO: Severity:CRITICAL
    INFO: OverallStatus:VERIFICATION_FAILED
    INFO: -
    INFO: Verification Result for Node:p19849dev136
    WARNING: Result values are not available for this verification task
    INFO: Error Message:<CV_VAL>root,|super,|zero,|</CV_VAL><CV_ERES>0</CV_ERES>
    INFO: Cause:Cause Of Problem Not Available
    INFO: Action:User Action Not Available
    INFO: *********************************************
    Please let me know what is the 7th (last one) argument.
    Regards,
    Anil Shenoy

  • How to do automatic start and shut  of Oracle 10g and listerner  on AIX 6

    Hi ,Please help ,how do we do automatic startup and shutdown of Oracle Database and Listener at System Reboot ,I am using Oracle 10G and operating system is AIX 6,Thanks

    Hi,
    Check this
    http://download.oracle.com/docs/cd/B19306_01/server.102/b15658/strt_stp.htm#BGBJBAEI
    for more ref
    http://www.oracle-base.com/articles/linux/AutomatingDatabaseStartupAndShutdownOnLinux.php
    Edited by: CKPT on Jan 7, 2011 1:11 PM

  • Default username and password for Oracle 10g

    I have installed Oracle 10g Standard edition on my PC, but do not know the username and password to login. Does anyone know the username and password?
    Thanks,
    YR

    Hello,
    Did you create database using dbca after installation or you choose to created during install?
    If you did you can create scott schema using this
    sql> @\Oracle\product\10.2.0\...\RDBMS\ADMIN\scott.sql
    You can login as sysdba and see if scott user created for you, offcourse if you have created database using DBCA or during isntall in first place.
    sqlplus "/as sysdba"
    Sql> select username , status from dba_users where username='SCOTT';
    I strongly recommend you to create new database using DBCA and it will let you walk thru all the steps.
    Regards
    Edited by: OrionNet on Mar 2, 2009 11:50 AM
    Edited by: OrionNet on Mar 2, 2009 11:52 AM

  • DELL BLADE Server and Windows 2003 Oracle 10g RAC

    Anyone out there sucessfully set up a Windows 2003 Oracle 10g RAC using DELL BLADE Servers and VMWARE configuration?

    dear guys
    i have 3 database instances running on primary databases.means 3 different sid.now i want to create DR for same.is it possible.how can i do it.its like 3 versions production,trial and development database running on primary under same home.i want to make dr(standby) .so do i follow same proedure for all.
    taking backups of all three.creaating pfile for all and then to start recovery for all three.is it possibleYes, It's called RAC but It need to be licensed.
    You have a lot of manuals online so check by yourself how to install and configure.

Maybe you are looking for

  • No sound, explorer.exe not starting, no event viewer

    I set up a new PC recently and installed Windows 7 Pro. Approximately once every few days I get a problem which, oddly, has several seemingly different manifestations. I mean that if I see one of these, all the others can be observed as well, until I

  • [noob needs help] Loading image from a URL

    Hey everyone. I'm new here. And I'm new at J2ME as well. I have a simple school project and I have doubts about it. I've searched everywhere on the net yet I could not find the solution. Anyways, I do understand the concept of loading images by putti

  • Software distribution and Unlimited Strength Jurisdiction Policy Files

    I suppose, I'm NOT allowed to ship the Unlimited Strength Jurisdiction Policy Files (USJPF) with my application, even if living in Germany and not selling abroad, right? So I see 2 possibilities: - Use weaker encryption by default and encourage the u

  • Noob help to format date to insert into mysql

    Sorry, if this question has been asked before, I did di a search but could not find an answer that I could understand.  I am pretty new to DW and my coding skills are not good so please go easy on me. I have a simple form to insert records to a mysql

  • Quick question about bug reports

    Hi all, I was just reading the reporting bug guidelines (https://wiki.archlinux.org/index.php/Re - Guidelines) and was wondering about the section "Upstream or Arch?". I'm not an expert on the particular package I want to file a bug against, so I hav