To change the way of afficherdans the data using SQL

I have data as follows:

Name age
Tom 24
Harry 45
Mona 30


I want to convert these data in the way below

Name1, name2 Age1 Age2 Name3 3
24 45 30 Mona Harry Tom



How can I do the same thing using SQL?

Why not try to search this forum of 'PIVOT' to make this small change yourself?

SQL> set line 1000
SQL> WITH t AS (SELECT 101 empid,45 marks,8 rank FROM dual UNION ALL
  2             SELECT 101 empid,62 marks,7 FROM dual UNION ALL
  3             SELECT 101 empid,80 marks,2 FROM dual UNION ALL
  4             SELECT 102 empid,67 marks,5 FROM dual UNION ALL
  5             SELECT 102 empid,56 marks,6 FROM dual UNION ALL
  6             SELECT 103 empid,87 marks,7 FROM dual UNION ALL
  7             SELECT 103 empid,55 marks,9 FROM dual UNION ALL
  8             SELECT 103 empid,60 marks,6 FROM dual UNION ALL
  9             SELECT 103 empid,70 marks,3 FROM dual
 10             )
 11  ---End of Sample Data
 12  ---Now the original query.
 13  SELECT empid, MAX(DECODE(rn1,1,marks)) Marks1,MAX(DECODE(rn1,1,rank)) Rank1
 14              , MAX(DECODE(rn1,2,marks)) Marks2,MAX(DECODE(rn1,2,rank)) Rank2
 15              , MAX(DECODE(rn1,3,marks)) Marks3,MAX(DECODE(rn1,3,rank)) Rank3
 16              , MAX(DECODE(rn1,4,marks)) Marks4,MAX(DECODE(rn1,4,rank)) Rank4
 17  FROM
 18     (SELECT empid,marks,rank,
 19      ROW_NUMBER() OVER(PARTITION BY empid ORDER BY marks) rn1
 20      FROM t)
 21  GROUP BY empid;

     EMPID     MARKS1      RANK1     MARKS2      RANK2     MARKS3      RANK3     MARKS4      RANK4
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
       101         45          8         62          7         80          2
       102         56          6         67          5
       103         55          9         60          6         70          3         87          7

SQL> 

Tags: Database

