display the data in row columns

I looked through the previous posts, but it is impossible to find a solution to my problem.

I want to display the data in row columns.
I have shown in the table below and test data and the sql code that gives me the result desired.
However, you can see that the sql depends of me knowing all the values in the column "rank".
I want a way to produce the output without knowing the values of rank.
CREATE TABLE test1 (
  accno       NUMBER,
  holder_type VARCHAR2(10),
  rank        NUMBER)

INSERT INTO test1 VALUES (1, 'acr', 0);
INSERT INTO test1 VALUES (1, 'bws', 1);
INSERT INTO test1 VALUES (1, 'aaa', 2);
INSERT INTO test1 VALUES (2, 'cds', 0);
INSERT INTO test1 VALUES (2, 'xxx', 1);
INSERT INTO test1 VALUES (3, 'fgc', 0);
INSERT INTO test1 VALUES (4, 'hgv', 0);
INSERT INTO test1 VALUES (4, 'bws', 1);
INSERT INTO test1 VALUES (4, 'qas', 2);
INSERT INTO test1 VALUES (4, 'aws', 3);

Here's the required output:=
ACCNO     ALLCODES
1     acr bws aaa
2     cds xxx
3     fgc
4     hgv bws qas aws

I.E. for each accno display the holder_types in rank sequence.

SELECT * FROM
(SELECT 
       a0.accno,
       a0.holder_type || DECODE(a1.holder_type, NULL, NULL, ' ') ||
       a1.holder_type || DECODE(a2.holder_type, NULL, NULL, ' ') ||
       a2.holder_type || DECODE(a3.holder_type, NULL, NULL, ' ') ||
       a3.holder_type || DECODE(a4.holder_type, NULL, NULL, ' ') ||
       a4.holder_type allcodes
  FROM (SELECT accno,
               holder_type,
               rank
          FROM test1
         WHERE rank = 0) a0,
       (SELECT accno,
               holder_type,
               rank
          FROM test1
         WHERE rank = 1) a1,
       (SELECT accno,
               holder_type,
               rank
          FROM test1
         WHERE rank = 2) a2,
       (SELECT accno,
               holder_type,
               rank
          FROM test1
         WHERE rank = 3) a3,
       (SELECT accno,
               holder_type,
               rank
          FROM test1
         WHERE rank = 4) a4
 WHERE a0.accno = a1.accno(+)
   AND a0.accno = a2.accno(+)
   AND a0.accno = a3.accno(+)
   AND a0.accno = a4.accno(+)) a
   ORDER BY accno

So you're after what we call 'Aggregation in the chain.'

Check this link as it highlights several techniques:

Aggregation of string techniques

A Re: Concat ranks of the values in a single column Michael

At Re: multiple lines in a single line in the 'single column Table' followed by reason of Billy on the conduct of a stragg first.

In addition, 11 GR 2 has the LISTAGG function.

Tags: Database

