How can we display 2 rows in a single row with new coulmn names?

Hi,
I have a requiment as shown below.
ME A_END Z_END
1 aaaa
2 zzzzz
I need the above data in the below format.
A_ME Z_ME A_END Z_END
1 2 aaaa zzzzz
How can we achive this?

user6755466 wrote:
Hi Alex,
Thanks for your quick response.
Actually the coulmns ME_ID, A-END, Z-END, etc doesn't have fixed values as you hard coded with values (e.g., 1, 2) in your query.One way is to assign a "row number" to each row and then pivot using the known row numbers of 1, 2 ... etc.
Example:
SQL> ed
Wrote file afiedt.buf
  1  with test as
  2  (
  3  select 3 a_end, 'aaaa ' z_end from dual union all
  4  select 5 a_end, 'zzzzz' z_end from dual
  5  )
  6  select max (decode (rn, 1, a_end)) a_me
  7       , max (decode (rn, 2, a_end)) z_me
  8       , max (decode (rn, 1, z_end)) a_end
  9       , max (decode (rn, 2, z_end)) z_end
10  from (select a_end, z_end
11              ,row_number() over (order by a_end, z_end) as rn
12*       from test)
SQL> /
      A_ME       Z_ME A_END Z_END
         3          5 aaaa  zzzzz
SQL>Here, the values are 3 and 5, but they are assigned a row number based on the order of them and then the decode uses that row number to pivot them.
Of course, as everyone else has pointed out, the best place to be doing this is in a dedicated reporting tool. SQL is not the best of places to pivot data for reporting purposes.

