How to show three more than one row as single row

for example there are two tables employee and department.
emp id dept_id
101 1
101 2
101 3
Due to different dept id i am getting three rows for same emp id. Is there anwyay i can show one row and all three departments into one line.
output like this 101 1/2/3
Please help!
Thanks

864470 wrote:
However, I am not getting any distinct values for that.Are you sying there are multiple records for same emp_id, dept_id combination? If so:
SQL> with t as (
  2             select 101 emp_id,1  dept_id from dual union all
  3             select 101,2 from dual union all
  4             select 101,2 from dual union all
  5             select 101,3 from dual
  6            )
  7  -- end of on-the-fly data sample
  8  select  emp_id,
  9          rtrim(xmlagg(xmlelement(d,dept_id,'/').extract('//text()') order by dept_id),'/') dept_list
10    from  t
11    group by emp_id
12  /
    EMP_ID DEPT_LIST
       101 1/2/2/3
SQL> with t as (
  2             select 101 emp_id,1  dept_id from dual union all
  3             select 101,2 from dual union all
  4             select 101,2 from dual union all
  5             select 101,3 from dual
  6            )
  7  -- end of on-the-fly data sample
  8  select  emp_id,
  9          rtrim(xmlagg(xmlelement(d,dept_id,'/').extract('//text()') order by dept_id),'/') dept_list
10    from  (
11           select  emp_id,
12                   dept_id
13             from  t
14             group by emp_id,
15                      dept_id
16          )
17    group by emp_id
18  /
    EMP_ID DEPT_LIST
       101 1/2/3
SQL> SY.

