Pivot

Hi Master,

I have a table like this...! I use oracle 11.2.

values of Sno

1         a

2         b

3         c

4         d

5         e

6 f and so forth... up to 26 z--but I need to output of

Co1 co2 co3

1     a     b      c

2 d e f like that...!

I tried like this...

Select sno, case, when sno = 1 then 'a b c '.

When sno = 2 then a e f'

on the other

null

end

ABC;

But how to store a, b and c in each column?

I use pivot, or listagg. But I've tried a lot of things... not getting not good performance... of course it is a work at home. but need your help.  Please advise... !!

Respect of

AR

Post edited by: 874273

Nobody here should give you the answer directly if it is homework, but I can certainly give you some advice.

If you want to solve this problem with pivot, then you will need to create a collection that changes all 3 letters, I'll call this LINE.

for example:

a, b, c-online 0

d, e, f-1 online

g, h, I have-online 2

.... => n

But you also need to create a column that rises each letter to a maximum of 3, so that you can rotate on these columns.  I'll call him the PASS.

a, d, g,..., v, y-online 0

b, e, h, w, z-online 1

c, f, i,..., x-online 2

If you give each letter a number to their ordinal position in the alphabet, I'll call this ORDPOS

a = 1

b = 2

c = 3

d = 4

....

z = 26

ROW and column can be derived from this

LINE = div (ORDPOS, 3) where div is integer divisor (the number of full time division)

COL = mod (ORDPOS, 3) where mod is the modulo (remainder of the division of integers)

You will need to find a way to "div", as Oracle does not have it, but she "mod".

With all this information, it is easy to rotate to get what you want.

Tags: Database

