How to get multiple row data in a single line in SQL

I have a cust_card_dtls table. This table contains the different clients card details. A customer can have a single card or several cards.

SQL > select * from cust_card_dtls;

CUST_ID CARD_NO
--------------- ----------
1 111
2 222
3 333
4 444
5 555
6 666
1 777
1 888
2 999

I wan to query these data by that I can get all of a particular customer card numbers in a single line.
i.e.
1 111 777 888
2 222 999
3 333
4 444
5 555
6 666

Any way to do it? Thanks in advance.

Just replace 2 with 4 as

select  LTRIM(SYS_CONNECT_BY_PATH(CARD_NO,','),',')||lpad(',',4-NVL(length(regexp_replace(LTRIM(SYS_CONNECT_BY_PATH(CARD_NO,','),',') ,'[^,]')),0),',')   card_str
        ,CUST_ID
from
(
select CUST_ID
        ,CARD_NO
        ,row_number() over (partition by CUST_ID order by CARD_NO)rno
        ,row_number() over (partition by CUST_ID order by CARD_NO)-1 rnom1
from
cust_card_dtls
)
where connect_by_isleaf = 1
connect by prior rno = rnom1 and prior CUST_ID = CUST_ID
START WITH RNO = 1

Tags: Database

Similar Questions

  • How to get multiple rows in the table is displayed on the form

    I am looking for a way to get more table rows that appear on the form.  I created a table with a header and a line with the add-in and remove button option.  I like how the sample purchase order form has it setup in the designer it shows one line and it appears on the form so the table has three rows to start with.  How do I do that?  I looked at the code on the sample and I couldn't find it anywhere.  Please help, thanks.

    Hello

    I have an example here in the construction of a dynamic array markets.

    http://www.assuredynamics.com/index.php/category/portfolio/building-dynamic-tables/

    You must select the line and then go to object > Binding palette and set it to repeat. You can set the minimum and initial number to what you want.

    The form should be saved in a dynamic form of XML in the Save as dialog box.

    Also the page must be set to Flowed, so that as the table grows, push another object down. In addition, you need to configure the paging settings so that the flow of the page as the number of lines is superior to a single page.

    Give a start and if you need more help,

    Niall

    Ensure the dynamics

  • How to get back my data for the health and the watch Apps once I've restored my phone?

    How to get back my data for the health and the watch Apps once I've restored my phone?

    From the backup, you're going to be restoration.

    If you back up to iTunes, make sure that it is an encrypted backup.

  • My watch clock: 2012,03,2012 at 20:10. How to get back the Date please.

    My watch clock: 2012,03,2012 at 20:10.  How to get back the Date please.

    http://www.ehow.com/how_2052285_change-time-date-Windows-XP.html

    http://support.Microsoft.com/kb/307938

    UTC/GMT is 20:12 on Friday, February 24, 2012

  • How to get the last date of 3 days for the current month?

    Hello. Guy

    How to get the last date of 3 days for the current month?

    MY OUTPUT WOULD LOOK LIKE THIS

    JANUARY 29, 2016

    JANUARY 30, 2016

    JANUARY 31, 2016


    GUYS HELP ME / / /...

    SQL > select last_day (sysdate) - level + 1 double connect by level<= 3="" order="" by="">

    LAST_DAY)

    ---------

    29 JANUARY 16

    30 JANUARY 16

    31 JANUARY 16

  • How to change the background color of a single line

    Hi, OTN,.

    I use JDeveloper with ADF faces 11.1.1.2 in the view layer. My question is how to change the background color of a single line in af:table?.

    Hi idir Mitra
    You can use EL to bind column for example inlineStyle (#{row.id == null?' background-color: rgb (255,214,165);':'background-color:red'})})

    Cordially Abhilash.S

  • How to get the contact data of old hard drive?

    A friend's mother died.  He would like to get contact details.  He says that he "kept everything in Internet Explorer." I can't understand this... was it really store in Outlook?  I got the hard drive of the machine and it attached to my laptop under drive H.  How can I recover the data?

    I would ask him what email he used; It is possible that he was using a webmail (gmail, hotmail, etc.) and has been updated and access to contacts and mail via Internet Explorer, and it don't realize may not be not that they were stored on the webmail site and were not yet on his hard drive. Another possibility is Contacts in C:\Users\username\Contacts, but that don't rely on Internet Explorer.

  • How to get the current date to display in the Spanish format.

    The coding is in format Adobe Acrobat, DC. The coding I have for the English today's date is:

    var d = new Date();

    sDate = util.printd var ("dd mmmm yyyy", d);

    this.getField("Text1").value = sDate;

    How can I get the current date displayed in this Spanish format: 07 December 2015

    Thank you

    It's a little complicated... But this code should do the trick:

    util.printd("dd", d) + " de " + util.printd("date(es){MMMM}", d, true) + " de " + util.printd("yyyy", d);
    

    Edit: Fixed the code... Did not notice the 'of' second before.

  • How to get the path data graphics (M, L, Q, etc...)?

    I have a shape on the stage and I want to get its graphics data (M, L, Q, etc), I tried the readGraphicsData method, but I could not find the data path & orders!

    var stage_shape: Shape = this.getChildAt (0) as a form;

    var v: vector. < IGraphicsData > = stage_shape.graphics.readGraphicsData (false);

    trace (v);

    output: [object GraphicsSolidFill], [GraphicsPath object], [object GraphicsEndFill]

    trace (v [1]);

    output: [object GraphicsPath]

    Then. How to get path data (178,5 M157.55 Q273.7 188.45 392,5 178,5 L392.5...)?

    Thank you.

    var stage_shape: Shape = this.getChildAt (0) as a form;

    var v: Vector. = stage_shape.graphics.readGraphicsData (false);

    trace (v);

    output: [object GraphicsSolidFill], [GraphicsPath object], [object GraphicsEndFill]

    trace (GraphicsPath(v[1]). Data);

  • How to get the numeric date on reviews, no positions.

    Hello

    Can someone tell me how can I get a digital date on my blog comments? date is currently like 'may 25, 2015', and I wish it were "25/05/2015".» I went into the code and saw that the use of this tag "{tag_usagedate}", I managed to fix this for the blog because there is this tag: "{tag_blogpostmonthnumeric}", how can I do the same thing for comments date? " I need to do this because my site is in Portuguese, and it's the only way I found the date of the translation. Unless someone can teach me what are these tags and how can it change directly in their table of months for something like {'February', 'Marco', 'Janeiro', 'April',..., 'December'}. Any help is appreciated.

    Thank you

    Alex.

    To do this I use liquid, make sure it is enable on your site, something as it does the job, maybe someone should check the syntax.

    {{date | date: ' %d-%m - yyyy "}} for all numeric values, but {{date | date:"%d - MMM-yyyy"}} should return the date with the month names in your culture.

    Look here the Developer Reference for all filters.

  • How to get multiple license for Adobe Standard?

    Our company wants to buy 3-5 for Adobe Standard licenses.  Can you tell me how to get them?

    Thank you

    Becky RMB

    Hi David,

    You can easily purchase several licenses for the product that you want.

    Adobe gives you an option to purchase volume licenses.

    Please visit the links below to be updated on the Volume licensing and choose the relevant purchase program.

    http://www.Adobe.com/volume-licensing.html?promoid=ITLHM

    http://www.Adobe.com/in/volume-licensing/benefits-by-role.html

    I'm sure this will help.

    Concerning

    Sukrit diallo

  • How to get the old data 6 months from the current date?

    Hi friends,

    I have a table which includes historical data, which are having more than 1 years old data. The historical table gets updated once a week. My requirement is that I should get the latest data from the week of each month for 6 months according to the current data. I use oracle 10g.

    Can you please someone help in this.

    Thanks in advance

    SELECT last_day (ADD_MONTHS (TRUNC (SYSDATE, 'mm'),-LEVEL))-7 start_dt.
    LAST_DAY (ADD_MONTHS (TRUNC (SYSDATE, 'mm'),-LEVEL)) end_dt
    OF THE DOUBLE
    CONNECT BY LEVEL<=>

    change as a result, I have provided you the start and end dates for your logic...

  • How can I insert a date on the signature line?

    How can I insert a date automatically on the signature line?

    Digital signature fields display the date and time when they were signed by default.

  • How to get the script to a table or view in SQL Developer?

    Dear friends/expert,

    Could you tell me how to get the script from a view or a table easily in SQL Developer as pressing F4 in TOAD?

    I found that I can press SHIFT + F4 to view in SQL Developer and get the script of the view in the Details tab. But how to move the script to the SQL worksheet to change? It is very easy to do in TOAD.

    And I have not found a way to get the script for a table up to now. Is it possible to do?

    Thanks in advance.

    Best regards
    Ning

    There are people a lot better out there to answer on this point than I am - but here's how I do it.

    I'm just in the browser/browser for interest table, choose the script on the right side tab (which shows all the SQL for the table) and then cut and paste what I want or need in my editor window.

  • Extract data into a single line

    Hi good morning all,
    Here's my problem: my goal is to have a single flat txt file with a single line!
    That being said can someone tell me how to retrieve my oracle table data in a txt file, with the news that my table has a single colum (varchar 250); and I have 200 rows in this table;
    the output should be only a single line without end!
    Thank you for your great support;
    I try with all possible overall; (set pagesize 0 tab settled out of SPACE SET SET NEWPAGE 0 0 trimspool set set verify off set set recsep [off set echo off... off position) but no way to work!

    user647922 wrote:
    Thank you all for the reply! Dear BLUSHADOW! I try but I get an error that I can't understand:
    SQL > declare
    cursor cur_e is
    Select to_char (MASTRECORD_EDU, 'fm9999') as ln
    of operant.fic_bdf;
    v_fh UTL_FILE. TYPE_DE_FICHIER;
    Start
    v_fh: = UTL_FILE. FOPEN ('W_DIR', 'testout.txt', 'w');
    for e in cur_e
    loop
    UTL_FILE. PUT(v_fh,e.LN);
    end loop;
    UTL_FILE. FCLOSE (v_fh);
    end;
    /
    declare 2 3 4 5 6 7 8 9 10 11 12 13 14
    *
    ERROR? line 1:
    ORA-01722: invalid number
    ORA-06512:? line 8

    Help, please!

    This means that one of your MASTRECORD_EDU values is not a valid number. Question by data, not code Office.

Maybe you are looking for