Similar Messages

  • How can I display the rows into columns.

    How can I display the rows into columns. I mean
    Create table STYLE_M
    (Master varchar2(10), child varchar2(10));
    Insert itno style_m
    ('MASTER1','CHILD1');
    Insert itno style_m
    ('MASTER2','CHILD1');
    Insert itno style_m
    ('MASTER2','CHILD2');
    Insert itno style_m
    ('MASTER3','CHILD1');
    Insert itno style_m
    ('MASTER3','CHILD2');
    Insert itno style_m
    ('MASTER3','CHILD3');
    Note : The Master may have any number of childs.
    I want to display like this..
    Master child1, child2, child3, .......(dynamic)
    MASTER1 CHILD1
    MASTER2 CHILD1 CHILD2
    MASTER3 CHILD1 CHILD2 CHILD3
    Sorry for disturbing you. Please hlp me out if you have any slution.
    Thanks alot.
    Ram Dontineni

    Here's a straight SQL "non-dynamic" approach.
    This would be used if you knew the amount of children.
    SELECT
         master,
         MAX(DECODE(r, 1, child, NULL)) || ' ' || MAX(DECODE(r, 2, child, NULL)) || ' ' || MAX(DECODE(r, 3, child, NULL)) children
    FROM
         SELECT
              master,
              child,
              ROW_NUMBER() OVER(PARTITION BY master ORDER BY child) r
         FROM
              style_m
    GROUP BY
         master
    MASTER     CHILDREN                        
    MASTER1    CHILD1                          
    MASTER2    CHILD1 CHILD2                   
    MASTER3    CHILD1 CHILD2 CHILD3             Since you said that the number of children can vary, I incorporated the same logic into a dynamic query.
    SET AUTOPRINT ON
    VAR x REFCURSOR
    DECLARE
            v_sql           VARCHAR2(1000) := 'SELECT master, ';
            v_group_by      VARCHAR2(200)  := 'FROM (SELECT master, child,  ROW_NUMBER() OVER(PARTITION BY master ORDER BY child) r FROM style_m) GROUP BY master';
            v_count         PLS_INTEGER;
    BEGIN
            SELECT
                    MAX(COUNT(*))
            INTO    v_count
            FROM
                    style_m
            GROUP BY
                    master;
            FOR i IN 1..v_count
            LOOP
                    v_sql := v_sql || 'MAX(DECODE(r, ' || i || ', child, NULL))' || ' || '' '' || ';
            END LOOP;
                    v_sql := RTRIM(v_sql, ' || '' '' ||') ||' children ' || v_group_by;
                    OPEN :x FOR v_sql;
    END;
    PL/SQL procedure successfully completed.
    MASTER     CHILDREN
    MASTER1    CHILD1
    MASTER2    CHILD1 CHILD2
    MASTER3    CHILD1 CHILD2 CHILD3I'll point your other thread to this one.

  • How can I display only one value of a field with two or more values?

    Post Author: skiabox
    CA Forum: Crystal Reports
    I have a field in my report with 2 or more values (depending of another field id).For example for id = 1 the report gives me 2 names in that field.For id = 3 the report gives me 3 names in that field.I want to display only one of these names in the id row.The selection of name is random.Thanks!

    Hello Tim,  would barely fit in this situation since this code resides on the client’s interaction side of things. I’d recommend using JavaScript for this matter, e.g. var Data_FName1 = document.getElementById(‘Data_FName1’).value;. If you still opt for using CFML, then you’d go for proxying your JavaScript code to a CFC.

  • How can I keep a playlist on phone when syncing with new computer?

    When syncing my IPhone I am prompted with an ominous message that says "Are you sure you want to remove the existing music ... from this phone and sync with this ITunes library? Music .... will be removed and items will be synced from this ITunes library" The answer is no because I have a playlist I would like to keep on the phone, but add one which resides on the computer I am attempting to sync with. That is not an choice presented, the choices are Cancel or Remove and Sync. Apple should either give more options or at least a better explanation. I have synced this phone and computer combination before but have since created a new playlist in the computer (a Mac Mini).
    So how can I keep a playlist on the phone and add one from the computer too? Is it possible to view the phone as a drive and move items around in that manner? I use ITunes on both Windows and Mac platforms but this issue has always been problem for me. I also have IPhone 3 (used as an IPod), IPhone 4S and Iphone 5.

    Unless you can get the iPod backup file (and restore the iPod from that file on your new computer) from the "dead" computer you will lose all the app data you can export via email.
    - Yu can trabsfer iTnes purchases from the iPod by:
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
    - You can transfer non-itunes purchased music to the new computer by using one of the third-party programs discussed in this previous discussion.
    Best iPod to PC
    - After you move the stuff to the new computer, either restore the iPod from the backup, or if no backup, restore to factory defaults,new iPod and sync.

  • How can I read several avi files in single DVD with FRONT ROW?

    Hi!
    Is it possible to make Front Row read several movie files in a single DVD?
    I burned 6/7 avi files in each DVD, but Front Row can't even read the DVD itself!
    Thanks!

    Hi Imcaet
    It sounds as though you have made a Data DVD rather than a Movie DVD. Front Row can only read Movie DVDs. All Data must be in iTunes, or in on of the directories it looks in, such as "Movies" in your home directory.
    If you need to combine the movies, you will need something like QuickTime Pro 7, which can be purchased from the Apple website. You need to Select All the movie you wish to Append, Copy, go to the End of the movie you wish to Append to, and Paste. You can then save/export the movie in full.

  • How Can I Back Up Itunes Library to CD/DVD with New Itunes

    I have the newest version of itunes 10.5.2 and theres no longer an option to backup to a cd or dvd. I need to move all of my apps,songs,videos, ect to a new computer. If i can not use a DVD anymore, whats the easiest way to move EVERYTHING, purchased and non purchased, to a different computer?
    Thanks so much for any help!

    Backup your library using this User Tip.
    Deauthorise the old computer if you won't be using it for iTunes.
    Restore the library into the music folder on the new computer.
    Install iTunes and sign in to your account.
    tt2

  • How can I sync my iMac & iPod Touch calendar & contacts with new iTunes?

    I have just installed the latest iTunes to my iMac. My iPod Touch has iOS 6.0.1. My iMac has OS 10.6.8. I sync by Wi Fi via iCloud. My calendar and contacts are not syncing by Wi Fi between the two, although my mail is. I What should I do?

    This says that it can't be done.
    But I am able to do it for my calendars in iCloud, just not for my contacts in iCloud.
    What is the reason for the difference.

  • How can I add a row into a JTable with JButton

    Hi all. I have the following code:
    package gui;
    import db.*;
    import javax.swing.table.AbstractTableModel;
    import java.util.ArrayList;
    public class FoundersTable extends AbstractTableModel{
        private static final int COLUMNS = 8;
        private String columnNames[] = {"��� ����", "���", "�������", "�������", "���������", "��������",
                "����� �� ����������", "������ �� ����, �����"};
        private ArrayList data;
        public FoundersTable(){
            data = new ArrayList();
        public int getRowCount() {
            return data.size();
        public int getColumnCount() {
            return columnNames.length;
        public String getColumnName(int colIndex) {
            return columnNames[colIndex];
        public Object getValueAt(int rowIndex, int columnIndex) {
            return ((ArrayList)data.get(rowIndex)).get(columnIndex);
        public void setValueAt(Object value, int rowIndex, int columnIndex) {
            ((ArrayList)data.get(rowIndex)).set(columnIndex, value);
            fireTableCellUpdated(rowIndex, columnIndex);
        public void addRow(ArrayList neueZeile) {
            data.add(neueZeile);
            int index = data.size() - 1;
            fireTableRowsInserted(index, index);
        public void removeRow(int index) {
            data.remove(index);
            fireTableRowsDeleted(index, index);
        public void removeAllRows() {
            data.clear();
            fireTableRowsDeleted(0, 0);
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return true;
    }Now in my MainJFrame class I have one button for additing and one button for removing a selected row. How can I add/remove rows with this two buttons.
    Thanks

    No my question is how can I add and remove rows WITH buttons My point was the code is the same. You use the addRow(...) method. Why did you write an addRow(...) method if you aren't going to use it?
    I don't understand your problem. Do you not know how to write an ActionListener?

  • How can I display multiple numeric limit test in operator interface

    I am using Teststand 3 and I want to display additional information like the limits and the results in the sequence UI control. Adding new columns to this control is no problem, so it works good with any step type, that has a single result. But how can I display the information of a step that has multiple results ? The rows of the sequence UI control are limited to a single line.
    Regards
    Dirk Schüller-Möller

    Dirk,
    If you want to display several results for a single step, then you will need to either create a new column for each result or have an expression in your column that will format in a single string all the result that you want to display.
    What you can not do is spawn the result of a single step across several rows (only one step per row).
    Best Regards,
    Alejandro del Castillo
    Ni

  • How can i display opening qtd balances in fsg

    hi @ll
    In oralce R12 how can i display specific account opening qtd balances in fsg in one row ? plz if any 1 know tell me as soon as possible

    No, you can't. Only hours and minutes.

  • How can I display XSLT transformer errors on a web page ?

    Hi,
    I have some JSP pages that access DB, create an XML based on DB data and then transform it into HTML through an XSLT stylesheet. Developing the XSL code it's easy to make mistakes and generate errors on trasformation, but what I receive on the web page is only a "Could not compile stylesheet" TransformerConfigurationException, while the real cause of the error is displayed only on tomcat logs. This is the code for transformation:
    static public void applyXSLT(Document docXML, InputStream isXSL, PrintWriter pw) throws TransformerException, Exception {
            // instantiate the TransformerFactory.
            TransformerFactory tFactory = TransformerFactory.newInstance();
            // creates an error listener
            XslErrorListener xel = new XslErrorListener();
            // sets the error listener for the factory
            tFactory.setErrorListener(xel);
            // generate the transformer
            Transformer transformer = tFactory.newTransformer(new SAXSource(new InputSource(isXSL)));
            // transforms the XML Source and sends the output to the HTTP response
            transformer.transform(new DOMSource(docXML), new StreamResult(pw));
    }If an exception is thrown during the execution of this code, its error message is displayed on the web page.
    This is the listener class:
    public class XslErrorListener implements ErrorListener {
        public XslErrorListener() {
        public void warning(TransformerException ex) {
            // logs on error log
            System.err.println("\n\nWarning on XEL: " + ex.getMessage());
        public void error(TransformerException ex) throws TransformerException {
            // logs on error log
            System.err.println("\n\nError on XEL: " + ex.getMessage());
            // and throws it
            throw ex;
        public void fatalError(TransformerException ex) throws TransformerException {
            // logs on error log
            System.err.println("\n\nFatal Error on XEL: " + ex.getMessage());
            // and throws it
            throw ex;
    }When I have an error in the XSL stylesheet (for examples a missing closing tag), I can find on tomcat logs the real cause of the error:
    [Fatal Error] :59:10: The element type "table" must be terminated by the matching end-tag "</table>".
    Error on XEL: The element type "table" must be terminated by the matching end-tag "</table>".but on my web page is reported just the TransformerConfigurationException message that is:
    "Could not compile stylesheet".
    How can I display the real cause of the error directly on the web page?
    Thanks,
    Andrea

    This code is part of a bigger project that let developers edit XSL stylesheets through a file upload on the system and we can't impose the use of any tool for checking the xsl. So, I need to display the transformer error on the web page.I see. This code is part of an editorial/developmental tool for developers to create and edit XSL stylesheets.
    As part of the editorial process, XSL errors during editing can be considered a normal condition. In other words, it is normal to expect that the developers will generate XSL errors as they are developing stylesheets.
    In this light, handling the XSL transformation errors is a business requirement that you need to handle. Using the Java Exceptions mechanisms, e.g. try / catch are inappropriate to handle business requirements, in my opinion.
    I suggest that you look at how you handle the occurence of XSL errors differently than what you currently have. You need to:
    (1) capture the Transformation exception on the server;
    (2) extract the message from the exception and put it into a message that can be easily understood by the user;
    The current error message that you have going to the web browser is not useful.
    And you should not have the Transformation exception sent to the web browser either.
    What you are attempting to do with the exception is not appropriate.
    Handle the Transformation exception on the Business tier and use it to create a useful message that is then sent to the Presentation tier. In other words, do not send Java exceptions to web browser.
    />

  • How can I display True/False in my dropdownlist as "Yes" and "No"?

    Hi All,
    I want to bind a dropdownlist to a boolean value (so it's either true or false).  I'm particularly interested in using two-way binding to when the user changes from "yes" to "no" the boolean value automatically changes from "true" to "false."  But, I want the user to see "yes" and "no" as the options, rather than "true" and "false".
    How can I display "yes" and "no" and still take advantage of binding?  Or can I not use binding in this circumstance?
      -Josh

    Solution 1:
    In order to display Yes/No for True/False, you may specify labelFunction for the dropdownList.
    In MXML:
    <s:DropDownList labelFunction="myLabelFunction" />
    In actionscript:
    private var arr:ArrayCollection = new ArrayCollection(["true","false"]);
                private function mylabelFunction(item:Object):String
                    if(item.toString() == "true")
                        return "yes";
                    else return "No";
    OR
    Solution2:
    may be u can try making an array collection like
    private var arr:ArrayCollection = new ArrayCollection([{label:"yes",value:"true"},{label:"no",value:"false"}]);
    and specify labelField for the dropdownList like
    <s:DropDownList labelField="label" dataProvider="{arr}" />

  • How can I display  contacts in a relationship

    I have companies in my CRM. I have a customers/contacts in the CRM I have tied as a relationship with each companies. How can I display all the records/contacts associated with a company? I have a already created a secure zone, so the company user would have logged in. Is this possible? If not, any workaround?
    The only workaround I thought of is to use webapp to import the company data and create another web app containing the employees data. Then link both tables/webapp using datasource. But the way the client's data is structured could create a lot of problems going forward.
    Any suggestion, help will be appreciated

    The relationship feature and how companies work currently in BC is really limited. It is an association and not true relationships at the moment. You cant output a company and show all its relationships at the moment.

  • How can I display & split the audio & video from the same digitized clip?

    I digitized a scene into iMovie that I edited on a professional system which I don't have access to anymore. The whole scene is 1 clip. Now I see a few tweaks that I want to make, so I was hoping to do them in iMovie.
    I want to "pull up" the audio in one section - meaning I want to take cut about 20 frames of audio from the end of a shot, and then move all the other audio up to fill the hole. To compensate for the missing 20 frames, I'll cut video off the head of the next shot. Some call this prelapping. Some call it an L-cut. Some call it asymmetrical trimming. Either way, I can't figure out how to do it in iMovie.
    My clip appears in the timeline as one track - a single track that contains the video and 2 audio tracks. How can I display the audio that's tied to the video on its own track? Then I think I could split audio & video wherever I wanted and trim things up - but I can't figure out how to do it.
    Am I asking too much of this software?
    BTW, I never see the option to "Split audio clip at playhead". I'm not displaying clip volume or waveforms. Choosing to display waveforms doesn't show me anything. Maybe iMovie thinks I'd only want to see waveforms of audio that isn't tied to my video-and-audio clips?
    Thanks in advance for any help...

    Jordon,
    "Am I asking too much of this software?"
    No, you're not.
    You first want to select your clip(s) and choose Advanced>Extract Audio.
    This will copy the audio from the video clip and place it on one of the two separate audio tracks while lowering the audio level to zero in the original video track.
    You can now edit and move the audio independently of the video.
    With the audio clip selected, you'll find you now have access to Edit>Split Selected Audio Clip at Playhead.
    Matt

  • How can i display a list of all the names stored in the Mail app?

    When sending an email, the program shows a list of names according to the first and subsequent letters that I type into the To: field. There are times I cannot recall someone's email user name. How can I display a complete list of all the names Mail has stored? I know that I can go to the To: field then type in the letter A, then write down all listings under A, and then repeat for each letter of the alphabet, but there should be an easier method.
    I have perhaps dozens of names in Mail, but only five names in Address Book, so the latter does me no good.

    On the menubar, Mail > Window > Previous Recipients
    Regards,
    Captfred

Maybe you are looking for

  • Dual Monitors Windows 7 Problems

    Ok, this problem is getting really annoying and I think its a problem with windows 7 itself and not my computer. Basically I have a dual monitor setup with the left hand monitor as my secondary and right hand monitor as my primary.  Whenever I have a

  • Components will not resize correctly in Catalyst

    Download PSD: http://dl.dropbox.com/u/814249/campusariel.psd Download FXP: http://dl.dropbox.com/u/814249/campusariel.fxp I am completely new to Flash Catalyst (any and all versions). I am currently using Photoshop CS5.5 to design and Catalyst 5.5 to

  • ITunes won't launch on Windows 7.

    iTunes no longer starts on my Windows 7 box. It will start in "safe" mode, ie if I cntrl-shift click on iTunes, it will start. Quicktime is not installed. The directory: C:\Users\username\App Data\Roaming\Apple Computer\iTunes\iTunes Plug-ins\ is emp

  • System not allowing to post parked vendor invoice

    Hi gurus, Why system not allowing to post parked vendor invoice when workflow is used for gl document????? It is saying not released and no one is allowed to post??? Thank you

  • Extracted ear/war/jar file location in JBoss

    How can I find out in runtime where JBoss extracted my ear/war/jar file? I have a file inside my ear/war/jar file and I need to know the location of the file. I know that it is in the tmp/deploy directory but I need the exact application temporary na