Group by and concat one column

Hello, i have a query that gives me the following results (example):
Column1 Column2
Madrid Product1
Madrid Product2
Madrid Product3
And my problem is that i want to have just one record with a group by for column1 and a concatenation of column2 like the following:
Column1 Column2
Madrid Product1/Product2/Product3
How can i do this?
Thanks.

            select column1, decode(acc, null, null, acc ||' , '|| ac) new_ac
         from
             ( select column1,
               column2 ac,
               lead(column2) over(partition by column2 order by column1) acc
               from table_name
                 

Similar Messages

  • Need to import csv and manipulate one column

    I have a monthly report output by an FTP program into CSV format. The CSV file has headers and 3 columns:
    1) a group name
    2) the number of transfers that group made
    3) the total size of all their transfers (in bytes)
    Example (with headers and 6 rows of data for 7 rows total):
    "monthly transfers","sum of monthly transfers","sum of file size"
    "group1 (Prod to Dev)","26","11556381672"
    "group2 (Prod to Dev)","5","348197396"
    "group3 (Prod to Dev)","14","1272913379"
    "group1 (Dev to Prod)","0","0"
    "group2 (Dev to Prod)","1976","2036311426"
    "group3 (Dev to Prod)","1","131"
    I have been asked to write a script that will convert the bytes to megabytes and then sort based on group name and export the new data so auditors (non-technical people) can review it.
    I've worked with Excel a bunch in Powershell (I.E. opening a com object and writing directly to a cell) and I'd prefer to do it that way, but the server this script needs to run on doesn't have MS Office installed and can't have anything else installed on
    it, so I'm trying to learn about import-csv and such. I've come up with this:
    $file = "C:\ftp\ftp_report.csv"
    $csv = import-csv $file
    $csv | sort "monthly transfers"
    The part I'm stuck on is converting that third column from bytes to megabytes. I know that in Powershell I can do "X / 1mb" to convert a number from bytes to megabytes, but I'm not sure of how best to do this in a specific column of a CSV file.
    Should I create a hash table? Should I count the number of rows and then do a "foreach" on
    $csv[0].'sum of file size' / 1mb
    Am I overthinking this and there's a really easy way to manipulate all values in a column?
    Thank you in advance.
    [email protected]

    Probably like this, right at the parameter:
    ("{0:N2}" -f ($row.'sum of file size' / 1mb))
    There's no place like 127.0.0.1

  • When creating a "lookup" column be able to display not only one column from the other list, but additional columns

    With the lookup technique, it is possible to select an item from another list and display one column of this item
    It is obviously possible to create several lookup columns on the same list and therefore display several columns
    There’s a high risk of not selecting the same item and therefore have inconsistent columns
    The Requirement therefore consist of being able of displaying several columns of the same item from the other list, based on one unique selection
    Example:
    In list(x), define lookup column on list (y), column Title (possible today)
    Then define a “secondary” lookup column on same list, column Code
    The effect would be that when selecting an item from list (X), both Title and Code would show up consistently in 2 different columns of list (Y)
    All possible solutions are welcomed

    If you are using SharePoint 2010, you can retrieve additional columns when adding a Lookup. If you are using 2007, there is no direct OOTB way, but the following two posts provide potential work-arounds:
    https://www.definitivelogic.com/blog/microsoft-sharepoint-2007-pulling-column-data-one-list-another-based-common-list-field
    http://stefan-stanev-sharepoint-blog.blogspot.com/2010/11/sharepoint-2007-associated-lookup.html
    Dimitri Ayrapetov (MCSE: SharePoint)

  • How do I add more than one column to a table using SQL?

    Hi
    I need to add 3 columns to a table using SQL
    the syntax
    "ALTER TABLE TEST ADD COLUMN newcol1 float";
    works fine - for adding one coumn only.
    For multiple columns I tried various permutations along the lines of
    "ALTER TABLE TEST ADD (COLUMN newcol01 float, COLUMN new2 float,COLUMN new3 float)";
    "ALTER TABLE TIPSTEST ADD COLUMN new1 float"
    "ALTER TABLE TIPSTEST ADD COLUMN new2 float"
    "ALTER TABLE TIPSTEST ADD COLUMN new3 float"
    etc., but this doesn't work.
    From a web search it sounds like SQL can only add one column at a time.
    I have a workaround : create intermediate temporary tables , copying data and adding
    one column at each stage. It seems a fairly awkward way of programming though.
    Am I missing something simple : is there a way to add multiple columns in one go?
    Thanks

    OK : solved an underlying problem with this one myself
    for the code
    String createString;
    createString =  "select COFFEES.* INTO NEWCOFFEES FROM COFFEES"; // example
              Statement stmt;
              try {
                   stmt = a_Globals.database1Connection.createStatement();
                          stmt.executeUpdate(createString);
                   stmt.close();
                   a_Globals.database1Connection.close();
              } catch(SQLException ex) {
                   System.err.println("SQLException: " + ex.getMessage());
              }                    commenting out the line:
    a_Globals.database1Connection.close();
    Allowed the subsequent SQL statement(s) to work OK. Looks like this was the cause of several
    difficulties, preventing me doing several SQL instructions in turn.
    Thanks for the responses.
    Mike2z

  • How to highlight only one column

    I am trying to highlight and copy one column but the one next to it is also highlighted.  Help!!

    I fear Klaus may be right about the doability of this in Safari.
    How about the following workaround? Don't have a Mac available at the moment, so it's a bit experimental.
    Do a "Paste with current style" in TextEdit of the entire table. (Fingers crossed, that should preserve the tab formatting of the entire table). Now copy the entire-table-stuff from TextEdit into a spreadsheet application like Numbers or Excel. Fingers crossed it'll show up in the spreadsheet as a table. Delete the extra columns from the table in the spreadsheet. Copy the single column back into TextEdit, delete the entire table-stuff. Klunky (assuming it works), but probably quicker than entering cells one at a time from Safari into TextEdit
    Suggesting doing it this way, because if you try copying an entire table directly from Safari into the speadsheet, it's got a nasty habit of stashing all the columns into a single column, which is not immediately helpful. If you're using Numbers on the Mac, it might be worth checking in over at the Numbers community to see if they've got workarounds for converting a "single-column-mess" produced by pasting from Safari into Numbers into a proper table. (I think Yvan might have a script for that, but I'm not sure.)

  • IBNS with two groups of XP Machines, one PEAP-MSCHAPv2 & one EAP-TLS

    Hello,
    I'm planning to implement a IBNS network. We have two groups of XP Machines. One group has machine certs and we're planning to check their certs using EAP-TLS. The second group of machines is managed by other departments, each having their own Active Directory, and configured with PEAP-MSCHAPv2. I'm not very familiar with this kind of setup, so hints are highly appreciated.
    1. Can I assume that, when properly configured, we can differentiate the authorizations per group (for exemple, at least two VLANs one for group 1 and another one for group 2 - I must at least seggregate the users per group and can't mix them in the same environment, since they belong two different departments).
    2. For the first group, no big issue. I can check against my central AD. For the users of the second group, since they can come from different departments, each having its own AD, can I differentiate them, by any means, to know which AD I'll have to query? Or do I have to query only one single AD? Is it required that all the users of group 2 belong to the same domain?
    Thanks in advance for your help.

    Hello,
    I'm planning to implement a IBNS network. We have two groups of XP Machines. One group has machine certs and we're planning to check their certs using EAP-TLS. The second group of machines is managed by other departments, each having their own Active Directory, and configured with PEAP-MSCHAPv2. I'm not very familiar with this kind of setup, so hints are highly appreciated.
    1. Can I assume that, when properly configured, we can differentiate the authorizations per group (for exemple, at least two VLANs one for group 1 and another one for group 2 - I must at least seggregate the users per group and can't mix them in the same environment, since they belong two different departments).
    2. For the first group, no big issue. I can check against my central AD. For the users of the second group, since they can come from different departments, each having its own AD, can I differentiate them, by any means, to know which AD I'll have to query? Or do I have to query only one single AD? Is it required that all the users of group 2 belong to the same domain?
    Thanks in advance for your help.

  • Problem in creating group above AND group left in one report!

    Hi all,
    I need a report that is a combination of group above and group
    left.
    Suppose I have 3 table (Emp, Sales, Product):
    Emp Table has 2 column
    - Emp_PK
    - Emp_Name
    Sales Table has 4 column
    -Sales_PK
    -Sales_Date
    -Emp_FK
    -Produck_FK
    -Quantity
    Product Table has 3 column
    -Product_PK
    -Product_Name
    -Product_Price
    I want to make Employee Sales Report For The Month that will
    look like this:
    Emp Number___: Emp_PK
    Emp Name_____: Emp_Name
    Sales Date______Product_Name____Quantity \(2 sales
    ________________Product_Name____Quantity /the date)
    Sales_Date______Product_Name____Quantity
    As you can see this consist of group above (The Employee) and
    group left (The Sales and Product).
    I create this by using 2 queries and link them (the Emp_PK from
    1st query and Emp_FK from 2nd query) on the report builder using
    data link.
    The first query is:
    Select Emp_PK, Emp_Name from Emp
    The second query is
    Select Emp_FK, Sales_Date, Product_Name, Quantity
    From Sales, Product
    Where Product_PK=PRODUCT_FK
    I then create the layout for second query and choose group left
    for Sales_Date using wizard and I create additional layout to
    for the employee.
    The problem is that when I run this report, it will print ALL
    the employee record first (including employee who has NOT sale
    anything) and then on the last page it will print the record of
    Last employee on the Emp table and ALL sales record (including
    those that is done by other employee).
    This report will run correctly if I choose an exact employee
    (For example by adding Where Emp_PK=1111 in the first query) to
    report all of the sales done by this person (employee with emp
    number of 1111). However I need the report to run and print
    ONLY those employee who has Sales Records!
    I thought that by linking the 2 queries in Data Model, it will
    have the same effect as linking using the WHERE clause in query.
    If suppose I create a query like this:
    SELECT Emp_PK, Emp_Name, Sales_Date, Product_Name, Quantity
    FROM Emp, Sales, Product
    WHERE Emp_PK=Emp_FK AND Product_PK=Product_FK
    The report will run OK but I can only choose EITHER group above
    or group left for this ONE query methods in report Wizard.
    Sorry if it is a long question but I hope you can see what I am
    trying to do.
    Thanks in advance for any tip.

    hello,
    of course you can create group left and group above blocks in a
    single report.
    you might want to use the INSERT REPORT BLOCK instead of the
    report wizard, as the report wizard only allows you to use one
    report layout per report, where the report block wizard (invoked
    by INSERT REPORT BLOCK) allows you to choose on a per-block
    basis.
    of course you can create the blocks completely from scarth by
    hand, if you want to.
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Group by for one column

    there is a scenario in informatica..where we can select more than one rows and group by on only one row..its possible in informatica..
    so can any one tell how to sql for those type of scenarios
    For example there are
    SEQUENCE_ID NUMBER NOT NULL,
    SAT_ID VARCHAR2(30 BYTE) NOT NULL,
    MFG_ID VARCHAR2(99 BYTE),
    SOLD_DT DATE,
    VIN VARCHAR2(30 BYTE)
    HE IS SELECTING ALL THE COLUMNS AND GROUPING BY ON SAT_ID ..so do any one tell how to write sql in that scenario

    in oracle you can have groupings without having to group all of the columns in the select clause by using an analytic query.
      select a.*
        from (select sequence_id,
                     mfg_id,
                     sold_dt,
                     vin,
                     row_number() over (partition by mfg_id order by sold_dt) rn
                from <table>
               where <conditions>) a
       where a.rn = 1
    try to post some sample data and output. we might be able to come up with some simple query that might be compatible or supported by informatica queries.

  • One column concat...urgent

    Hello All,
    I have a table with one column, which has the values are follows as 12 records.
    Out of that I want to create only three records
    discard all 'value' records and
    concatenate all the remaining records as one with respective of each 'value' record: Assume the 'value' will be default value and it'll never get changed at all
    column
    value
    val1
    val2
    val3
    value
    val11
    val22
    val33
    val44
    value
    val10
    val30
    So in the output will be
    column
    val1,val2,val3
    val11,val22,val33,val44
    val10,val30
    Any help would be appreciated

    Ok see this:
    SELECT rank, MAX(TRIM(LEADING ',' FROM SYS_CONNECT_BY_PATH(col1,','))) AS result
    FROM (
         SELECT col1, rank, ROW_NUMBER() OVER (PARTITION BY RANK ORDER BY RANK) AS rn
         FROM (
              SELECT col1, len, DECODE(SUBSTR(col1,-1,1),0,0,len) as rank
              FROM (
                   SELECT col1, LENGTH(TRIM(BOTH '*' FROM TRANSLATE(col1,'abcdefghijklmnoprstuvwxyz','*************************'))) AS len
                   FROM test_table
                   WHERE col1 <> 'value'
    START WITH rn = 1
    CONNECT BY PRIOR rn = rn - 1 AND PRIOR rank = rank
    GROUP BY rank;Hope this help you ;)
    Peter D.
    Forgot about result. Here it is:
          RANK RESULT
             0 val10,val30
             1 val1,val2,val3
             2 val11,val22,val33,val44Message was edited by:
    Peter D.

  • Concate 3  column data in to one column.

    I would like to concate 3 columns in to one column. all three column has datatype as LONG. Is any one knows how to concate long datatype column into one column?
    Thanks in Advance

    812294 wrote:
    Is there any way to not use CLOB datatype? I am fetching data from three different tables.And what fetching from three different tables has to do with CLOB?
    SQL> set serveroutput on
    SQL> declare
      2      concat_result clob;
      3      tmp           long;
      4  begin
      5      select  text
      6        into  tmp
      7        from  dba_views
      8        where rownum = 1;
      9      concat_result := tmp;
    10      select  data_default
    11        into  tmp
    12        from  dba_tab_columns
    13        where data_default is not null
    14          and rownum = 1;
    15      concat_result := concat_result || tmp;
    16      select  search_condition
    17        into  tmp
    18        from  dba_constraints
    19        where search_condition is not null
    20          and rownum = 1;
    21      concat_result := concat_result || tmp;
    22      dbms_output.put_line(concat_result);
    23  end;
    24  /
    select
    "LIB_IDX","LIB_NAME","VENDOR_NAME","PROTOCOL_NUM","VERSION_NUM","PATH_NAME","MAP
    _FILE","FILE_CFGID","MAP_ELEM","ELEM_CFGID","MAP_SYNC" from v$map_library0 OBJ#
    IS NOT NULL
    PL/SQL procedure successfully completed.
    SQL> SY.

  • I have never used PS, and I am trying to edit a brochure created by someone else.  I need to move text from one column to another

    I have never used PhotoShop and do not have time at the present. Please help me to move a section of text from one column to another in a brochure.

    Here are 3 options for future reference:
    1. With the setup you've described, apply a Match Move behavior to  the text and make the rectangle the source. Change the Transform parameter to Mimic source.  This way you can still adjust the text postion as needed, but the rectangle will drive the animation.
    2. Use a group to do the animation.  Put both your rectangle and text in the same group and animate the group's postion.
    3. Use the Link behavior.
    Each of these has it's advantages depending on what you need.

  • Table with column group (one column) - next row is showing on new page instead of below previous row

    I am creating new table. My goal is to display some text in few lines like this:
    "AAAAAAAA"           "BBBBBBBB"           "CCCCCCCCC"     
    "DDDDDDD"           "EEEEEEEE"
    Actually the next row (with "DD" and "EE" values) is not displayed below first row, but on the next page.
    I've tried to put table into rectangle, disabled all page breaks and still the same effect. Any help?

    Hi Heidi,
    Actually, it's not solution, I only gave more details about my problem :)
    Another description:
    In my report I'm creating Tablix with Column grouping. There is only one column with image (every image has same width). If there is only three pictures, then they are displayed next to each other in one row.
    In case, there is more than three pics, another row is showing on next page. I'd like to display all rows one after another on one page.
    I've tried to create three vertical lists, and filter each column group to display only records:
    1) =(RowNumber("Tablix1")) mod 3 = 1
    2) =(RowNumber("Tablix1")) mod 3 = 2
    3) =(RowNumber("Tablix1")) mod 3 = 0
    Unfortunately, I got an error:
    "A FilterExpression for the tablix ‘Tablix1’ uses the function RowNumber.  RowNumber cannot be used in filters."
    Do You have any other propositions?
    --------EDIT--------
    ok, I manged to solve it. As I said, I've created three vertival lists and placed them next to each other.
    Then, instead of using filter, I've used Visibility trigger:
    1)
    =IIf(RunningValue(Fields![rowgroupfield].Value, COUNTDISTINCT, "Tablix1") mod 3 = 1, false, true)
    2)
    =IIf(RunningValue(Fields![rowgroupfield].Value, COUNTDISTINCT, "Tablix2") mod 3 = 2, false, true)
    3)
    =IIf(RunningValue(Fields![rowgroupfield].Value, COUNTDISTINCT, "Tablix3") mod 3 = 0, false, true)
    I had to use function RunningValue to count all occurrences, as my report is quite complex and "RowNumber" [ssrs function] and "ROW_NUMBER() OVER (ORDER BY [rowgroupfield])" [sql query] were not working properly.

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • I also have a .csv file with the name of a jpeg in one column and a text description of each jpeg in a second column. Is there a way to automatically insert one jpeg (photo) and its corresponding text, each pair on one page, into a Indesign document?

    I also have a .csv file with the name of a jpeg in one column and a text description of each jpeg in a second column. Is there a way to automatically insert one jpeg (photo) and its corresponding text, each pair on one page, into a Indesign document?

    I would also recommend to write the description into the meta data. This would allow to place a text frame above the image and it is possible to add meta information and file name automatically together with the image, when you place it or even in a prepared template.
    Meta data information can be written easily in Bridge in the Meta File Workspace.

  • Pages:  How can I sort one column of words and not have it affect the other columns?

    How can I sort one column of words and not have it affect the other columns?  I have opened the inspector to the edit columns and rows under Table.  It will sort the column, but then it changes the other colums as well.  I know that if I use Numbers, it will work, but I want to know how to do the same thing in Pages.

    Hi Peter,
    Numbers sorts full rows on values in selected column(s). The technique for sorting a single column is essentially the same as Jerry is describing for Pages tables—separate the (data in the) column to be sorted, sort it, return it to the table.
    In Numbers the actual column may be separated from the original table, sorted, then returned. In Pages, the data must be extracted, sorted, then pasted back in, overwriting the unsorted data (if it was left in the original table).
    iWork tables follow a database model in which each row is a Record, and each column holds a Field within the records.
    As evidenced by the current question (and several similar questions arising in the Numbers community) that model doesn't apply to the way some users, especially some who come in from the MS Excel world, use tables.
    With Excels model—islands of data on a single large table, the ability to sort one or a selected few columns of data makes sense. One 'island' may comprise only cells AA21:AH50. Sorting that small 'table' should be possible without disturbing the rest of rows 21-30, which are probably part of one or more other 'data islands' in the sea that is a MS Excel spreadsheet.
    In Numbers, each of those 'islands' would be a separate Table, and that Table would be sortable without disturbing other Tables in the document.
    Regards,
    Barry