Similar Messages

  • Please help with an sql to show more than one records into single row for each student

    From the following data I would like to create an sql to get the information  as the following layout
    studentid,  firstTerm,  EnglishMark1,ScienceMark1,MathsMark1, Secondterm,EnglishMark2,ScienceMark2,MathsMark2,
    ThirdTerm,EnglishMark3,ScienceMark3,MathsMark3 // As single rows for each student
    Example
    1 First, 30,40,20,Sec,30,40,20,  simillarly next row for next row for another sudent. Please help to generate the sql for the same.
    Please help it would be very appreciate.
    With Thanks
    Pol
    polachan

    create table yourdata (studentid int, term varchar(10), section varchar(50), Mark int)
    insert into yourdata values
    (1,'First','Math',20),(1,'First','English',30),(1,'First','Science',40),
    (2,'First','Math',20),(2,'First','English',30),(2,'First','Science',40),
    (3,'First','Math',20),(3,'First','English',30),(3,'First','Science',40),
    (1,'Sec','Math',20),(1,'Sec','English',30),(1,'Sec','Science',40),
    (2,'Sec','Math',20),(2,'Sec','English',30),(2,'Sec','Science',40),
    (3,'Sec','Math',20),(3,'Sec','English',30),(3,'Sec','Science',40)
    Select studentid
    ,max(case when term='First' and section='English' Then Mark End) as EnglishMark1
    ,max(case when term='First' and section='Science' Then Mark End) as ScienceMark1
    ,max(case when term='First' and section='Math' Then Mark End) as MathMark1
    ,max(case when term='Sec' and section='English' Then Mark End) as EnglishMark2
    ,max(case when term='Sec' and section='Science' Then Mark End) as ScienceMark2
    ,max(case when term='Sec' and section='Math' Then Mark End) as MathMark2
    ,max(case when term='Third' and section='English' Then Mark End) as EnglishMark3
    ,max(case when term='Third' and section='Science' Then Mark End) as ScienceMark3
    ,max(case when term='Third' and section='Math' Then Mark End) as MathMark3
    From yourdata
    Group by studentid
    drop table yourdata

  • I have songs from icloud showing on more than one device but only want them on one so how do i delete them

    Can some tell me how i can not have the songs showing on more than one device for my account

    Krshrtr wrote:
    it wont let you swipe to the left on songs that have the cloud next to them
    That's correct - it only deletes them from your phone, not from iCloud
    If you go into Settings, Music and set Show All Music to Off, you will only see the songs that are actually on the phone.
    One other tip - once you've deleted the songs/lists you no longer want, restart the phone (hold the Home and Sleep buttons for about 10 seconds until the Apple logo appears) to make sure the songs are gone.

  • How do you delete more than one row on numbers?

    how do you delete more than one row on numbers?

    Hi operatorcarmax,
    Select the Rows (shift click works for me). Then hover the cursor over any selected Row label to see the upside-down triangle. Click on it to see a Pop-up menu.
    The Numbers User Guide is available for download under the Numbers Help Menu. A good read.
    Regards,
    Ian.

  • How can i put more than one item in a same row of a form?

    guys!
    it seems item is positioned in a single row one by one each time item is appened to a form. i can't append more than one item in same row.
    i'm using sun wtk and default colored phone emulator.
    xxxx

    Hi,
    It is not possible to have more than one combo in the source frame. This is because frame drivers can take only
    two columns in the sql query, one is the display value and the other the return value.
    Thanks,
    Sharmila

  • How can I pass more than one parameters in PDK-URL services?

    Hi all,
    How can I pass more than one parameters in PDK-URL service? All samples on Portal Center shows just one parameter passing.
    <inputParameter class="oracle.portal.provider.v1.URLPortletParameter">
    <name>csz</name>
    <isMandatory>false</isMandatory>
    <displayName>What location do you want a map for (City, State or Zip)?</displayName>
    </inputParameter>
    How can I write the privider.xml file for passing multiple parameters?

    I answer to my question. I've got the answer.
    I repeatly write down the <inputParameter> tags, and it works.

  • How can I select more than one song from the search results?

    I want to create playlists based on certain words in the song title. For example, I may want to create a playlist of all my songs with LOVE in the title.
    Doing the search is easy, but I can't select more than one song at a time. Is there any way in iTunes 12 for Windows to do this? I found an answer in iTunes for Mac, and it basically says to "un-check "Search Entire Library." " but I don't see that option in iTunes for Windows.
    Here is the link to that question: how can i select more than one song from drop down search bar
    I hope some Windows user can help me out.

    Found the "Search Entire Library" option - click on the small (VERY small for my eyesight) down arrow next to the magnifying glass. Also need to select "Filter by: Songs", and then the songs in the main window show the results.
    I'm going to leave this up on the board because 1) in case someone else has this question, and 2) I don't know how to delete it anyway.

  • Cant listen to more than one song in a row with ios4

    Ever since i "upgraded" to the new ios4 software i can no longer listen to more than one song in a row without it stopping by itself. if im using apps while playing music it takes me back to the home screen. If someone knows how to fix this that would be nice bc im really frustrated with it and regret getting the software.

    But all of a sudden I cannot get my libraray or any playlist ti play more than one song at a time automatically. It just stops after each song.
    head into your itunes main library window. are all the little boxes to the left of your tracks unchecked?
    is so, hold down Ctrl and click on one of those boxes to recheck all the songs. (this may take a little time.)
    do you get continuous play once all the songs are rechecked?

  • Hello - how do I have more than one app window open at a time on OS X 10.9.1

    Hello - how do I have more than one app window open at a time on OS X 10.9.1?  I do not want to hold the option key to have multiple apps open on my screen.  Thanks.

    Barney-15E
    Finder enhnacements installed? = no.  I did a reinstall of Mavericks, not a full clean install = no help. Searched for "single-app mode" in Spotlight and the web, no luck.
    With Safari open on screen, from dock, opened iTunes and Safari does not show on screen.  Open Word from doc and iTunes is not on screen. 
    Attached some screen shots if these help.

  • How can I add more than one same spry menu (eg. collapsible menu)  with in different styles (font size, color, background, etc) on current page?

    How can I add more than one same spry menu (eg. collapsible menu)  with in different styles (font size, color, background, etc) on current page?

    Hi Nancy,
    This screenshot was only for imagination. A part of the code (not all) is below.  In the code there are some background images but they are not seem in live mode.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="css/my_site.css" rel="stylesheet" type="text/css" />
    <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css"/>
    <link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
    <script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
    <style>
    #CollapsiblePanel1 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-color: #003366;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel1 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        line-height: 52px;
    #CollapsiblePanel1 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/international.jpg);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel2 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelContent {
        background-color: blue;
    #CollapsiblePanel3 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel3 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel3 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel4 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel4 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel4 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel5 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel5 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel5 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    </style>

  • How can I buy more than one item at a time?

    How can I buy more than one item at a time i iPhote fx a book and a calander? It would be nice to place one order and only pay for the shipping once!

    You can't.
    Regards
    TD

  • How do I get more than one signature option in Fill and sign?

    How do I get more than one signature option in Fill and sign?

    Hi,
    Are you trying to place more than one signature on a PDF document?
    Please explain the workflow.
    Regards,
    Anand

  • How do you delete more than one photo at a time on Iphone 3gs camera roll?

    How do you delete more than one photo at a time on the Iphone 3gs camera roll?

    You can't.

  • How do I merge more than one PDF document into one singular pdf using adobe viewer touch on a microsoft surface?

    How do I merge more than one PDF document into one singular pdf using adobe viewer touch on a microsoft surface?

    Or using the Adobe PDF Pack https://www.acrobat.com/

  • How do I print more than one custom-size photo on a page in PSE 10?

    I recently upgraded from Photoshop Elements 6 to Photoshop Elements 10.  I make greeting cards, and on PSE 6 I was able to print two custom-size (6-1/2” x 5”) cards on each 8-1/2” x 11” sheet of photo paper.  The option to print more than one custom-size card on a single sheet of paper is not available in PSE 10.  I want to know how I can print more than one custom-size card (or photo) on a page in PSE 10?

    In Editor:
    File>Print>#4 Select type of print>picture package

Maybe you are looking for

  • Why all of a sudden do I have all sorts of windows open up in the middle of what I'm doing and it's almost impossible to close them out

    When I'm in the middle of a web page, all of a sudden I get 4 or 5 new tabs open up with Mozilla offers and to get them to close is a battle. Ever since Mozilla updated my version to a newer Firefox which I HATE( and it didn't even ask me if I wanted

  • Problem removing session attributes

    I have a problem removing session attributes I try w/ mysession.removeAttribute("key"); but it still lives in memory. I've tried setAttribute("key", null) as the API states that will do the same thing, but it doesn't work. I can get mysession.invalid

  • 10.5.7 Makes Aperture 2.1.3 FLY

    I have an old PowerMac G5 from Sept 2003 which I've upgraded over the years with RAM, a Radeon 800XT and larger faster internal SATA drives, but nothing comes close to the speed increases I see today after updating to Leopard 10.5.7 Easily 100% faste

  • General Ledger Report

    Hi Friends, When I am trying to run General Ledger reports , no data are being fetched by the report. Please help : I want to generate a Ledger Account report for all the Natural Accounts, showing the opening, closing and detailed account transaction

  • Will lumia 620 bought in france work in the US?

    I have a lumia 620 bought in France. I am moving to the US and would like to know if I get a new SIM card in the USA it will work? Or are they using different kinds of SIM cards? Thank you