Similar Questions

  • How can I change the date used to filter the screen heat for a resource map?

    The dates that appear at the top of the heat map of resources are blocked on March 2014 until August 2014. How can I change these dates to see the current and future commitments to my resources?

    HeatMapDates.png

    To change the dates, you will need to save on the registration page and modify the advanced search criteria. These filter dates apply for the following clicks and pages of details when displaying resources.

  • How can I change the data used by a graph of a waveform depending on which tab is active?

    Hello

    First of all, I want to say thank you in advance!  Let me describe the situation a bit.  My front panel VI (see attachment) has a tab control and on each tab of the window, I have a graph of intensity with a free drag cursor.  On the tab control window that I try to display the row or column of data where the cursor is, I can do this for each in the intensity chart individually.  I'm trying to clean up the block diagram a bit and instead of using 4 waveform graphs, I want to use one, can the data that is displayed in the graph of the waveform are associated with which page is active in the tab control.  Is this possible?  And how can I do?

    Thank you once again,

    ~ Daniel DeWitte

    Thread just the terminal tab to a case structure, switching data going graphic terminal

    (Sorry, message by phone, can not look at your code...)

  • How to view clob data using sql

    Hello

    In our database we have a table that is to have a column of type CLOB but now I want to display the data using sql select query but it throws error: "unsupported data Type.

    Could someone let me know how to view the clob data using the select query.

    Oracle DB version: 10.2.0.3

    Thank you

    user562223 wrote:
    Hello

    In our database we have a table that is to have a column of type CLOB but now I want to display the data using sql select query but it throws error: "unsupported data Type.

    Could someone let me know how to view the clob data using the select query.

    Oracle DB version: 10.2.0.3

    Thank you

    Usually a to_char (CLOBDFIELD) circled

    HTH,

    FJFranken

  • Is there a way to change the date limit of the details page of Salesforce agreement once that agreement came out to the Signature?

    Currently, the only way to change your Salesforce is by going to "manage agreements." The problem is that the registration of Salesforce and echosign are more synchronized. Is there a way for users to go to the agreement and be able to change the date limit?

    Hi esluskonis,

    I'm sorry, but it is not possible to change the time of the signing of the document by using Salesforce.

    Kind regards

    Ana Maria

  • To change the data type of control/led

    Is it possible to change the underlying data type of the indicator or a control?  I a VI that I want to use that accepts any type of data (essentially data varriant) and display it accordingly.  I have different controls selected to display data of different types in the sense of data vs decimal boolean data vs integer, but certain types of data will be of type uint32 vs int16 vs uint64 etc..  Is it possible to programmatically change the data type, so I need to have all the combinations of indicators?

    The short answer is no. The long answer is that LabVIEW has not 'generic' controls that allow you to display any type of data (apart from the variant of course). There are several ways to address this problem, but all require you as the programmer to manage explicitly each type of data you could possibly meet. Here are some possibilities (in no particular order), please let me know if you would like to help a particular implementation of these.

    1. Force incoming data to variant, use the info option to determine the data type of the original data in a case structure (open G can do this VERY easy), have an indicator on the front panel for each type of data you want and hide those unused
    2. Use a sub-group of experts on the front panel and sub - vi call of to view specific types (that lends itself very well to encapsulate your data in a class and you leave OOP allows to expand into different types of data)
    3. Use a tab with the variant (similar to option 1) control put each kind of data in its own tab, enable only the current
    4. Do a Control-X to accept a Variant option 1 under the hood
    5. Just as a string of format and use a string indicator

    That's all I can think of right now, once again, let me know if you need more information/help on the options.

  • How can I change the date on photos with the Photosmart A646?

    How can I change the date on my photos when using the Photosmart A646 with Windows 7?

    It says 01/01/70. I explored all the options on the touch screen of the printer as well as the print on the computer properties screen and can't seem to find a way to change the date.

    If you took a picture with the turn date stamp feature then you can not change the stamp.

  • How to change the date in milliseconds

    Hello guys, I worked on a new project where the user add his birth date, I want some type of validation to check if the user is personal good brith 'date of day or the futuer even not", the user date conclude filed is in this format" "2013-07-05 to the validation that I change in milliseconds.". "

    Is it possible to change the date in this format in milliseconds?

    or any other way to make the validation

    Thanks for help

    After 2 hours, I'm dating a solution by myself, however the function can be customize to check if the user enters on the right date.

    function findtAge(subjectName,fromdate, todate) {
        console.log("findAge(fromdate, todate) is called now "+subjectName+"-->"+fromdate+"-->"+todate);
        if(todate) todate= new Date(todate);
        else todate= new Date();
    
        var age= [], fromdate= new Date(fromdate),
        y= [todate.getFullYear(), fromdate.getFullYear()],
        ydiff= y[0]-y[1],
        m= [todate.getMonth(), fromdate.getMonth()],
        mdiff= m[0]-m[1],
        d= [todate.getDate(), fromdate.getDate()],
        ddiff= d[0]-d[1];
    
        if(mdiff < 0 || (mdiff=== 0 && ddiff<0))--ydiff;
        if(mdiff<0) mdiff+= 11;
        if(ddiff<0){
            fromdate.setMonth(m[1]+1, 0);
            ddiff= fromdate.getDate()-d[1]+d[0];
            --mdiff;
        }
        if(ydiff> 0) age.push(ydiff+ ' year'+(ydiff> 1? 's ':' '));
        if(mdiff> 0) age.push(mdiff+ ' month'+(mdiff> 1? 's':''));
        if(ddiff> 0) age.push(ddiff+ ' day'+(ddiff> 1? 's':''));
        if(age.length>1) age.splice(age.length-1,0,' and ');
        console.log("===============================");
        console.log("Subject age is = "+age.join(''));
        console.log(" age Day = "+ddiff);
        console.log(" age Month = "+mdiff);
        console.log(" age Year = "+ydiff);
        console.log("===============================");
        var subjectAGE =  age.join('');
    
    }
    

    Thanks a lot guys for the helpful answers

  • script to change the data type of column

    Hi gurus of the oracle.

    I have 190 tables in my database.

    I have the column type CHAR of all these tables data.

    I need to change the data type of CHAR in VARCHAR2 for all these tables...

    There the script to change the data type of all tables at once?

    Please help me in this regard.

    Thanks in advance

    Concerning

    REDA

    Hello

    There is nothing built-in to Oracle SQL to do.  Maybe your front-end has certain characteristics.

    You can write dynamic SQL statements to do.  In other words, you can write a query that the output is a SQL script like this:

    ALTER TABLE TABLE_A CHANGE (A_TXT1 VARCHAR2 (5))

    A_TXT2 VARCHAR2 (10));

    ALTER TABLE TABLE_B CHANGE (B_TXT1 VARCHAR2 (5));

    with one row for each column of type CHAR.  Notice how the first line of output for each table begins with ALTER TABLE... but the later lines at the same table.  Similarly, the last line of a table (which will be the same as the first row, if the table has only one column of type CHAR) to end with a semicolon, but other lines are not.

    Here's a way to generate and execute such a dynamic script in SQL * more:

    -Disable the features that make the output easy to read, but hinder the execution
    SET FEEDBACK OFF
    SET LINESIZE 500
    SET PAGESIZE 0

    -Create fix_char.sql
    COIL c:\some_pathename\fix_char.sql

    SELECT THE CHECK BOX
    WHEN ROW_NUMBER () OVER (PARTITION BY table_name
    ORDER BY column_name
    )  = 1
    THEN 'ALTER TABLE ' | table-name
    || "CHANGE (").
    ELSE «»
    END
    ||        column_name
    ||        "VARCHAR2 (').
    ||        DATA_LENGTH
    ||        ')'
    ||        CASE
    WHEN ROW_NUMBER () OVER (PARTITION BY table_name
    ORDER BY column_name DESC
    )  = 1
    THEN '); "
    Output END AS
    Of user_tab_columns
    WHERE data_type = "CHAR".
    ORDER BY table_name
    column_name
    ;

    SPOOL OFF

    -Turn on the features that make the output easy to read, but hinder the execution
    SET FEEDBACK ON
    SET LINESIZE 80
    SET PAGESIZE 50

    -Fix_char.sql performance
    @c:\some_pathname\fix_char

    It's good to change all the CHARIOT of VARCHAR2 columns.  The CHAR data type is nothing trouble.

  • Change the data in Clone

    I don't know if it's possible, but I would like to ask whether it is in someways?

    I have to make a clone of the production database, but at the same time I don't want my production data are available on the clone? Is there a way I could change the data in the clone?

    Thank you
    Blabla

    Bhavi Savla wrote:
    I don't know if it's possible, but I would like to ask whether it is in someways?

    I have to make a clone of the production database, but at the same time I don't want my production data are available on the clone?

    some/many/most/ALL a clone is an identical reproduction of 100%.

    Is there a way I could change the data in the clone?

    This is your DB & you are free to do what you're capable of doing.
    What exactly do you intend to the modified data to be?

  • using case, but by changing the data type of diff

    Hi guys, I am creating a view and selecting in a column that has a value of-1, 0 or 1, it's very good and I was about to use a case statement to convert the - 1 to "n", but obviously I can't do what data types do not match, I can't change the data type of the original column until someone knows how I could achieve This or a similar output, for example, is there a way to add an extra column to the view and just copy the numbers to the horizontal except for when it is - 1, we will copy a "n" throughout. the new column might be char and we could convert the numbers to a char when their through copying. Is it possible to do and if so could someone explain or give me an example of how to do it.

    Thank you.

    An alternative to the above:

    case when col1 = -1 then 'N'
         else to_char(col1)
    end
    
  • Change the date format on a database level

    Hello

    I know how to change the date format on a per connection layer.
    Can I change something in the format once and for all on a level username / the oracle instance level?


    Thank you
    Maxim.

    The table below lists priorities of NLS parameter: http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/ch3globenv.htm#g1012681

    This is why many people say that the safest way to avoid the problem of date format is format of date, hardcode in every SQL statement. A logon trigger should also be an option if you are sure that the application doesn't runs another
    ALTER SESSION SET NLS_DATE_FORMAT = «...» ».

  • How can I change the date/time data (Sysdate) without changing the date of the BONE

    Hi all

    I have a need to change the sysdate to a database for testing purposes and need to fix the date of database at a date later (e.g., 30/06/2009). I have 2 other instances on the same server in order to change the date of the OS is not an option. I am familiar with the sysdate affecting a fixed value, but doing so changes the date to a constant because I still need time to elapse. I searched the forum and cannot find a way to do it. Any help would be greatly appreciated.

    Thank you

    Like this:
    ALTER SYSTEM SET FIXED_DATE = "."

    Published by: user503699 on May 14, 2009 21:13

  • Rename and change the date of the file on multiple files

    How to rename multiple files in pictures in a single operation like I did in iPhoto? The same question arises to change the filedate?

    I looked in the manual very rudimentary, and it seems to have disappeared. I think that pictures is a gradient iPhoto (I don't want to use a program with no future updates) and I'm not happy to trust pictures/iPhoto to archive all 18100 photos and videos in a single file which from time to time a photo or two disappears (will not help to repair the database file)

    I started using Adobe elements 14 Organizer to keep track of my files in a folder of my choice where my photos is located a file for each photo a week (feel safe) and Adobe Photoshop elements 14 to change files. He has a solution for my answers mentioned here, I have not found better (I tried AcdSee pro for mac but it is pretty unstable and limited in options)

    Come on Apple we give a new Photos with option not reinforced this low quality low option software

    You can't and you couldn't have in iPhoto, either - no change is possible for file names or file dates in a program

    Given that you want to not use pictures you have made the right choice - do not use in it, use a software you like - the software you use is your choice and you can change at will - but it is crazy to expect that Apple or someone else will change the software used and loved by millions just to meet your personal wishes

    And clearly, you have no idea how works same Photos - but because you don't like it don't is really no reason for you or for someone to try to explain it to you - just for a simple example - Photos put everything into one large file - it stores each photo in its own file using the same exact file used by each program Amc system including organizing Adobe

    You have made the right choice for you to use and enjoy - don't know why you even bother to post here

    LN

  • Why I can't change the dates of reminder in the calendar

    I was trying to extend a stay to add one day more to a reminder I had set up on my calendar, but couldn't stay.

    After changing the date it to show the dates of trip corrected for about 2 seconds and then return to the original date of travel.

    Any ideas as to why it is not working properly.

    Thank you

    Maybe this will help.

    Calendar may not enter the new event.

    Calendar may not enter the new event (2)

Maybe you are looking for

  • Satellite A505-S6973 - mute and eco utility buttons not respons

    Hello again everyone, I apologize for this but I have a question about my account record. I posted a question earlier where whenever I press the mute buttons and eco utility I get no answer (just a beep the button mute). I pressed the fn man icon and

  • How long the registration process generally takes for principal apple

    I signed up about two weeks ago and my Director has not been contacted nor have I received any kind of emails... we already have a configuration of DEP account and checked - but I don't have an ETA or idea, if something went wrong during registration

  • HP 15-p030nr Beats: buy a new motherboard

    My laptop has been overheating. I tried literally everything from checking for viruses to reapply thermal paste and I can't fix it. Here is a link to my post on the forum about this. http://h30434.www3.HP.com/T5/notebook-hardware-and-upgrade-question

  • SanDisk e250 I got a mirco SD card

    I had need of more memory so I got a 4 GB Micro SD card, it is part of the fine, but the memory of the reader does not change. I even tried to charge the card on my computer. It loads fine, but when I put it in my player it is not there to do I need

  • Reference Dell 8700 Sound only via HDMI, no catches

    Brand new Dell 8700, I can get sound via the HDMI connection but nothing since the headset plugs or the Green and black plugs on the back of the computer. Control Panel - sounds I can only see NVIDIA HDMI no options, Realtek no option at all. I tried