Combine multiple record column valus into 1

Hi All,
When I run a simple sql
Select C1,C2,C3 from Tab; I get these values
x,y,1
x,y,2
x,y,3
x1,y1,8
x1,y1,10
How do I these to show up like this
x,y,(1,2,3)
x1,y1,(8,10)
using only SQL query
Appreciate any ideas.
Thanks.

This is one of the most commonly asked question on this forum. Search for Pivot queries. It is possible in SQL only if we know the maximum number of values for any group (x,y group in this case has 3 values). If we do not know this, it has to be a PLSQL solution. Hope this helps.
SriDHAR

Similar Messages

  • Combining multiple records into a single record (View)

    Okay so here is my scenerio:
    There is a table I have made that details SQL jobs and the various details about them. What i wan't to do is make a view with specific logic implemented. Fields that will be taken across to this view will be: LastRunDate, LastRunTime and Step_Status.
    JobName will also be used to define the logic but will not be a column in itself.
    What i wan't is an additional column using this logic, called 'DataSet'. For each Dataset there are multiple jobs that are unique to it, so there are multiple records being brought over from the table to view for one particular dataset. For example,
    for 'ExampleDataSet' there are three jobs, i wan't it so these jobs are combined and named as 'ExampleDataSet' under a calculated column called 'Dataset'. For the following fields i would like it so that LastRunDate and LastRunTime are the time in whichever
    job was last to be intitiated is the date and time set. For Step_Status, there are three possible results, 'Running', 'Failed' or 'Succeeded'. If any of the three jobs are 'Running', then 'Running'. If neither are running yet one has failed then 'Failed'.
    Only when all three have succeeded should it then be set to 'Succeeded'.
    I hope i have made that clear enough, please feel free to ask any questions if not. I am relatively new to SQL but i thought to at least try least try (I knew it wouldn't work) and it didn't work. But it may give you a better idea of
    what i wan't:
    CREATE VIEW [dbo].[vw_DataAvailabilityAnalysts] AS
    SELECT CASE
    WHEN JobName in ('Job1','Job2','Job3') and step_status='Running' THEN 'Running'
    WHEN JobName in ('Job1','Job2','Job3') and step_status='Failed' THEN 'Failed'
    WHEN JobName in ('Job1','Job2','Job3) and step_status='Succeeded' THEN 'Succeeded'
    END as StatusCheck,
    CASE WHEN JobName in ('Job1','Job2','Job3') THEN 'ExampleDataSet'
    END as DATASET,
    LastRunDate,
    lastruntime,
    step_status,
    FROM [CDS_Common].[dbo].[DataAvailability]
    Many Thanks,
    Plain_Clueless
    Plain_Clueless

    Okay so here is what my table looks like (Simplified). There are four columns and the data within is extracted via a Stored Procedure.
    JobName
    LastRunDate
    LastRunTime
    Step_Status
    Job1
    11/06/2014
    09:30:00
    Succeeded
    Job1
    10/06/2014
    09:37:20
    Succeeded
    Job2
    11/06/2014
    04:05:00
    Succeeded
    Job1
    09/06/2014
    02:17:41
    Succeeded
    As you can see there are 3 jobs which are all 'Job1'. This jobs are obviously different within the table however this represents that they are jobs which all update the same DataSet within our local warehouse. Whereas Job2 updates a different dataset alltogether.
    I wan't to create a view which will alagmate the jobs that are of the same DataSet, which will disclude the column JobName but would create a whole new column that looks like this:
    DataSet
    LastRunDate
    LastRunTime
    Step_Status
    DataSet2
    11/06/2014
    04:05:00
    Succeeded
    DataSet1
    11/06/2014
    09:30:00
    Succeeded
    Bascically what this shows you is all the Job 1's combined so they are one record, Amaglamated. The last time any of these jobs were run is the LastRunDate & LastRunTime, which was the first record in the first table provided. Again for Step_Status,
    there are three possible results, 'Running', 'Failed' or 'Succeeded'. If any of the three jobs are 'Running', then 'Running' (Absolute). If none of the three jobs are running yet one has failed then 'Failed'. If one has failed yet another is also running then
    'Running'.Only when all three have succeeded should it then be set to 'Succeeded'. (This last bit isn't as important).
    Hope this clears it up a bit,
    Plain_Clueless
    Plain_Clueless

  • Combine Multiple Records in Crystal Reports

    I have a table with our clients buying preferences, The first three columns is the client ID, Name and Last name and the fourth and fifth columns is the clients buying preference, I have multiple records per client depending on the preference the client has chosen.
    ID First Name Surname Type Suburb
    5 John Smith House Melrose
    6 John Smith House Rosebank
    7 John Smith House Kilarney
    8 John Smith Cluster Melrose
    9 John Smith Cluster Rosebank
    10 John Smith Cluster Kilarney
    I need to combine the fourth column into one string and the same for the fifth column.
    ID First Name Surname Property Type Suburb
    5 John Smith House, Cluster Melrose, Rosebank, Kilarney
    I have been getting closer by using the formula in a similar post,  Combine Field from Multiple Records
    but still struggling a bit
    Any help with this would be greatly appreciated.

    Thank you so much, I was a bit blind there. That works brilliant for one client,
    As I was saying yesterday, that was just one client of many in my report, What do I do in the case of multiple clients...
    ID     First Name     Surname     Property Type     Suburb
    5     John     Smith     House     Melrose
    5     John     Smith     House     Rosebank
    5     John     Smith     House     Kilarney
    5     John     Smith     Townhouse     Melrose
    5     John     Smith     Townhouse     Rosebank
    5     John     Smith     Townhouse     Kilarney
    6     Jack     Black     Cluster     Sandton
    6     Jack     Black     Cluster     Houghton
    6     Jack     Black     Cluster     Fourways
    6     Jack     Black     Appartment     Sandton
    6     Jack     Black     Appartment     Houghton
    6     Jack     Black     Appartment     Fourways
    obviously if I use that formula, with many records the following happens, before I suppress...
    ID     First Name     Surname     Property Type     Suburb
    5     John     Smith     House     Melrose
    5     John     Smith     House     Melrose, Rosebank
    5     John     Smith     House     Melrose, Rosebank, Kilarney
    5     John     Smith     House, Townhouse      Melrose, Rosebank, Kilarney
    5     John     Smith     House, Townhouse      Melrose, Rosebank, Kilarney
    5     John     Smith     House, Townhouse      Melrose, Rosebank, Kilarney
    6     Jack     Black     House, Townhouse, Cluster     Melrose, Rosebank, Kilarney, Sandton
    6     Jack     Black     House, Townhouse, Cluster     Melrose, Rosebank, Kilarney, Sandton, Houghton
    6     Jack     Black     House, Townhouse, Cluster     Melrose, Rosebank, Kilarney, Sandton, Houghton, Fourways
    6     Jack     Black     House, Townhouse, Cluster, Appartment     Melrose, Rosebank, Kilarney, Sandton
    6     Jack     Black     House, Townhouse, Cluster, Appartment     Melrose, Rosebank, Kilarney, Sandton, Houghton
    6     Jack     Black     House, Townhouse, Cluster, Appartment     Melrose, Rosebank, Kilarney, Sandton, Houghton, Fourways
    obviously if I have to suppress, NOT ONLASTRECORD
    I have the following result...
    ID     First Name     Surname     Property Type     Suburb
    6     Jack     Black     House, Townhouse, Cluster, Appartment     Melrose, Rosebank, Kilarney, Sandton, Houghton, Fourways
    Where as the result I desire is
    ID     First Name     Surname     Property Type     Suburb
    5     John     Smith     House, Townhouse      Melrose, Rosebank, Kilarney
    6     Jack     Black     Cluster, Appartment     Sandton, Houghton, Fourways
    Is there anything I can do to get this result?

  • How to combine multiple purchased aac files into one aac file

    I recently purchased in iTunes an album consisting of 16 m4a files.  I ended up creating a playlist in iTunes for the songs.  I would like to create one m4a file which combines all and then play it in iTunes.  Is the copy protection preventing me from doing so?
    I know how to convert m4a files that I have converted to mp3 and combine them using Terminal with a cat command.  Then I import that combined file into iTunes.  All is well in this case.  I tried this with the 16 m4a files and I could not import the resultant mp3 file into iTunes.
    Any way to combine multiple purchased aac files?

    A simple way to accomplish the job, though not recommended is to print the 2 page file to a new PDF with multi-up (assuming you select vertical rather than horizontal locations) and adjust the paper in the Adobe PDF printer to be 8.5X22. At least you might give it a shot. Some variation, along with rotation possibly, might work.

  • How do I combine multiple single pdf's into one pdf document w/ multiple pages?

    How do you combine multiple single page pdf's into one pdf document w/ multiple pages?

    Hi Sandra,
    You have ExportPDF subscription from Adobe which would not combine files for you. It is only used to convert PDF into different formats.
    For Combining PDF you might to purchase the different subscription : PDF Pack
    Let me know if you have any other question
    Regards,
    ~Pranav

  • Multiple record data merge into paragraph styles-applies the wrong style

    Hi, I've been working on this project for sometime and everytime I manage to get one part of the workflow to work another seems to break. My agency publishes catalogs in multiple formats: large-print, audio, braille, and HTML. I've been trying to redesing our work process so that the catalogs will be laid out from merged data out of comma-separated file. The data merges have worked fairly well in Word, but InDesign is a challenge. I'm merging multiple records on a page, like a mailing label. The paragraphs need to be formatted and I'm trying to apply a paragraph style to them. After much work, I think I've finally got the data merge to work correctly, but the wrong paragraph styles are applied. I'm going to apply a new master page to the data once the data is merge that uses the paragraph styles for text variable running headers and I need to build a table of contents based on the paragraph styles so I need this to work. Attached are some screenshots.
    Master page set up for data merge with paragraph styles:
    Here is the merged document with the wrong paragraph styles applied:
    I have only a few weeks to get this process ironed out to keep to our rigorous production schedule. If anyone can help I would really appreciate it.
    thanks,
    Lina

    I don't remember this happening in past versions. But I mainly use XML. And a quicky test converting your file to XML worked fine (and besides, it ends up all in continuous text frames...).
    I don't do much GREP. But you can do this via a Find/Replace.
    First, in your main document, you can delete the tags--but do this on a second copy of your working file!
    Change your Content Placement options to not remove blank lines (these are in the Datamerge panel).
    Then after the merge, change the format of the two blank lines at the beginning of the records without the two lines of data:
    Note the Change Format style is changing those two paragraphs to Title.
    Then rerun the find to remove the two blank paragraphs.
    I suspect this can be done easier. I am sitting awaiting an appointment and cannot go much further than this for now, sorry.

  • Combine 2 specific column values into one column

    Is there an easy solution to combine column values that is in a group?
    In my report I have 1 column group named Activity_Area which has 5 different values Activity 1, Activity2...Activity5.
    Let's say I want to merge Activity 4 and Activity 5 and call it ActivityX and gives me the output as below
    Activity 1 | Activity 2 | Activity 3 | ActivityX

    Hi Jhonny86,
    According to your description, you create a field in database and it contains five values. Then you want to only display four values in report column group, and the last two values should be replaced by “ActivityX”, right?
    In your scenario, you can create an table like below:
    create table Act(id int,activity varchar(99))
    insert into Act select 1,'Activity 1'
    insert into Act select 2,'Activity 2'
    insert into Act select 3,'Activity 3'
    insert into Act select 4,'Activity 4'
    insert into Act select 5,'Activity 5'
    Then query the table with code like below in query designer, then add the field [Act] into the column group.
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • Store refusing to combine multiple BB gift cards into one

    Hi,
    I have few egift cards which can be used in-store or online. I want to combine them into one to keep track easily.
    I went to BB store in Milpitas CA, and the store manager rudely told me that I can't combine gift cards.
    Please let me know if I could get the egift cards combined?
    Thanks!

    Good morning anjulg,
    With so many e-gift cards, I can understand that it may be difficult to manage all of them and keep balances in order. Typically, customers are able to redeem up to 15 gift cards in store, and 10 on BestBuy.com. While the limitations of how many gift cards you may purchase at one time is much lower, you should also note that the limit for a balance on a gift card is $2,000.
    I’m sorry to hear you had trouble combining your e-gift cards at our Milpitas, CA store, and for any rudeness you may have encountered. However, the store would have been correct in denying the combination of your e-gift cards, as transferring the value is outside the E-Gift Card Terms and Conditions. You may view these terms and conditions here. You may also want to check out the Gift Card Terms and Conditions on BestBuy.com.  
    I apologize for any disappointment this may cause you. If you should have any other inquiries or need further assistance, please let me know.
    Regards, 
    Tasha|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Easy or otherwise: combining multiple complex ivideo projects into one

    I'm tempted to [finally] invest in fcp--just a matter of time--but at this particular moment (urgency) the decision would be made for me if I was sure I could do the following, which in imoviehd has proven well nigh impossible. I have six movie projects, each rather complex, that I want to combine into one movie project (for dvd purposes of letting viewer watch the whole movie straight through, in addition to watching each movie [chapter] separately). I've tried several ways to drag and drop the elements from one imovie project into another, but it is not working at all (the transfer starts out okay, but then it indicates the transfer will be, ahem, several thousand minutes to complete. The movies are between 2 and 88 GB, total run time for all six is 37 minutes.
    I guess my question is whether someone can tell me that there's an easier way to do this in fcp.
    thanks for any edification.

    This is stupidly simple in FCP, and authoring the dvd you want is stupidly simple in DVDSP.
    I've never used imovie, so I've no idea how that works, but in fcp it's a simple copy/paste from one sequence to another until they're all strung together.
    But I dunno how to get your material out of imovie and into fcp unless you export the finished pieces, convert them to .mov instead of .dv and import those.

  • Combining multiple small .pptx files into one larger .pptx

    So I'm a newbie when it comes to powershell and can't figure this out.  Here's the scenario, I have a file named "Multi organization.pptx" in a directory, within this directory I also have sub-directories labeled "Organization 1",
    "Organization 2", etc.  I have a .csv file with the correct order to place the organizations in the  multiorganization.pptx.  What I need powershell to do is search each of these sub-directories for their .ppt or .pptx take the entire
    presentation and place them in the "Multi organization.pptx" in the order they are listed in the .csv and if there isn't a .pptx in the sub-directory then it should skip that one and move to the next item in the .csv.  
    A couple notes all the slides are 16:9 ratio and must keep source formatting.  The script should also know to search for .ppt as well.

    Well below is what I have developed so far.  I need assistance pulling ppt's based on the CSV name (so organization 1 folder would have organization 1 ppt in that folder).  All these ppts are custom layouts, which could make this rather arduous.  Also need assistance with pulling all slides from given presentation and putting them in the Multi-organization.pptx.  I figure if I get help developing a solid code here, then it may be easier for the Powerpoint developers forum to assist. #Set office to Open
    Add-type -AssemblyName office
    $Application = New-Object -ComObject powerpoint.application
    $application.visible = [Microsoft.Office.Core.MsoTriState]::msoTrue
    $slideType = "Microsoft.office.interop.powerpoint.ppSlideLayout" -as [type]
    #Specify path
    $path = "Multi-organization.pptx"
    #Import CSV and Tell PS to get specified pptx files
    #Need CSV Command to pull pptx's based on CSV object
    Get-ChildItem -Path $path -Include "*.ppt", "*.pptx" -Recurse |
    ForEach-Object{
    $presentation = $application.Presentations.open($_.fullname)
    $customLayout = $presentation.Slides.item(1).customLayout #Need to know how to grab all slides
    $slide = $presentation.slides.addSlide(1,$customLayout) #need command to place slides in consecutive order from CSV pull.
    $presentation.SaveAs()
    $presentation.Close()
    "Modifying $_.FullName"
    $application.quit()
    $application = $null
    [gc]::collect()
    [gc]::WaitForPendingFinalizers()One thing I did notice was the slide pulled the layout and inserted only one slide but left out the text box and words.  Will the words need to be added after the script runs?  If so it seems to defeat the purpose of automating the task.

  • Combine multiple web services with the same SQL query into one

    Hello,
    I would like to ask a question regarding combine multiple similar web services into one. Can you please tell me if it is possible to combine 4-5 web services into one since they built on the same SQL query with 5 different criterias or condition so that the user can enter any of the 5 criterias to populate the data on the form instead of having 5 different web services?
    e.g Query: Select appName, permit#, address, phone, description, type, section, from table where appName = can be 'appName, permit#, address, phone, or description' to populate the rest of the data to the form.
    Does any one have ever done some thing like this in Workbench ES? If so please assist. I know it can be easier to build it in Visual Basic, C#, or dot.net but the requirement is to build it in workbench ES.
    Thanks in advance,
    Han Dao

    If you are querying for Name, PhoneNumber, and SSN, and you queried for all people with a phone number that started with 867, you would have a potentially long list of people.  So to keep track of all of the people, we store each record in XML complex elements.  The root node is just any name you want, and the repeating element is the complex element name. 
    So using the example from above, I'm going to specify the following:
         Root Node: Result
         Repeating Element: Person
    So now when I do a query, my resultXML will look like:
    <Result>
          <Person>
                 <Name>Alex</Name>
                 <PhoneNumber>867-5309</PhoneNumber>
                 <SSN>111-11-1111</SSN>
          </Person>
    </Result>
    If your query returned multiple results (like ours would probably), it would look like:
    <Result>
          <Person>
                 <Name>Alex</Name>
                 <PhoneNumber>867-5309</PhoneNumber>
                 <SSN>111-11-1111</SSN>
          </Person>
          <Person>
                 <Name>Han</Name>
                 <PhoneNumber>867-2169</PhoneNumber>
                 <SSN>222-22-2222</SSN>
          </Person>
    </Result>
    So Result and Person is just to give a little bit of structure to the xml result (containers really).  So you can name them whatever is helpful for you.
    The column name mappings map the query columns (Name, PhoneNumber, SSN) to some node in the XML (Name, PhoneNumber, SSN).  So you don't need to specify which field maps to what in the form.  Just copy the column names to the element name so you have a 1-to-1 naming.  If you want to manipulate the XML a bit though, you could do:
    Column Name               Element
    Name                            YourName
    PhoneNumber                Phone
    SSN                              Secret
    which would then make your xml look like:
    <Result>
          <Person>
                 <YourName>Alex</YourName>
                 <Phone>867-5309</Phone>
                 <Secret>111-11-1111</Secret>
          </Person>
    </Result>
    It lets you change the XML element names to whatever you want. Otherwise by default they take on their column names.
    In your form, you could bind to the WSDL through the Data Connections pane and point it to your web service.  This will then create form elements that you can just drag and drop allowing you to have the information available when the service gets ran.  Once the service is called, you can modify the field's data to get whatever information you need in order to populate other form fields. 
    If that is too confusing, feel free to send me your form (e-mail is on profile page) and I'll add comments to it to show you how to set up the form for the web service call (and also give me the link to your webservice)

  • Need help combining multiple audiobook cds into single mpeg file for Ipod

    I have been unable to find an application that will let me combine multiple MPEG audio files into a single MPEG file. My goal is to combine several CDs from an audiobook into a single file so that I can listen to it on my Ipod. Also, it would take up a lot less space as an ITunes listing. Mediajoiner was recommended on some other forums, but I could not find a version that worked with OS X and Java 1.5.
    Any help is appreciated

    [MP3Trimmer|http://www.deepniner.net/mp3trimmer>

  • Multiple records in BPM using Switch

    Hi Frnds,
                  I was doing File to RFC to Webservice sceanrio using multiple records.
    For that i have used
    ReceiveTransformation-Block(ForEach)-Send Sync-ContainerEndBlock-TransformationSendTransformation(Multimapping)-Block-switch-sendsync-containerendblock-Transformation---send.
    In switch, i was checking the condition like, if the material is present, then it got the first branch or else it should go to next branch.
    In switch i was facing the problem, if i give multiple records with the same value, i am getting the output. If i give different values like for one record, material is present and the other record material is not present, then i am not getting the output.
    Could you please help in this issue.

    In switch i was facing the problem, if i give multiple records with the same value, i am getting the output
    The standard behaviour of Switch is that in case of multiple records, the Last Record value is taken and checked with the switch condition.
    U break all the records into individual records usinf "Recordset per message = 1" or transform one message with multiple records into multiple records, save it into multiline container variable and then use Block with mode ForEach.
    Regards,
    Prateek

  • How to combine multiple files in CS6

    I am trying to combine multiple files-- book chapters-- into a single editable document in CS6. Tutorials apprea outdated

    following on from Sandee Cohen's post no.18, the location of the script has moved to:
    http://www.simonwiscombe.com/indesign-merging-all-files/
    and it is worth noting that the script initially merged files that were all 1pp long each.
    Simon did make a modification to it later on in the article so that the script would merge files of all lengths, but when I ran the script, it produced an error to do with line 18. The line:
    var sourceFolder = Folder.selectDialog(“Select a folder with source InDesign files.”);
    needs to be replaced with
    var sourceFolder = Folder.selectDialog('Select a folder with source InDesign files.');
    (double quotes were swapped out for single quotes)
    I have only tested the script with varying page lengths with minimal objects on the pages to determine if the files merged. So far so good. The earlier version that merged 1pp files only would fail if fonts/links were missing as any dialog box upon opening seems to interfere with the script. I feel that the newer script will do the same thing.
    I know this is an older thread but given I just had the same experience, I thought the revised script would help a few people.
    Colin

  • Is it possible to do a multiple-records data merge that doesn't generate multiple text boxes?

    Is it possible to do a multiple-records data merge that doesn't generate multiple text boxes? And if so, how?
    For publications such as a directory with contact information, it would be easier to manage the layout by merging multiple records into one text box. However, it seems like the only option in InDesign is to merge the records into each of their own text boxes.

    No, but it's possible to stitch the frames together after the merge, then reflow.  See Adobe Community: Multiple record data merge into paragraph styles-applies the wrong style

Maybe you are looking for