Pivot in 11g producing a keyword error

Hello everyone. :) I am a freshman in SQL and just to get to the track of a blazing function pivot for the section of society, I work in. (it goes without saying, a response of Sesame Street style is not offensive.) We are literally moving to 11 g (11.2.0.1.0). Unfortunately, none of our more experienced programmers now anything on the pivot function. It's not really surprising to me since we worked in 10g. In any case, I use the SQL Developer 3.0.04 version which I know is not the newest, but I do not yet have permission to upgrade. I used http://www.oracle-developer.net/display.php?id=506# to me as much as I am about this feature. Please , could someone help me see what Miss me?

The script that I have problems with is:

SELECT *.
Of
(SELECT
begin_month,
begin_yr,
uut_part_num,
uut_part_description
Of
Cris.serial_num_rpt_view
PIVOT (SUM (wonum) AS WO_Count
FOR begin_yr AS year, begin_month IN
(AS of January 01,
02. IN February,.
03 MARCH
04 IN April,
05 MAY,
06 in June,
07. IN July,.
August 08,
September 09,
10 IN October,
In November, 11
(12 DECEMBER))
WHERE
date_reported > = to_timestamp (: v_bDate, ' MM/DD/YYYY')
AND date_reported < = to_timestamp (: v_eDate, ' MM/DD/YYYY')
AND Association = 'HORN')
The site WHERE AS SUPERIOR (BOX WHEN: v_SITE IS NULL THEN '%' ELSE: v_SITE END)
AND TFA as SUPERIOR (BOX WHEN: v_TFA IS NULL THEN '%' ELSE: v_TFA END)
AND SUBTFA as SUPERIOR (BOX WHEN: v_SUBTFA IS NULL THEN '%' ELSE: v_SUBTFA END)
AND UUT_Part_Number as SUPERIOR (BOX WHEN: v_Part_Number IS NULL THEN '%' ELSE: v_Part_Number END)
AND UUT_Serial_No as SUPERIOR (BOX WHEN: v_Serial_No IS NULL THEN '%' ELSE: v_Serial_No END)
-The next line is for counting WO, given that the WOs repeat the case when count only the last instance of a series of repetitions WO numbers
(CASE WHEN lead (WOs.WONUM, 1, 0) (WOs.wonum order) = WOs.WONUM THEN 0 1 OTHER END);

The error I get is:

ORA-01738: lack of KEYWORD
01738 00000 - "missing IN the keyword"
* Cause:
* Action:
Error on line: 16: 2 column

An indication of error bounces between lines 15 and 16. If I put IN at the end of the 15 I so a missing closing parenthesis error...

Thank you in advance.

Pivot operator converts an aggregate table row in a column. The values of distinct line become columns in the output and aggregate column value is placed under the appropriate column Swivel.

The syntax of the Pivot operator is as below:

-- SELECT ..
     FROM table PIVOT (aggregateFunction [, aggregateFunction] FOR column IN (expression [, expression]))
--  WHERE ..

Limitation of the PIVOT operator is, it supports only pivoting on a single column.

You cannot use this:

FOR begin_yr year, AS begin_month IN

See the tutorial several PIVOT columns:
http://mangalpardeshi.blogspot.cz/2009/06/Pivot-multiple-columns.html

and the PIVOT tutorial:
http://www.Oracle-base.com/articles/11g/pivot-and-UNPIVOT-operators-11gr1.php

Tags: Database

Similar Questions

  • Unused missing keyword error

    Hi all, when I try to update some columns that don't have the data I receive ORA-02000: lack of UNUSED keyword error. Can someone explain to me how to overcome this error?
      1  alter table  regal.regal_cust_allowance_det_tab
      2  set percentage = 0.2,
      3      range_type = 'Goods',
      4      range_from = 1000,
      5      range_to   = 5000
      6* where CUSTOMER_NUMBER = 1020
      7  /
    set percentage = 0.2,
        *
    ERROR at line 2:
    ORA-02000: missing UNUSED keyword
    Any help is appreciated,
    Thanks in advance!

    Hello

    Need the UPDATE statement. How is it, you update the values of the columns using ALTER table statemennt? Serious error

  • 1071: syntax error: produce a keyword (for example the function) after attribute _ definition, not root.

    I followed a tutorial on YouTube about creating a leader board for a game.

    After you set:

    Stop();

    _ root.pos = SharedObject.getLocal ("scoresTut");

    root.pos.data.player1 = _ root.player1.text _;

    root.pos.data.player2 = _ root.player2.text _;

    root.pos.data.player3 = _ root.player3.text _;

    root.pos.data.player4 = _ root.player4.text _;

    root.pos.data.player5 = _ root.player5.text _;

    root.pos.data.player6 = _ root.player6.text _;

    root.pos.data.player1Score = _ root.player1.Score _;

    root.pos.data.player2Score = _ root.player2.Score _;

    root.pos.data.player3Score = _ root.player3.Score _;

    root.pos.data.player4Score = _ root.player4.Score _;

    root.pos.data.player5Score = _ root.player5.Score _;

    root.pos.data.player6Score = _ root.player6.Score _;

    It came with the Syntaxt error above.

    Can anyone help please?

    When you write this program in AS3 shoud you do not use _root. Instead of _root, you can use MovieClip (root).

  • "missing the SELECT keyword" error during an insert into the temporary table using the blob value

    I'm trying to insert into an oracle temp table using select that retrieves data from a blob field but I get the error: "lack the SELECT keyword.

    How we store temporary in oracle result when we make this type of operation (extraction of data in fields and try to load them into a separate table on the fly.?)

    with cte as)

    Select user_id, utl_raw.cast_to_varchar2 (dbms_lob.substr (PREFERENCES)) as USER my_blob

    )

    create table new_table as

    SELECT user_id,EXTRACTvalue(xmltype(e.my_blob),'/preferences/locale') regional settings

    E ETC

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

    BLOB data - value - which is

    <? XML version = "1.0" encoding = "ISO-8859-1" ?>

    - < Preferences >

    < time zone > America/New_York < / > zone

    < displayscheduleinusertimezone > Y < / displayscheduleinusertimezone >

    < local > Spanish < /locale >

    < DateFormat > JJ/mm/aaaa < / DateFormat >

    < timeFormat > hh: mm aaa < / timeFormat >

    < longformat > Long_01 < / longformat >

    < doubleformat > Double_01 < / doubleformat >

    < percentformat > Percentage_01 < / percentformat >

    < currencyformat > Currency_01 < / currencyformat >

    < / Preferences >

    A WITH clause that must immediately precede the SELECT keyword:

    SQL > create table t:

    2 with the o as (select double dummy)

    3 select * West longitude;

    Table created.

  • 11g R2 database Setup error

    during the installation of database 11 g R2, I get the following error
    file not found
    oc4j_applications\applications\em\em. War

    Please suggest

    Make sure you download and unzip the two files in the same directory.

    The way is to install 11 g without any error is

    extract the two Zip files anywhere-
    win64_11gR2_database_1of2.zip
    and win64_11gR2_database_2of2

    Then, copy all the content of the components of the second zip file folder... win64_11gR2_database_2of2\database\stage\Components\

    and paste it into the first folder of Zip files
    win64_11gR2_database_1of2\database\stage\Components\

    He will be working well
    and won't give any error.
    now
    simple to run the installer...

    Refer
    installing Oracle database 11g rel 2

    This should fix your error.

  • Update SQL with Pivot on 11g

    Smart brains, need help to make SQL -.

    This is the simple requirement-

    Table X
    COLUMN A. COLUMN B
    ====================
    NEW YORK CITY
    ETIENNE OF THE CITY
    CITY HKG
    CITY OF PSC
    CITY MOM
    FRA CITY

    Table Y
    COL ATT1 | COL ATT2 | COL ATT3 | COL ATT4 | COL ATT4 | COL ATT5 | COL ATT6 | COL ATT7 | COL ATT8 | COL ATT9 | COL ATT10
    =======================================================================================

    There are N lines in table X, and values are not known
    There are always > table Y N columns and are fixed named

    I'm looking for a clever way (database 11g) to formulate an SQL UPDATE to update the table Y with column B of table X - see the output below.
    I tried the traditional pivots in pL - SQL, but is not a satisfactory until it.interesting thing here is the number of
    lines in the table as x varies.

    Table Y

    COL ATT1 | COL ATT2 | COL ATT3 | COL ATT4 | COL ATT4 | COL ATT5 | COL ATT6 | COL ATT7 | COL ATT8 | COL ATT9 | COL ATT10
    ======================================================================================
    NYC HNY HGK GSP MOM FRA

    Thank you
    Bobin

    Hi, Blanco,

    Blanchy... wrote:
    ... There are N lines in table X, and values are not known

    You can use the ROW_NUMBER analytic function to assign known values for use in the query.

    There are always > N columns in the table Y and are fixed named

    I'm looking for a clever way (database 11g) to formulate an SQL UPDATE to update the table Y with column B of table X - see the output below.
    I tried the traditional pivots in pL - SQL, but is not a satisfactory until it.interesting thing here is the number of
    lines in the table as x varies.

    What have you tried?
    What was unsatisfactory on these methods?
    How can we avoid the things you don't like about them if you give some tips on what they were?

    Here is an example using the Oracle 11 PIVOT function:

    WITH     got_r_num     AS
    (
         SELECT     column_b
         ,     ROW_NUMBER () OVER (ORDER BY  column_b)     AS r_num
         FROM     table_x
    --     WHERE     ...
    )
    SELECT     *
    FROM     got_r_num
    PIVOT     (     MIN (column_b)
         FOR     r_num
         IN     (     1     AS att1
              ,     2     AS att2
              ,     3     AS att3
    --          ,     ...
              )
         )
    ;
    

    It should be easy to write an INSERT statement by using it.

  • Procedure with recursive query in 11g to compile with error in 10g

    Hi all

    I have a procedure recursively selects tree table (with ID-ParentID relationship). Question itself works perfectly and exactly as I need 11g and procedure containing it compiles well. But when I try to create the same procedure in 10g then I get a message this procedure compiled with the error. I have no other suspicions but the part inside.

    The exact query is here (destination_tariff_zones is the tree table which refers to himself by parent_destination_tariff_zone_id):

    + dtzl_cur open FOR
    with dtree (nm, iid, chess, wldcard, dtzindex)
    as (select dtz.iname, dtz.iid, 0, dtz.wildcard, rcdi.iindex)
    of dtz, ISR., rcd rating_cube_dimensions rating_cube_dimension_indices destination_tariff_zones
    where dtz.parent_tariff_zone_id is null and
    DTZ. "' rc_dimension_index_id ' = rcdi.iid and
    ISR.. "' rc_dimension_id ' = rcd.iid and
    RCD.rating_cube_id = rc_id and
    RCD.dimension_type_id = dim_type
    Union of all the
    Select dtz.iname, dtz.iid, dtree.alevel + 1,
    Cast ((dtree.wldcard || dtz.wildcard) as varchar2 (20)), rcdi.iindex
    from dtree, dtz, ISR., rcd rating_cube_dimensions rating_cube_dimension_indices destination_tariff_zones
    where dtree.iid = dtz.parent_tariff_zone_id and
    DTZ. "' rc_dimension_index_id ' = rcdi.iid and
    ISR.. "' rc_dimension_id ' = rcd.iid and
    RCD.rating_cube_id = rc_id and
    RCD.dimension_type_id = dim_type)
    Select iid, nm, wldcard and dtzindex
    from dtree
    order of wldcard; +

    Is there a difference between how to manage 11g and 10g WITH instructions?
    Please notify.

    Thank you very much in advance,
    Max

    Hello
    maybe try something like:

    with dtree as
    (select dtz.iname, dtz.iid, 0, dtz.wildcard, rcdi.iindex,dtz.parent_tariff_zone_id
    from destination_tariff_zones dtz, rating_cube_dimension_indices rcdi, rating_cube_dimensions rcd
    where dtz."rc_dimension_index_id" = rcdi.iid and
    rcdi."rc_dimension_id" = rcd.iid and
    rcd.rating_cube_id = rc_id and
    rcd.dimension_type_id = dim_type)
    select iname, iid, level-1 alevel,
    replace(SYS_CONNECT_BY_PATH(wildcard,'/'),'/',''), iindex
      from dtree
    connect by prior iid = parent_tariff_zone_id
    start with parent_tariff_zone_id is null
    

    But make sure you careffull I'm not sys_connect_by way to reproduce the casting, because I'm not able to test the query...

  • Oracle Forms 11g - ORA-12154: TNS error

    Well, until I post my info, I searched and searched all over Google, OTN, Experts-Exchange, etc... to try and figure this one out and I am puzzled. So here goes. I get the dreaded ' * ORA-12154: TNS: could not resolve the connect identifier specified * "error. This is my environment:

    ----------------------------------------------------------------------------------------------
    Server: Red Hat Enterprise Linux 5 version performs the following:
    Oracle Database 11g (Rel 1): 11.2.0.10
    Oracle Fusion Middleware 11g (rel. 11.1.1.2.0) Forms Server

    I can connect via SQL + no problem
    ----------------------------------------------------------------------------------------------
    Client: My Windows XP Professional PC.

    I can't TNSPING the SID of the database, no problem.
    I can connect via SQL + no problem
    I can connect via TOAD to the db without problem
    I can connect to Oracle Enterprise Manager through the web interface, no problem

    I have 2 houses Oracle (Oracle 8.0.6, Oracle 11.1.0.1) on my PC. The current House is currently the 11g one. I have my background on my PC Setup very well.

    The problem is when I try to run an example of form through the web, I created, the login prompt appears and I get my name in username/password / database SID and it is, I get the error. Of the clues as to what I should look for? Ultimately it is an application that all users will access and they should not have to worry about anything whatsoever to have installed on their PC.

    Thank you

    Keep in mind that file tnsnames.ora forms 11g is under $ORACLE_INSTANCE/config

  • CAP error (the canoe system find the specified file) Exception is produced &amp; i/o Error: C:\Users\myname\AppData\Local\Temp\widgetGen.13585025011375276733210

    IO error: C:\Users\Shravan\AppData\Local\Temp\widgetGen.13585025011375276733210
    . tmp\sampleapp (the system cannot find the file specified)
    [ERROR] CAP exception has occurred

    Why does thisd error occur and how to fix it?

    I signed the keys to the cmd line

    IAM trying to package also with cmd prompt only.

    Thank you

    Closing thread because it is a duplicate:
    http://supportforums.BlackBerry.com/T5/Web-and-WebWorks-development/I-O-error-C-users-Shravan-AppDat...

  • Producer of Folio error

    Hallo,

    Yeserday afternoon I deleted my folio free edition Folio producer that I created in indesign.

    I have created a new set of folio in indesign and I can see from Adobe Content viewer well but when I go to the producer Folio I can't see one of my portfolio that I just created.

    It shows that I have no folio, please create one.

    I am very sure that I'm not working on the mode - I'm connected to the internet.

    He used to download the folio automatically on Folio producer after that I created one in indesign, but not more - even I try to refresh, connection.

    Please let me know where went wrong? or maybe there is a problem with the server producer Folio?

    Looking forward to hear from you,

    Kind regards

    Rush Sulaiman

    Guys,

    Thank you for your help, really appreciate it.

    I don't know how, in some sort the link between indesign with producer Folio started working again - it is all matter

    See you soon,.

    Rush

  • Mobile app to beta3 producing an odd error

    I'm the porting an app to beta2 beta3. I get the following error: Expecting semicolon before the target. It provides a line number, but does not indicate any file. Any thoughts?

    After a lot of debugging, I finally resolved the matter to be with one? ...:... conditional style within an MXML attribute. I think that no file name was displayed because the error was in the code generated by Flex.

  • error 1 to queue in a producer/consumer architecture

    Hi all

    I use an architecture-based on producer/consumer queue, as shown in the screenshot below (which is a simplified diagram of what I want to do).

    As you can see:

    1 / in the producer of the loop, I read data from two LV2: map Wafer and HAD current

    2 / in the loop of producer, these LV2 are used as output of a sub - VI, called 'Wafer map change. The Subvi, allows the user to change the 'Wafer map' picture indicator located in the loop of consumption, by double clicking it.

    3 / when the Subvi has run, it displays the picture indicator updated (Wafer card) and the new 'Course DUT' coordinates.

    4 / the two variables are grouped and transformed into a Variant.

    5 / the variant is then enqueud in the queue of the 'hand '.

    6 / this variant is converted from inside the loop of consumption, and photo indicator is unbundled.

    7 / Finally, the map LV2 Wafer is written and the modified photo indicator.

    This type of data flow worked earlier, but now I am facing the following error (it's my french translation):

    Error 1 occurred: Add an element at the end of the queue in GUI.vi of automatic Test Bench

    Possible reasons:

    LabVIEW: An input parameter is not valid. For example, if an entry is a path, it may contain a character that is prohibited by the operating system, as? or @.

    NOR-488: The command requires a PDC GPIB controller.

    I have no idea how it appeared. But now I'm stuck, and I would be grateful if someone can help me with it.

    Thank you.

    Kind regards

    Florian

    Your method to allow the judgment seems suspicious.  Say that there is an error in the loop of consumption.  This stops the loop of consumption and the stop button set to TRUE.  But the value of the stop button will not be read until the next iteration of the loop of producer.  So if you decide to hit the button on the Insert, the queue was already destroyed, then you will get your error.  And all these local variables just shouts "RACE CONDITION" for me.

    Get a mechanical action of the Stop button latch when out.  It is the default setting for a button.  Then place the terminal inside the event (which you already have).  A REAL outside this case, wire OR with wire error to stop the loop of the producer.

    You need to do is create a command to stop the loop of the consumer.  This order will be sent in the case of changing value of stop button.  You should probably send this command after the loop of producer, just in case where the loop of producer created an error.

    You can also use a node property of the button stop to set the Value property (signs).  This will cause the structure of the event to raise.  This will cause the producer loop stop if the consumer has an error.

  • Pack Content Validation error: query needs at least a keyword text

    I get "error validating content Pack: query needs at least a test complete keyword" error for the dashboard I created.  That means in fact, I feel that I use the keyword text.

    Attached to the screenshot for the validation error as well as the dashboard application. I appreciate any help here.

    This is a known bug in the validator that its unable to find a keyword, even when one exists. Please ignore for now. Usually what it means if there is no keyword in the search box or text filter it prompts a user to add at least a keyword because it helps makes the query more quickly and improves the overall query performance.

    Can I ask what submission of content pack this question is related to?

    Thank you!

  • Why the button in movieclip produces Error #1034

    I have a menu sliding with several clips.  I want to add buttons to each Panel to link to a PDF file.  The button works, but the code produces the following error:

    TypeError: Error #1034: Type coercion failed: cannot convert flash.display::SimpleButton@114e2941 to flash.display.MovieClip.

    at slideshow_fla::MainTimeline/onClick()

    I tried to bypass the portion of interpolation of Panel by searching for type of child, but it does not seem to ignore the button.  What Miss me?

    Import gs.*;

    Gs.easing import. *;

    S1.props = {lx:0, rx: 350, ind:1};

    S2.props = {lx:36.45, rx: 386.45, ind:2};

    S3.props = {lx:72.90, rx: 422.95, ind:3};

    S4.props = {lx:109.40, rx: 459.45, ind:4};

    S5.props = {lx:145.85, rx: 495.90, ind:5};

    S6.props = {lx:182.35, rx: 532,40, ind:6};

    S7.props = {lx:218.80, rx: 568.85, ind:7};

    S8.props = {lx:255.25, rx: 605.30, ind:8};

    S9.props = {lx:291.75, rx: 641.80, ind:9};

    S10.props = {lx:328.20, rx: 678.25, ind:10};

    S11.props = {lx:364.70, rx: 714.45, ind:11};

    S12.props = {lx:401.15, rx: 751.20, ind:12};

    S13.props = {lx:437.60, rx: 787.65, ind:13};

    S14.props = {lx:474.10, rx: 824.15, ind:14};

    S15.props = {lx:510.55, rx: 860.60, ind:15};

    S16.props = {lx:547.05, rx: 897.10, ind:16};

    S17.props = {lx:583.50, rx: 933.55, ind:17};

    S1.addEventListener (MouseEvent.CLICK, onClick);

    S2.addEventListener (MouseEvent.CLICK, onClick);

    S3.addEventListener (MouseEvent.CLICK, onClick);

    S4.addEventListener (MouseEvent.CLICK, onClick);

    S5.addEventListener (MouseEvent.CLICK, onClick);

    S6.addEventListener (MouseEvent.CLICK, onClick);

    S7.addEventListener (MouseEvent.CLICK, onClick);

    S8.addEventListener (MouseEvent.CLICK, onClick);

    S9.addEventListener (MouseEvent.CLICK, onClick);

    S10.addEventListener (MouseEvent.CLICK, onClick);

    S11.addEventListener (MouseEvent.CLICK, onClick);

    S12.addEventListener (MouseEvent.CLICK, onClick);

    S13.addEventListener (MouseEvent.CLICK, onClick);

    S14.addEventListener (MouseEvent.CLICK, onClick);

    S15.addEventListener (MouseEvent.CLICK, onClick);

    S16.addEventListener (MouseEvent.CLICK, onClick);

    S17.addEventListener (MouseEvent.CLICK, onClick);

    function onClick(e:MouseEvent):void

    {

    var click: MovieClip = MovieClip (e.target);

    for (var i: int = 0; i < numChildren; i ++)

    {

    If (getChildAt (i) is the MovieClip) {}

    var mc:MovieClip = MovieClip (getChildAt (i));

    If (mc.props.ind < = clicked.props.ind)

    TweenLite.to (mc, 1, {x: mc.props.lx, ease:Expo.easeOut});})

    on the other

    TweenLite.to (mc, 1, {x: mc.props.rx, ease:Expo.easeOut});})

    }

    }

    }

    S1. B1.addEventListener (MouseEvent.CLICK, onBtn1Press);

    function onBtn1Press(e:MouseEvent)

    {

    trace ("button 1 pressed");

    }

    You must enable debugging so you can see the line of code to the origin of the problem, but looking at your code, it looks like the problem:

    var click: MovieClip = MovieClip (e.target);

    Fix it

  • C2664 errors after the upgrade of client db 10g and 11g

    Hi, after upgrading customer db 10g and 11g, the compiler gave errors error C2664:

    /************************************************************
    AddCxrCh.cpp (2071): error C2664: 'sqlglm': cannot convert parameter 1 from 'char' [513] in ' unsigned char *'
    Types of art are not related. conversion requires reinterpret_cast, C style cast or function-style cast
    make: * [AddCxrCh.obj] error 2
    ************************************************************/

    The same code was compiled correctly when you use the db 10g client. I know that I can easily correct this error by changing the code, but there is more than a sqlglm used instructions. I'm looking for a way that will solve the problem by changing the settings of the compiler.

    Thank you

    Hello

    There is a change between 10g and 11g. It is described in "Oracle 11g Pro * C nsqlprep Sqlglm issues [ID 860382.1]". The document, you can find on Metalink, aka Oracle Support.

    Herald tiomela
    http://htendam.WordPress.com

Maybe you are looking for