Similar Questions

  • Display the date in a column

    Hi all

    I have a column that displays the date in the marker '2010-05-29 14:52:10 ', my requirement is I want to show only the month and year according to the results.

    Say '2010-05-29 14:52:10 ' should be displayed as "may 2010"...» I checked and found that we have MONTHNAME (expr), which returns only the month. We have one for the month and year in the format above. Please give your suggestions.

    Thank you
    Natraj

    Hi, to get the name of the month you can use MONTHNAME (date_expression). For the year, you can use YEAR (date_expression). I suppose that these two might meet your requirements.

    Alternatively, you can click on the properties of the columns, go to the "data format" tab, choose the custom date format and give the 'custom date format"yyyy MMMM for desired results

    -John CRMIT

  • call a stored procedure for each row in the transitional attribute and display the data in the form of af: table. The other rows are based on the entities

    Hi Experts,

    JDeveloper 12.1.3.0.0

    I have a VO based on entity object. With a column of the VO is transient attribute (I created).

    I need to call a stored procedure for each row in the transitional attribute and display the data in the form of af: table. As well as other attributes.

    So can anyone suggest how can I achieve this?

    Thank you

    AR

    I think that you need a stored function (which returns the value) in this case, is not?

    Take a look at:

    https://docs.Oracle.com/CD/B31017_01/Web.1013/b25947/bcadvgen005.htm

    and search for:

    Invoking stored function with only Arguments in

    call your function in the Get attribute and return value accessor...

  • Displays the number of rows in the table displaying a named criteria query data

    I created a test named for my View, called 'Criteria1' and Criteria1 to create a group of ADF with Table query. I want to display the number of rows in result when a search is performed. How can I do?

    Thanks in advance,
    Tom

    As mentioned, you can add outputText and you must give OutputText partialTriggers as query component your Id. Thus, when you give a search on the query component, it will refresh the outputText with the number of lines.


    ID = "ot1" partialTriggers = "id of the component of motion here" / > ""

  • How to display the date (instead of number) along of there axis of column chart?

    Hello

    I have a requirement in which I need to display the date on the projects along the x axis and y Axis. It is essentially a graph of milestone. Something like this:

    Capture.PNG

    Here is my code:

    < mx:ArrayCollection id = "acProjects" >
    < mx:Object PROJID = 'A1' projDesc = 'Execution of Civil engineering works' plandate = '2009-12-23' actualdate = "2009-11-25" / >
    < mx:Object PROJID = "A2" projDesc = 'Installation of equipment' plandate = '2010-02-15' actualdate = "2010-03-25" / >
    < mx:Object PROJID = 'A3' projDesc = 'Comissioning of Equipment' plandate = '2010-05-30' actualdate = "2010-06-15" / >
    < mx:Object PROJID = 'A4' = 'Transfer to regular use' projDesc plandate = "2010-04-23" actualdate = "2009-03-30" / >

    < / mx:ArrayCollection >

    < mx:ColumnChart id = "columnchart1" width = "100%" height = "100 percent" color = "black" dataProvider = "{acProjects}" >
    < mx:horizontalAxis >
    < mx:CategoryAxis categoryField = "projDesc" / >
    < / mx:horizontalAxis >
    < mx:series >
    < mx:ColumnSeries displayName = "Date" xField = 'projDesc"yField ="plandate"/ >

    < / mx:series >
    < / mx:ColumnChart >

    But with this code, I get something like this:

    Capture2.PNG

    In general, by default, the y-axis is always numbered. Is there a way where we can change to display date?

    Appreciate your help...

    -Deepak

    Use the DateTimeAxis:

    http://livedocs.Adobe.com/Flex/3/langref/MX/charts/DateTimeAxis.html

  • How to display the data, that contains non-numeric characters.

    Hello

    I have table t1 with column of type varchar2 below

    ID

    ------

    11151

    11412

    1113

    1 to 114

    11b 15

    111 6

    Now, I need to display the data, that contains non-numeric characters.

    Did you get the result like:

    STR

    ----------

    1 to 114

    11b 15

    111 6

    WITH t
         AS (SELECT '11151' str FROM DUAL
             UNION ALL
             SELECT '11412' FROM DUAL
             UNION ALL
             SELECT '1113' FROM DUAL
             UNION ALL
             SELECT '1a114' FROM DUAL
             UNION ALL
             SELECT '11b15' FROM DUAL
             UNION ALL
             SELECT '111c6' FROM DUAL)
    SELECT *
      FROM t
      where regexp_like(str,'[^[:digit:]]');
    

    See you soon,.

    Manik.

  • See the date with timestamp column column

    Hello

    In the table have am capture the creation_date as date data type column. I prepare a report to display the date. Is it possible to display the date with creation of time stamp

    I use oracle 10g Enterprise Edition

    The table name is LICENSING name column is CREATION_DATE

    Please suggest me

    Thank you
    Sudhir

    Which indicates that the data currently stored in the table always have an hour of midnight. Whatever the application / process that inserts the data is, apparently, not the component "time" DATE in the desired way. You will need to set the insertion process to spend time in your report.

    Justin

  • PivotTable ' display the data as "percentage of accuracy

    Hello

    I would like to know if there is a way to configure the PivotTable ' display the data sub - percentage of ' precision.

    ATM, I have reports using SR types where one of those who are much bigger than others... Thus, when its generated report, it returns something like:

    TYPE A: 99%
    TYPE B: 0%
    TYPE C: 0%
    TYPE D: 0%

    How can I view other correct value types? Something like number of decimals...

    PS: as criteria in this report, I changed my data Format 'Number', ' less:-123 "to 15 decimal places.»

    Thank you
    Ramon

    902360 wrote:
    Hello

    I would like to know if there is a way to configure the PivotTable ' display the data sub - percentage of ' precision.

    ATM, I have reports using SR types where one of those who are much bigger than others... Thus, when its generated report, it returns something like:

    TYPE A: 99%
    TYPE B: 0%
    TYPE C: 0%
    TYPE D: 0%

    How can I view other correct value types? Something like number of decimals...

    PS: as criteria in this report, I changed my data Format 'Number', ' less:-123 "to 15 decimal places.»

    Thank you
    Ramon

    Well Yes. Can do. Read this link:

    http://shivabizint.WordPress.com/2008/09/14/changing-the-precession-of-percent-of-columns-in-pivot-table-of-OBIEE/

  • To access the data in row Datagrid since in an itemRenderer

    I would like to know how can I access the data to another line starting an itemRenderer.  I need to format my cells based on other data in line. Here's what I mean... I have a datagrid and I want in row 0 col 2 itemRenderer access the data in row 1, column 1 in order to make a comparison, I can determine how to format data line 0 pass 2 and so on.  Is there a way of the converter of element by hand in another line and access the data?  I can't find a clear answer so I thought that I would go to the pro.

    Thank you!!

    You can use this code to join the dataProvider on the grid.

    var o: Object = this.parent.parent;

    var dp:Object = o.dataProvider;

  • How to display the Date Predefault time

    Hi friends,

    How to display the date in the field to date through sctipting by default I have a requirementy to display the date field as the next day's date with timestamp from 09:00 (15/02/2010-09:00) data type as the field & column is UTC_datetime.please help I get.


    Siebel bee

    Take a look at the function today(), TimeStamp() and ToChar()

    You should be able todo with something similar to this:

    Expr: "ToChar (TimeStamp (), 'MM') + ' / ' + ToChar (TimeStamp (), 'DD') + ' / ' + ToChar (TimeStamp (), 'YYYY') + ' ' + ToChar (TimeStamp (+(1/24), 'HH')) + ': 00:00.

    as a value before failure.

  • Creation of a detailed report to display the date today

    Hello
    I try to display today date in the format of narrative report form. Anyone know how to code in HTML format?
    Here is my code to display the date: -.

    < TABLE align = "left" >
    < b >
    < TD > < B > < / b > < table >
    < TD width = "520" > < table >
    < TD > < B > < / b > < table >
    < /TR >

    < b >
    < TD > to < table >
    < TD >: @1 < table >
    < TD width = "100" > Date < table >
    < TD >: < table >
    < /TR >

    Please advice. Thank you

    Laughing out loud. what David wanted to create a custom field in your report to step 1 and initialize it as CURRENT_DATE.
    then, at step 2 of report design, use the identifier of this new column instead of @1

  • Display the data in a Dimension

    Hello

    I have a dimension with two levels

    1 program
    2. courses

    Program which is the parent level contains the names of programs as: MSc, engineering, electrical, computer science MSC, PhD Environmental Engineering...

    Course is the level of the child and contains the names of the courses that are included in the programs.

    I've specified the descriptor of the name of the program as "long Description".

    When I right-click a dimension, and then 'Data' to display the data, it's for me.
    The names of the programs, and when I drill down, he gives me the Dimension_Key of the courses in the respective program.

    Instead of the surrogate key, I want to display the names of the courses included in this program.


    What should I do to achieve this...?

    Kind regards...
    RF

    Edited by: badwanpk on January 29, 2009 14:58

    You can set a dimension (for example) DISPLAY_NAME attribute that applies to both levels and this attribute is defined as a long description attribute. It can be mapped to a column for the program and another for the course. Or have a dimension for each level attribute.

    See you soon
    David

  • How display the date of my last update of OSX in my Mac?

    How display the date of my last update of OSX in my Mac?

    If it was in the last 30 days, the updates will often (not always) show the Mac App store on your page of updates, under the heading "updates installed in the last 30 days.

  • is it possible to display the Date and time in the address bar or a clock window constantly

    I need to take screenshots with date stamps and time using the script of iMacros. Everything by taking screenshots iMacro don't add taskbar windows for the date and time. It takes screenshots of browser. Is it possible to display the Date and time in the address bar or a clock within the tab browser constantly to capture the screenshot with time stamp through iMacros
    I added the big clock background Add-ons, but it is visible to new tabs.

    Badly looking for help and it will be really appreciated...

    Try this extension:

  • A model of TV Sony KDL-32BX330 has somehow display the date or time? MENU button does not

    A model of TV Sony KDL-32BX330 has somehow display the date or time? The button MENU has no option to select or adjust the time or date... maybe a new firmware?

    Hello, manual,.

    There is no option to display the time and date of the TV Sony KDL 32BX330.

    We cannot comment on future firmware updates, nor can respond us if a product will not in the future it does not currently feature.

    If my post answered your question, please mark it as an "accepted Solution".

Maybe you are looking for

  • How do you communicate with the Apple Watch

    How do you communicate with the Apple Watch

  • IM - order of answers

    Usually, when I have IM replies come in chronological order. After Skype recently updated my answers get lumped all of mine and then the other person. It is very annoying because I have to scroll to see its new response (s), while mine to collect at

  • Installation of bench beginner for the introduction of analog measures

    Hello world I'm looking to install a system to help make some simle measures. This configuration will be used only by me at my desk/Workbench to help me better understand some parts of machine, that I as well as various other hardware troubleshooting

  • Help: Decommissioning of Win8 for Win7

    I have a new HP Pavilion p6 - 2316 s office running 64-bit Windows 8 I have 2 things that are not win 8 compadable, and I bought the DVD of Windows 7 64-bit. I went and turned off Secure Boot. I also changed the boot sequence so that it starts from t

  • Windows media player (11) starts, but does not play file

    When I double-click an audio file, WMP opens but then does not play the file. MP3 and WMA (and other formats) files are configurΘ for dΘmarrer with default WMP and video files to various formats still work very well. I can get the audio to play by do