Maybe you are looking for

  • I would like to see the time in a waveform graph (real-time​)

    i need the x-axis of the waveform graph to show real time (from the computer clock). I have made a program with all the example. He read and log data when the chosen time has elapsed. the program work's well...but i dont't know why the x-axis blink e

  • How to prevent changes to SOLD TO in sales order

    Hi, Can someone remind how to stop users from changinf the address of the SOLD TO in a sales order? We allow users to change the SHIP TO address but sometimes they select the wrong partner and update the SOLD TO and then the delivery is made to the w

  • Blue messages problem

    Me and my grandparents have an iphone and we can't get our blue bubble back. We tried turning our iMessages off and then we tried turning our iphone off and nothing worked. We still have the green bubble. How do we get our blue bubbles back??

  • ReportCrash 100% cpu because cups is crashing

    My C2D iMac is at 100% CPU as I type this.  I'm getting loads of crash reports.  I have a cups process and 22 cups-driverd processes and more are created every few minutes.  I've deleted my printers (all three are network printers) thinking that I'd

  • Is there any ways for me to turn off the detection of keywords about time in Reminders?

    Hi, everyone! I don't know how many of you use Reminders frequently. Anyway, I am. Reminders has a acute keywords detecting system which detects keywords concerning time in order to auto-fill the time section which you might later fill in. It's a gre