Similar Questions

  • The pivot in Tecra S1 and duplicator?

    I would like to use the pivot of my TFT under my Tecra S1 which is anchored.

    No chance for this?

    See you soon

    Lutz

    Hello

    As far as I know you need a 3rd party software that should be supplied with the monitor.
    But it works on the unit not rooted?

    Also check this post on a similar question:

    http://forums.computers.Toshiba-Europe.com/forums/thread.jspa?forumid=5&ThreadId=9726

  • How can I rotate an image of a pivot point?

    Hello

    I have a problem, the rotation VI Imaq only rotate an image at its Center. My problem is that I need a pivot known to this point. How can I achieve this?

    Thank you

    Francesco.

    This message can help?
    http://forums.NI.com/T5/LabVIEW/rotate-an-image-by-specified-pixel/TD-p/2570453

  • Display pivoting on the 8600

    OK, I have a 8600 All in 1 more. When I tried to open a document on the scanner, I caught the display, which pivoted upward and now faces almost to the top. I can't seem to find an exit or a button, so I can rotate downwards. Any ideas?

    Hi there ebeisher,

    Feeling just right of the screen to the Panel, you should feel raised 3 points. Push here and pull. This should return the screen in position for you. Let us know if it helps.

    Good luck!

  • When I open my browser Google Chrome I get error "could not find the translation file:...\pivot.ini [WPCTRL95] does not work.

    Hello

    I have the same problem. The error message appears when I open my browser Google Chrome (Yes, only that browser). The full message is: could not find the file:...\pivot.ini translation [WPCTRL95] will not run.
    What kind of changes? As far as I know, I did not bring changes of lipids to my computer or programs. The thing is that I for a moment, and I don't recall the exact moment when it appeared.

    Hello

    Please take a look at the thread similar here with a solution as possible.

    I hope this helps!

  • Pivot adjust HP w2408 function does not change not as Op Sys Win Vista to Win 7.

    1. Monitor: HP w2408.  Special model with adjustment of the pivot

    2. operating system: has: Windows Vista - pivot adjustment works properly.   IS: Windows 7 - setting pivot works at all.

    3. error message: no

    4. changes: operating system as in point 2 above.

    5 setting HP w2408 pivot function did not work since the evolution of the operating system from Windows Vista to Windows 7.

    I found the solution to my problem.  "My screen" (re: your Start menu) is not supported by HP for Windows 7.  However, my display works with Win 7.  When my computer was worked on by a local repair shop, apparently the pivot function has been disabled by mistake.  Happy news: HP has a great method for the restoration of the pivot function.

    http://support.HP.com/us-en/document/c00872993

    I copied the above URL when I was on the site of HP.

    I hope that solves your problem.  I now work in landscape mode (he wanted ArcMap).  Normally, I'm in vertical mode; It is ideal for editing large text documents!

    LS58

  • Pivot problem

    Hi master,

    I have a requirement to display the output as like that... I give fake values of table and column. If I get the desired result, that I can work on my data in the table. I want to use pivot does not decode function. Please notify.

    create table fruits (name varchar2 (10), type varchar2 (10), NTC number (3));

    Insert into SCOTT. FRUIT

    (NAME, TYPE, CNT)

    Values

    ('Apple', 'Add', 20);

    Insert into SCOTT. FRUIT

    (NAME, TYPE, CNT)

    Values

    ('Apple', 'change', 21);

    Insert into SCOTT. FRUIT

    (NAME, TYPE, CNT)

    Values

    ('Apple', 'delete', 22);

    Insert into SCOTT. FRUIT

    (NAME, TYPE, CNT)

    Values

    ("grapes", "add", 31);

    Insert into SCOTT. FRUIT

    (NAME, TYPE, CNT)

    Values

    ("grapes", "Edit", 32);

    Insert into SCOTT. FRUIT

    (NAME, TYPE, CNT)

    Values

    ("grapes", "delete", 33);

    COMMIT;

    out of desire.

    name add edit delete

    Apple 21 22 23

    31 32 33 grape

    Please advise... !

    (NAME, TYPE, CNT) fruits as long as)

    Select 'Apple', 'Add', 20 double Union all

    Select 'Apple', 'change', 21 double Union all

    Select 'Apple', 'delete', 22-dual union all

    Select 'grape', 'Add', 31 to double union all

    Select "grape", "edit", 32 double Union all

    Select 'grapes', 'delete', 33 to double

    )

    Select *.

    fruit

    pivot)

    Sum (NTC)

    to TYPE in ('Add' as 'ADD', 'Edit' under 'EDIT', 'delete' that 'DELETE')

    )

    by NAME

    NAME ADD EDIT DELETE
    "Apple." 20 21 22
    "grapes". 31 32 33
  • Using the account with pivot for several columns

    create table TEST_CASETBL (ID, NUM, TYPE, CREATED_BY, CREATED_DT) that choose

    1, 1-1, CO, ABC, sysdate-10 of all the DOUBLE select union

    2, 1-1, EO, ABC, sysdate-10 of all the DOUBLE select union

    3, 1-2, CO, ABC, sysdate-10 of all the DOUBLE select union

    4, 1-2, UPD, ABC, sysdate-10 of all the DOUBLE select union

    5, 1-3, CO, XYZ, sysdate-10 of all the DOUBLE select union

    6, 1-3, EO, XYZ, sysdate-10 of all the DOUBLE select union

    7, 1-4, CO, XYZ, sysdate-10 of all the DOUBLE select union

    8, 1-4, NT, XYZ, sysdate-10 of all the DOUBLE select union

    9, 1-5, EO, XYZ, sysdate-10 of all the DOUBLE select union

    10, 1-5, NT, XYZ, 10 sysdate from DUAL;

    I want to calculate number of NUM, County of different values in the 'TYPE' column based on the CREATED_BY column

    Expected result:

    CREATED_BY Count (NUM) Count (CO) Count (EO) Count (s) Count (UPD)

    ABC                                 2(which means 1-1,1-2)               2                   1                         0            1

    XYZ                           3(which means 1-3,1-4,1-5)               2                    2                        2            0

    Please provide your suggestions to solve the SQL query form

    Thank you

    Hello

    Melissacharlier-Oracle wrote:

    create table TEST_CASETBL (ID, NUM, TYPE, CREATED_BY, CREATED_DT) that choose

    1, 1-1, CO, ABC, sysdate-10 of all the DOUBLE select union

    2, 1-1, EO, ABC, sysdate-10 of all the DOUBLE select union

    3, 1-2, CO, ABC, sysdate-10 of all the DOUBLE select union

    4, 1-2, UPD, ABC, sysdate-10 of all the DOUBLE select union

    5, 1-3, CO, XYZ, sysdate-10 of all the DOUBLE select union

    6, 1-3, EO, XYZ, sysdate-10 of all the DOUBLE select union

    7, 1-4, CO, XYZ, sysdate-10 of all the DOUBLE select union

    8, 1-4, NT, XYZ, sysdate-10 of all the DOUBLE select union

    9, 1-5, EO, XYZ, sysdate-10 of all the DOUBLE select union

    10, 1-5, NT, XYZ, 10 sysdate from DUAL;

    I want to calculate number of NUM, County of different values in the 'TYPE' column based on the CREATED_BY column

    Expected result:

    CREATED_BY Count (NUM) Count (CO) Count (EO) Count (s) Count (UPD)

    ABC                                 2(which means 1-1,1-2)               2                   1                         0            1

    XYZ                           3(which means 1-3,1-4,1-5)               2                    2                        2            0

    Please provide your suggestions to solve the SQL query form

    Thank you

    This CREATE TABLE statement works when try you it?  Do you need single quotes around string literals?

    You may want something like:

    WITH data_to_pivot AS

    (

    SELECT created_by, type

    COUNT (DISTINCT num) over (PARTITION BY created_by) AS count_num

    OF test_casetbl

    )

    SELECT *.

    OF data_to_pivot

    PIVOT (COUNT (*)

    TO indicate the ("CO" AS count_co

    'EO' AS count_eo

    'NT' AS count_nt

    'UPD' AS count_upd

    )

    )

    ORDER BY created_by

    ;

  • How to select columns, that we need a table with pivot

    Hello

    How can I select only the required columns that I need the table

    My goal is to keep everything in one line

    Database: 11.2.0.2.0

    I have a table called Table Agent

    create the table AGENT_DETAIL

    (

    agent_id NUMBER (20) not null,

    agent_type_code VARCHAR2 (10) not null,

    agent_type_prefix VARCHAR2 (10) not null,

    Type_Code VARCHAR2 (10) not null,

    type_prefix VARCHAR2 (10) not null,

    last_modified DATE not null

    )

    INSERT INTO agent_detail VALUES

    (29709, ARE ',' OFFICE ',' DNSWEB ',' AGTDETAILS', SYSDATE);

    INSERT INTO AGENT_DETAIL VALUES

    (29709, ARE ',' OFFICE ',' DNSNATID ',' AGTDETAILS', SYSDATE);

    INSERT INTO AGENT_DETAIL VALUES

    (29709, ARE ',' OFFICE ',' DELIVERY ',' AGTDETAILS', SYSDATE);

    INSERT INTO AGENT_DETAIL VALUES

    (29709, ARE ', 'OFFICE', "WEBUSAGE", "WEBUSER" SYSDATE);

    When you query it against the table

    SELECT * FROM AGENT_DETAIL;

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXTYPE_CODETYPE_PREFIXLAST_MODIFIED
    129709REOFFICEDNSWEBAGTDETAILS22:14:15 12/09/2015
    229709REOFFICEDNSNATIDAGTDETAILS09/12/2015-22:15:26
    329709REOFFICEDELIVERYAGTDETAILS09/12/2015-22:21:37
    429709REOFFICEWEBUSAGEWEBUSER10/12/2015-09:27:52

    Because my goal is to put everything in a single line instead of get in 4 rows

    My query is like that

    (select *)

    the Dungeon of pivot (min (TYPE_CODE) AGENT_DETAIL (last dense_rank command by LAST_MODIFIED) for TYPE_CODE in ('DNSWEB' as the WEB)

    'DNSNATID' as

    NATIONAL,

    'DELIVERY' AS

    DELIVERY,

    "WEBUSAGE" AS WEBUSAGE

    )

    ))

    Result:

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXTYPE_PREFIXWEBNATIONALDELIVERYWEBUSAGE
    129709REOFFICEWEBUSERWEBUSAGE
    229709REOFFICEAGTDETAILSDNSWEBDNSNATIDDELIVERY

    Is it possible to get everything in one record, I know that I have two type_prefixes different (WEBUSER, AGTDETAILS)

    But all I want to see my data is like this

    Agent_id Agent_type_code Agent_type_prefix WEB WEBUSAGE NATIONAL DELIVERY

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

    RE OFFICE DNSWEB DNSATID DELIVERY WEBUSAGE 29709

    Hello

    When you use SELECT... PIVOT, the result set contains 1 row for all the distinct combinations of the values of all columns except columns mentioned in the PIVOT clause.  If you want to ignore some columns completely, then let the PIVOT operated at a "table" that does not include the.  For example:

    with RELEVANT_AGENT_DETAIL as

    (

    Select AGENT_ID, AGENT_TYPE_CODE, AGENT_TYPE_PREFIX, TYPE_CODE, LAST_MODIFIED

    of AGENT_DETAIL

    -where--if you filter, put it here

    )

    Select *.

    of RELEVANT_AGENT_DETAIL

    Pivot (min (TYPE_CODE) Dungeon (last dense_rank command by LAST_MODIFIED))

    for TYPE_CODE in ('DNSWEB' as WEB

    'DNSNATID' as NATIONAL

    'DELIVERY' as DELIVERY

    "WEBUSAGE" as WEBUSAGE

    )

    )

    ;

    If you are lazy or trying to be cute, maybe you can give the columns unwanted some lazy jobs in the PIVOT clause, like this:

    Select *.

    of AGENT_DETAIL

    Pivot (min (TYPE_CODE) Dungeon (dense_rank last order by LAST_MODIFIED)

    TYPE_CODE

    TYPE_PREFIX

    )

    for TYPE_CODE in ('DNSWEB' as WEB

    'DNSNATID' as NATIONAL

    'DELIVERY' as DELIVERY

    "WEBUSAGE" as WEBUSAGE

    )

    )

    ;

    But this makes the code confusing and may be difficult to maintain.

  • Overtemperature "PIVOT" is missing from the ODI 12.1.2

    Hello

    I use ODI 12.1.2 under 64 bit Linux.

    In my component palette "PIVOT" is missing, so I made a request Patch 17053768 with success.

    Am I supposed to remove the ' ~ /.odi/system12.1.2.0.0 ' file according to the section after the installation of the file Readme in the patch, but I might not be able to get the path because of which I wouldn't be able to delete the "system12.1.2.0.0" resulting "PIVOT" in Linux(64bit) component file still missing.

    Help, please...

    Thank you

    Sébastien.

    Note .odi is a hidden directory

    • On Unix /Linux:

    $HOME/.odi/system11.xxx

    Then search for the hidden by the name .odi directory and delete the appropriate.

    How to restore the default layout / Initial of Windows ODI (Doc ID 1439606.1)

    Kind regards

    Deker P.

  • PIVOT of several columns

    Hi gurus,

    I have a table, for which I am trying to get a given for a person_id in

    "person_id / Group1 / Group1_end_dt / Group1_sts / group2 / Group2_end_dt / Group2_Sts ' format. Is there a way to achieve a single line for a person, using an analytical function?

    Could you please help?

    Create Table my_tab (person_id number, group_num number, group_end_dt Date, group_sts Varchar2 (10));

    /

    insert into my_tab (PERSON_ID, GROUP_NUM, GROUP_END_DT, GROUP_STS)

    values (100, 1, to_date (10 January 2015 ', 'dd-mm-yyyy'), 'MET');

    insert into my_tab (PERSON_ID, GROUP_NUM, GROUP_END_DT, GROUP_STS)

    values (100, 2, to_date (11 January 2015 ', 'dd-mm-yyyy'), "NOTM");

    insert into my_tab (PERSON_ID, GROUP_NUM, GROUP_END_DT, GROUP_STS)

    values (200, 1, to_date (10 January 2015 ', 'dd-mm-yyyy'), "NOTM");

    insert into my_tab (PERSON_ID, GROUP_NUM, GROUP_END_DT, GROUP_STS)

    values (200, 2, to_date (11 January 2015 ', 'dd-mm-yyyy'), 'MET');

    with

    my_tab as

    (select person_id 100, 1 group_num, to_date('01-10-2015','dd-mm-yyyy') group_end_dt, group_sts 'PUTS' of all the double union)

    Select 100.2, to_date (January 11, 2015 "," dd-mm-yyyy'), 'NOTM' from dual union all

    Select 200,1, to_date (January 10, 2015 "," dd-mm-yyyy'), 'NOTM' from dual union all

    Select 200,2, to_date (January 11, 2015 "," dd-mm-yyyy'), 'PUTS' from dual

    )

    Select *.

    of my_tab

    Pivot (Max (group_end_dt) end_date, max (group_sts) at group_num (as group_one, 2 group_two 1) of the Statute)

    PERSON_ID GROUP_ONE_END_DATE GROUP_ONE_STATUS GROUP_TWO_END_DATE GROUP_TWO_STATUS
    100 10/01/2015 MET 01/11/2015 NOTM
    200 10/01/2015 NOTM 01/11/2015 MET

    Concerning

    Etbin

  • Sorting for the pivot 5 APEX error

    Hello

    Has anyone encountered the following error when trying to make a kind of pivot with more than 1 sort column? If so, what is the solution?

    {'dialogue': {'uv': true, 'line': [{'V': "failure of Widget}]}}

    AJAX\u0020call\u0020returned\u0020server\u0020error\u0020ORA\u002D01403\u003A\u0020no\u0020data\u0020found\u0020for\u0020worksheet. »}]}}

    If we make a kind of pivot with sort 1 column, the results are always returned without any error. I just created a SR this topic because I think it could be a bug.

    Version of the APEX - 5.0.0.00.31

    Version of DB - 11.2.0.4.0

    APEX via OSH/mod plsql

    Kind regards

    David

    Just to let everyone know that after raising a SR, they confirmed that this is a bug and it will be fixed in version 5.1. This bug is in each version of the APEX 5 so far.

    Kind regards

    David

  • Doubt pivot

    Hi Master,

    The syntax of the pivot function can I use several columns in the "IN CLAUSE".  Not as in (10,20,30) deptno column values? Please explain to me. If possible... Thanks for giving me an example

    Concerning

    AR.

    Hello

    874273 wrote:

    Hi Master,

    The syntax of the pivot function can I use several columns in the "IN CLAUSE".  Not as in (10,20,30) deptno column values? Please explain to me. If possible... Thanks for giving me an example

    Concerning

    AR.

    Of course, you can have several columns in the IN clause.  Try it and see.

    I don't know what you mean by "not the values of columns as deptno in (10,20,30).  You won't want to give values for each of the columns?

    Here is an example:

    WITH relevant_data AS

    (

    SELECT EXTRACT (YEAR FROM hiredate) AS hireyear

    deptno

    work

    FROM scott.emp

    WHERE job IN ("CLERK", "MANAGER")

    )

    SELECT *.

    OF relevant_data

    PIVOT (COUNT (*)

    (JOB, deptno) IN ((«GREFFIER», 10) AS clerk_10)

    , ('MANAGER', 10) AS manager_10

    , ("CLERK", 20) AS clerk_20

    , ('MANAGER', 20) AS manager_20

    , ("CLERK", 30) AS clerk_30

    , ('MANAGER', 30) AS manager_30

    )

    )

    ORDER BY hireyear

    ;

    Output:

    HIREYEAR CLERK_10 MANAGER_10 CLERK_20 MANAGER_20 CLERK_30 MANAGER_30

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

    1980          0          0          1          0          0          0

    1981          0          1          0          1          1          1

    1982          1          0          0          0          0          0

    1987          0          0          1          0          0          0

    I hope that answers your question.

    If not, post an example of what you're trying to do with multiple columns using other commonly available tables, as scott.emp, or a table of your own table (CREATE TABLE and INSERT post instructions).  Display the accurate results you want from the data provided and your best attempt at a query.

  • Writing a query that may require a pivot but include [month, year] in the column and RiskGrades, no aggregate?

    Hello

    new to oracle/mark. I need to write a query that will pull the customer details and on the columns, it will have the month-year: Jan2015, Feb2015... Dec2015.

    on the lines, it will contain the details of the client. the information it will provide are the categories of risk to each month.

    I create a query, but it uses a function to update and is very slow. There are approximately 3000 documents. An update of column required 15 minutes or even more. so an update of column takes 15 minutes * 9 to update until September.

    the best ways to manage this demand?

    my query is:

    UPDATE tmpRiskGrades one

    SET a.feb2015 =)

    Select l.risk_grade

    of rep_loanportfolio l

    where a.agreementno = l.agreeement_no AND l.dtuserdatetime = February 28, 2015 ")

    Certainly, that looks like a pivot base for me.  Assuming that dtuserdatetime is actually a date data type, something like that will not work in your version of non-recognition:

    Select customer_no, agreeement_no, customer_address, loan_type region,

    Max (case when dtuserdatetime = to_date (Jan 31, 2015 "," DD month yyyy ' "))

    end of the era risk_grade) jan2015,.

    Max (case when dtuserdatetime = to_date (February 28, 2015 "," DD month yyyy ' "))

    then risk_grade end) Feb2015,

    ...

    of rep_loanportfolio l

    where loan_type = "HOME LOAN" and

    account_status = 'LIVE' and

    dtuserdatetime between to_date (Jan 31, 2015 "," DD month yyyy ' ") and

    TO_DATE (31 Dec 2015 "," DD month yyyy ' ")

    Group of customer_no, agreeement_no, customer_address, region loan_type

    order of region loan_type, customer_no, agreeement_no, customer_address

    If you are on 11.2 or higher, you could look at the PIVOT keyword, which is a more concise expression of the same thing.

    John

  • PIVOT and string concatenation

    Hi everyone ,


    I would like to use a pivot query to build a report .is it possible concatenation in Pivot report.

    My requirement is

    Vinoth RAM Sam Rahul Vimal Arun
    Visitors
    Neo tools / connections of mercury / R.Industries / LAU /Forge
    Fittings of mercury /R.Industries / /Forge LAUForge/MercuryR.Industries / UAL


    Any guidance would be appreciated.


    Thank you

    Colette

    Colette wrote:

    I would like to use a pivot query to build a report .is it possible concatenation in Pivot report.

    My requirement is

    Vinoth RAM Sam Rahul Vimal Arun
    Visitors
    Neo tools / connections of mercury / R.Industries / LAU /Forge
    Mercury Fittings/R.Industries / LAU /Forge Forge/Mercury R.Industries / UAL

    Any guidance would be appreciated.

    Yes, it is possible to perform the aggregation of the chain in a pivot report.

    How depends completely on the information about your environment, data model and the data you have provided not: How to get the answers from the forum

    See also Re: 4. How can I convert rows to columns?

Maybe you are looking for

  • C6280 printer and windows 7

    all software except for a levels of the program (the hp soultion Center) ink for this printer it says is not compatible with windows 7. is there anyway that I can make it work? is there an option on the printer for this? or is there another program I

  • Modem in Portege 650ct - cannot find the driver

    Help, please!I can't find the driver for the modem installed in the laptop Toshiba portege 650 CT (the internal modem)ATI3 command responds: Toshiba 28.8 data/14.4 Fax Modem Version 4.15 (MA) [Edited by: admin August 20 05 08:21]

  • Logic pro 9 crashing

    Logic Pro 9.1.8 (1700.67) - OS X El Capitan 10.11.2 Mac Pro mid-2012 3.2 GHz Quad-Core Intel Xeon 14 GB 1066 MHz DDR3 ECC ATI Radeon HD 5770 1024 MB ------------------------------------------------------------- So logical crashes constantly in two di

  • Questions of G72 - "pinch" the Touchpad / compatible keyboard backlight

    Currently, I bought a HP G72-B66US.  I just have a few questions. I am able to "pinch" on the Touchpad zoom?Y at - it a backlit keyboard to this model? Any help would be greatly appreciated.

  • Under certain conditions add value in table

    Hi all I have two tables 2D of the string data in my VI (taken from the .mdb using ADO & SQL file). The "Window list" table on the left, that's what I want to add values to. The 'List of glass' table on the right contains the values that I want to ad