Merge multiple rows of same ID into Single row

Hi All,
I need the requirements of merging multiple rows of same ID as single row.
My Table Data:
ID     Language1 Language2 Language3 Language4
1001 NULL         JAPANESE  NULL          NULL
1001 SPANISH   NULL          NULL          NULL
1001 NULL        NULL           NULL         ENGLISH
1001 NULL        NULL           RUSSIAN    NULL
Required Output Should be,
ID     Language1 Language2 Language3 Language4
1001 SPANISH    JAPANESE  RUSSIAN   ENGLISH
Please help me to achieve this output.
Tried grouping but its not working also producing the same result.
Thanks.
Live freee....Joy forever................ :)

Try the below:
create Table Test_Sample(ID int,Language1 varchar(50), Language2 varchar(50), Language3 varchar(50), Language4 varchar(50))
Insert into Test_SAmple Values(1001,NULL,'JAPANESE', NULL, NULL),
(1001,'SPANISH', NULL, NULL, NULL),
(1001,NULL, NULL, NULL, 'ENGLISH'),
(1001,NULL, NULL, 'RUSSIAN', NULL)
Select ID,MAX(Language1),MAX(Language2),MAX(Language3),MAX(Language4)
From Test_Sample
Group by ID
Drop table Test_Sample

Similar Messages

  • Merging multiples of the same photo into one

    I remember reading a couple tutorials on how to do this weeks ago, but now i cannot seem to remember what to search for to find a tutorial on this.
    I multiple photos, its the same location (tripod) with me in a different position in each frame. I want to merge each frame into one picture so in one picture there are multiples of myself in different positions.
    thanks!

    You'll have to use File->Scripts->Load Files into Stack to load all the images into a single document, each on it's own layer, select all the layers and go to Edit->Auto-Align Layers. If all went well then you should be able to achieve your effect using a couple of simple layer masks

  • Mearge Multiple rows of same record in single row with /

    Dear Friends
    Here I am giving a example, In this example i want to mearge the records containing waybillno 24292 to single record but here i am having seperate tallerno which i want to combine in 1 record with '/'
    Please give the solution urgently
    WAYBILLNO WAYBILLDT TALLERNO TALLERDAT INVOICEVALUE
    24942 31-MAR-11 873000
    24942 31-MAR-11 3142 07-MAR-11
    24942 31-MAR-11 3145 18-MAR-11
    sandy
    Edited by: Sandy on 17 May, 2011 4:57 AM

    /* Formatted on 5/18/2011 10:10:36 AM (QP5 v5.149.1003.31008) */
    WITH t AS (SELECT 24942 WAYBILLNO,
                      '31-MAR-11' WAYBILLDT,
                      873000 TALLERNO,
                      NULL TALLERDAT
                 FROM DUAL
               UNION
               SELECT 24942,
                      '31-MAR-11',
                      3142,
                      '07-MAR-11'
                 FROM DUAL
               UNION
               SELECT 24942,
                      ' 31-MAR-11',
                      3145,
                      '18-MAR-11'
                 FROM DUAL
               UNION
               SELECT 24943,
                      '28-MAR-11',
                      3150,
                      '08-MAR-11'
                 FROM DUAL
               UNION
               SELECT 24943,
                      ' 20-MAR-11',
                      3155,
                      '12-MAR-11'
                 FROM DUAL)
        SELECT WAYBILLNO,
               MAX (SUBSTR (SYS_CONNECT_BY_PATH (WAYBILLDT, ','), 2)) WAYBILLDTS,
               MAX (SUBSTR (SYS_CONNECT_BY_PATH (TALLERNO, ','), 2)) TALLERNOS,
               MAX (SUBSTR (SYS_CONNECT_BY_PATH (TALLERDAT, ','), 2)) TALLERDATS
          FROM (SELECT WAYBILLNO,
                       WAYBILLDT,
                       TALLERNO,
                       TALLERDAT,
                       ROW_NUMBER ()
                       OVER (PARTITION BY WAYBILLNO
                             ORDER BY WAYBILLDT, TALLERNO, TALLERDAT)
                          rn
                  FROM t)
    -- WHERE CONNECT_BY_ISLEAF = 1  don't think connect by isleaf is available in 9i
    -- so you will need to pick the max and group by waybillno
    START WITH rn = 1
    CONNECT BY PRIOR rn = rn - 1 AND PRIOR WAYBILLNO = WAYBILLNO
      GROUP BY WAYBILLNO
      ORDER BY WAYBILLNO
    WAYBILLNO     WAYBILLDTS     TALLERNOS     TALLERDATS
    24942      31-MAR-11,31-MAR-11,31-MAR-11     3145,3142,873000     18-MAR-11,07-MAR-11,
    24943      20-MAR-11,28-MAR-11     3155,3150     12-MAR-11,08-MAR-11

  • Combining Multiple Rows into single row with multple columns

    Hi Experts,
    I have the following requirement, kindly help me.
    I have data in my table like below.
    ID NAME DEPT
    1 Sam 10
    1 Sam 20
    2 alex     30
    2 alex 40
    2 alex 50
    3 vinod 60
    3 vinod 70
    I want to show the same data into single row with dynamically generating columns for DEPT. I want show like below.
    ID NAME DEPT1 DEPT2 DEPT3
    1 Sam 10 20
    2 alex 30 40 50
    3 vinod 60 70
    It's urgent requirement, kindly help me.
    Thanks in advance.

    Right I've had my drink, so what was this "urgent" question then?
    798616 wrote:
    I have data in my table like below.
    ID NAME DEPT
    1 Sam 10
    1 Sam 20
    2 alex     30
    2 alex 40
    2 alex 50
    3 vinod 60
    3 vinod 70
    I want to show the same data into single row with dynamically generating columns for DEPT. I want show like below.Dynamic numbers of columns eh! Tricky.
    If you understand how SQL statements are executed it's along these lines...
    1. Open Cursor
    2. Parse SQL statement and determine columns
    3. Bind in any input values
    4. Fetch data
    5. Bind out values to columns
    6. Repeat step 3 until no more data
    7. Close cursor
    Now, you're expecting that you can determine the columns (step 2) from the fetched data (step 4 onwards). You can't. The SQL engine needs to know the expected columns before any data is fetched so, it can't base the number of columns on the data itself.
    If you need that requirement, you would need to query the data first and build up a dynamic query based on the data and then execute that dynamically built query to fetch the data and pivot it into those columns, which means that you have queried the data twice. Not good practice and not good (or simple) coding.
    What you're talking of doing is something that should be handled at the presentation/interface layer, not as part of the data fetch.
    Typically these sorts of things are handled most easily in report generation/writer tools such as Oracle Reports, Business Objects etc. where they fetch the data from the database and then process it to format it on the display, pivoting the results as required.
    It's not something that lends itself to be easily achieved in SQL. Yes, SQL can do pivoting of data quite easily, but NOT with a dynamic number of columns.
    If you were to specify that there is a maximum number of columns that you could get (rather than wanting it dynamic), then you can do it simply in SQL with the max-decode method...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select deptno, ename, row_number() over (partition by deptno order by ename) as rn from emp)
      2  --
      3  select deptno
      4        ,max(decode(rn,1,ename)) as ename1
      5        ,max(decode(rn,2,ename)) as ename2
      6        ,max(decode(rn,3,ename)) as ename3
      7        ,max(decode(rn,4,ename)) as ename4
      8        ,max(decode(rn,5,ename)) as ename5
      9        ,max(decode(rn,6,ename)) as ename6
    10        ,max(decode(rn,7,ename)) as ename7
    11        ,max(decode(rn,8,ename)) as ename8
    12        ,max(decode(rn,9,ename)) as ename9
    13        ,max(decode(rn,10,ename)) as ename10
    14  from t
    15  group by deptno
    16* order by deptno
    SQL> /
        DEPTNO ENAME1     ENAME2     ENAME3     ENAME4     ENAME5     ENAME6     ENAME7     ENAME8     ENAME9     ENAME10
            10 CLARK      KING       MILLER
            20 ADAMS      FORD       JONES      SCOTT      SMITH
            30 ALLEN      BLAKE      JAMES      MARTIN     TURNER     WARD
    SQL>

  • Merge multiple rows into single row (but multiple columns)

    How to merge multiple rows into single row (but multiple columns) efficiently.
    For example
    IDVal IDDesc IdNum Id_Information_Type Attribute_1 Attribute_2 Attribute_3 Attribute_4 Attribute_5
    23 asdc 1 Location USA NM ABQ Four Seasons 87106
    23 asdc 1 Stats 2300 91.7 8.2 85432
    23 asdc 1 Audit 1996 June 17 1200
    65 affc 2 Location USA TX AUS Hilton 92305
    65 affc 2 Stats 5510 42.7 46 9999
    65 affc 2 Audit 1996 July 172 1100
    where different attributes mean different thing for each Information_type.
    For example for Information_Type=Location
    Attribute_1 means Country
    Attribute_2 means State and so on.
    For example for Information_Type=Stats
    Attribute_1 means Population
    Attribute_2 means American Ethnicity percentage and so on.
    I want to create a view that shows like below:
    IDVal IDDesc IDNum Country State City Hotel ZipCode Population American% Other% Area Audit Year AuditMonth Audit Type AuditTime
    23 asdc 1 USA NM ABQ FourSeasons 87106 2300 91.7 46 85432 1996 June 17 1200
    65 affc 2 USA TX AUS Hilton 92305 5510 42.7 46 9999 1996 July 172 1100
    Thanks

    Hi,
    That's called Pivoting . The forum FAQ has a section on this subject: {message:id=9360005}
    I hope this answers your question.
    If not, post your best attempt, along with a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data. (You did post the results you wanted, but they're very hard to read because they're not formatted. Use \ tags, as described in the forum FAQ, below.)
    Explain, using specific examples, how you get the results you want from the data given.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).  This is always important, but especially so with pivots.
    See the forum FAQ {message:id=9360002}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Convert  multiple rows into single rows for the respective index name

    Dear Experts,
                             I want to convert  multiple rows into single rows for the respective index name,
                            Here is my query.
    SELECT user_tables.table_name, user_indexes.index_name, user_ind_columns.column_name
    FROM user_tables
    JOIN user_indexes on user_indexes.table_name = user_tables.table_name
    join USER_IND_COLUMNS on USER_INDEXES.INDEX_NAME = USER_IND_COLUMNS.INDEX_NAME
    where user_indexes.index_name not like '%PK%' AND user_ind_columns.column_name NOT LIKE '%SYS%'
    ORDER BY user_tables.table_name,user_indexes.index_name;
    Result of previous query
    TABLE_NAME
    INDEX_NAME
    COLUMN_NAME
    T1
    IDX_ACCNTYPCFG1
    ENABLE_SERVICE
    T1
    IDX_ACCTTYPCFG1
    ACC_CODE
    T1
    IDX_ACCTTYPCFG1
    ACCTYPE
    T2
    IDX_ACCTTYPCFGAPP1
    ACCTYPE
    T3
    IDX_ACTLG1
    MOBILE_NO
    T3
    IDX_ACTLG1
    ID
    Desired output required is
    TABLE_NAME
    INDEX_NAME
    COLUMN_NAME
    T1
    IDX_ACCNTYPCFG1
    ENABLE_SERVICE,ACC_CODE,ACCTYPE
    T2
    IDX_ACCTTYPCFGAPP1
    ACCTYPE
    T3
    IDX_ACTLG1
    ACCTYPE,MOBILE_NO
    please help.

    Maybe
    with
    user_tables as
    (select 'T1' table_name,'IDX_ACCNTYPCFG1' index_name,'ENABLE_SERVICE' column_name from dual union all
    select 'T1','IDX_ACCTTYPCFG1','ACC_CODE' from dual union all
    select 'T1','IDX_ACCTTYPCFG1','ACCTYPE' from dual union all
    select 'T2','IDX_ACCTTYPCFGAPP1','ACCTYPE' from dual union all
    select 'T3','IDX_ACTLG1','MOBILE_NO' from dual union all
    select 'T3','IDX_ACTLG1','ID' from dual
    select table_name,
           case index_name when 'IDX_ACCNTYPCFG1' then 'IDX_ACCTTYPCFG1' else index_name end index_name,
           listagg(case column_name when 'ID' then 'ACCTYPE' else column_name end,',') within group (order by null) column_name
      from user_tables
    group by table_name,case index_name when 'IDX_ACCNTYPCFG1' then 'IDX_ACCTTYPCFG1' else index_name end
    TABLE_NAME
    INDEX_NAME
    COLUMN_NAME
    T1
    IDX_ACCTTYPCFG1
    ACCTYPE,ACC_CODE,ENABLE_SERVICE
    T2
    IDX_ACCTTYPCFGAPP1
    ACCTYPE
    T3
    IDX_ACTLG1
    ACCTYPE,MOBILE_NO
    Regards
    Etbin

  • How to display multiple lines of texts in a single rows in ALV

    Hi,
    I have a unique requirement in which i have to display multiple lines if texts for a single rows in ALV Grid. Right now in my output it is coming in single line which is not visible fully because that text is more than 255 character. So i want to display the test by splitting into multiple lines and show it on output. Please suggest some solution for this if this is possible in ALV.
    Thanks,
    Raghav

    Hi Raghavendra,
    Its not possible to display multiple line in one row of an alv, but i think you can acheive it by splitting the whole text into multiple sub-text.
    For example, if your requirement is as below:
    Field #1          Field #2
    1                    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(200 characters)
    2                    yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy(220 character)
    then you can break Field#2 value into say 50 character and then populate the internal table with repetative entries of Field#1 and the finally sort it by Field#1 value... as a result of which you output will be somewhat as below:
    Field#1          Field#2
    1                   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    2                   yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
                         yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
                         yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
                         yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
                         yyyyyyyyyyyyyyyyyyyy           
    Hope it will help you in meeting your requirement.
    Regards,
    Shradha

  • Multiple row value coming in a single row(nclob)

    hi ,
    i have a requirement where i have to work on a column on datatype nclob, now here the value of 2 rows coming into a single column. like this:
    select distinct extractvalue(xmltype(details),'/Anything/invoiceNumber') as invoices ,
    actinguserid as user_id ,createdt
    from bchistevent where bucket = 201301
    and upper(type) = 'COM.AVOLENT.PRESENTATION.EVENT.INVOICEDOWNLOADEVENT'
    --and    bchistevent.bucket = to_char (add_months (sysdate, -1),'YYYYMM')
    395452969-000-20130103     1.46388193452398E37     1/8/2013 3:05:42 AM
    300000590-000-20090723     1.46388193452398E37     1/11/2013 8:11:45 AM
    300000590-000-20090723     1.46388193452398E37     1/11/2013 8:12:50 AM
    395453127-000-20130103     1.46388193452398E37     1/14/2013 4:44:26 AM
    *300084670-000-20120906, 300084671-000-20120906*     1.46388193452398E37     1/7/2013 12:45:19 AM
    395452626-000-20130103     1.46388193452398E37     1/8/2013 3:03:57 AM
    300084679-000-20120906     1.46388193452398E37     1/11/2013 8:10:47 AM
    300000728-000-20090731     1.46388193452398E37     1/11/2013 8:19:19 AM
    300084679-000-20120906     1.46388193452398E37     1/14/2013 12:31:48 AM
    300000590-000-20090723     1.46388193452398E37     1/14/2013 4:13:19 AM
    395452718-000-20130103     1.46388193452398E37     1/8/2013 7:10:19 AM
    300084679-000-20120906     1.46388193452398E37     1/23/2013 6:54:11 AM
    300084679-000-20120906     1.46388193452398E37     1/22/2013 3:11:54 AM
    300000590-000-20090723     1.46388193452398E37     1/11/2013 8:14:02 AM
    395453127-000-20130103     1.46388193452398E37     1/14/2013 4:33:12 AM
    300084679-000-20120906     1.46388193452398E37     1/22/2013 3:03:36 AM
    300084679-000-20120906     1.46388193452398E37     1/14/2013 12:34:13 AM
    395452997-000-20130103     1.46388193452398E37     1/7/2013 3:31:38 AM
    395452391-000-20121027     1.46388193452398E37     1/3/2013 4:40:05 AM
    and the value of bold highlighted row is coming in a single row, plzz help how to break this in 2 rows??
    Edited by: user1175303 on Mar 13, 2013 5:43 AM

    user1175303 wrote:
    the column value which is in question is <Anything><invoiceNumber>300084670-000-20120906, 300084671-000-20120906</invoiceNumber></Anything> here i am getting 2 values in a single column and because of this i am unable to get desired output...So you have XML issue but trying to resolve it in Oracle??? Why <invoiceNumber> holds two invoice numbers? Anyway:
    with t as (
               select  distinct extractvalue(xmltype(details),'/Anything/invoiceNumber') as invoices,
                       actinguserid as user_id,
                       createdt
                 from  bchistevent
                 where bucket = 201301
                   and upper(type) = 'COM.AVOLENT.PRESENTATION.EVENT.INVOICEDOWNLOADEVENT'
    select  regexp_substr(invoices,'[^,]+',1,column_value) invoices,
            user_id,
            createdt
      from  t,
            table(
                  cast(
                       multiset(
                                select  level
                                  from  dual
                                  connect by level <= length(regexp_replace(invoices,'[^,]')) + 1
                       as sys.OdciNumberList
    /SY.

  • How to merge multiple XML or Text documents into 1 Word Document?

    Hi all,
    We're looking for a way to merge multiple XML or Text documents into 1 Word document.
    All the XML or Text documents are oriented as a 'Paragraph', meaning smaller pieces of text.
    By selecting some of these XML documents, the system should be able to create a new Word document with all the selected text paragraphs included.
    The Word document can then be edited for applying a correct lay-out and the document is ready.
    Actually, we are trying to do some kind of 'mail merge' but with multiple XML or Text documents!
    Has anybody an idea whether something exist already or give us a direction how to proceed?
    Thanks in advance,
    Pascal Decock

    You use Assembler for this purpose.
    1) Assembler can be accessed through LC Java API. See http://help.adobe.com/en_US/enterpriseplatform/10.0/programLC/help/index.html
    API Quick Starts (Code Examples) > Assembler Service API Quick Starts
    2) Last week I posted on generating and merging PDF's from PostScript. Take a look at the assembly service instance in the .lca. Assembler uses DDX (Document Description XML) to describe document construction. NOTE the .lca was developed with ES 3 (aka ADEP). The .lca It contains the most basic DDX.
    <?xml version="1.0" encoding="UTF-8"?>
    <DDX xmlns="http://ns.adobe.com/DDX/1.0/">
    <PDF result="out.pdf">
      <PDF source="inDoc1"/>
      <PDF source="inDoc2"/>
    </PDF>
    </DDX>
    http://forums.adobe.com/message/4019760#4019760
    DDX Reference at http://help.adobe.com/en_US/livecycle/9.0/ddxRef.pdf
    Steve

  • How to convert single column into single row

    I need to convert single column into single row having n no.of.values in a column. without using case or decode. I need a query to display as below.
    emp_id
    100
    101
    102
    102
    103
    200
    I need output like 100,101,102,103,104.........200.

    I assume you want to convert 200 rows with one column into one row with 200 columns. If so, this is called pivot. If you know number of rows (max possible number of rows) and you are on 11G you can use PIVOT operator (on lower versions GROUP BY + CASE). Otherwise, if row number isn't known, you can use dynamic SQL or assemble select on clent side. Below is example emp_id = 1,2,..5 (to give you idea) and you are on 11G:
    with emp as (
                 select  level emp_id
                   from  dual
                   connect by level <= 5
    select  *
      from  emp
      pivot(
            max(emp_id) for emp_id in (1 emp_id1,2 emp_id2,3 emp_id3,4 emp_id4,5 emp_id5)
       EMP_ID1    EMP_ID2    EMP_ID3    EMP_ID4    EMP_ID5
             1          2          3          4          5
    SQL>
    SY.

  • Want to be able to open tabs in multiple rows, rather than in a single row. I used tab mix plus before, but it says it is not compatible with New tab Homepage. The older version of Firefox allowed this very easily.

    Want to be able to open tabs in multiple rows, rather than in a single row. I used tab mix plus before, but it says it is not compatible with New tab Homepage. The older version of Firefox allowed this very easily.

    Your plugins list shows outdated plugin(s) with known security and stability risks.
    *Java Plug-in 1.5.0_06 for Netscape Navigator (DLL Helper)
    Update the [[Java]] plugin to the latest version.
    *http://java.sun.com/javase/downloads/index.jsp (Java Platform: Download JRE)

  • ALV - Multiple Rows into Single Row

    I have a requirement to display the ALV output from CDHDR&CDPOS tables here in the output i have 15 columns( Fields ) any changes im displaying in report output ,but if there is same time multiple columns will change im displaying as individual record instead of that i need to show as single row.
    in this output last three records have same time change but i have populated into three different columns i want to make it as SINGLE Row Record.
    Thanks!!

    We don't need script task for this. Use TSQL in the datasource. Refer below example
    DECLARE @TEMP TABLE(ID INT, [VALUE] NVARCHAR(30))
    INSERT INTO @TEMP VALUES(1 , 'MAZ')
    INSERT INTO @TEMP VALUES(1 , 'HON')
    INSERT INTO @TEMP VALUES(1 , 'FOR')
    INSERT INTO @TEMP VALUES(2 , 'JEEP')
    INSERT INTO @TEMP VALUES(2 , 'CHE')
    INSERT INTO @TEMP VALUES(3 , 'NIS')
    INSERT INTO @TEMP VALUES(4 , 'GMC')
    INSERT INTO @TEMP VALUES(4 , 'ACC')
    INSERT INTO @TEMP VALUES(4 , 'LEX')
    SELECT [id],
    Stuff((SELECT ',' + [VALUE]
    FROM @TEMP
    WHERE [id] = a.[id]
    FOR xml path('')), 1, 1, '') [VALUE]
    FROM @TEMP a
    GROUP BY [id]
    Regards, RSingh

  • Concatenation Multiple Rows into Single Row

    My select query is like wise
    ID Name
    1 Arthi
    2 Preethi
    3 Madhu
    4 Saranya
    Above i listed all the names using the select query. Now i have to combine this 4 rows in single row like
    Arthi,Preethi,Madhu,Saranya.
    Also this rows may be 5 or 50 too. So what are Names listed using select statement those should combine into one Single String.
    Help me pl

    Please post this in an appropriate forum;
    SQL and PL/SQL
    PL/SQL
    Community Feedback and Suggestions (Do Not Post Product-Related Questions Here)
    Adith

  • Club Multiple rows into single row

    Hi,
    Iam facing this problem. Iam having this table client_details with columns as
    client -- group -- group_code
    1234 ------ X ------ code1
    1234 ------ Y ------ code2
    5555 ------ X ------ code3
    5555 ------ Y
    Now when I Query this table for a particular client, I require both the group_code for this client (it can be null also). But I require the result in a SINGLE row.
    The group will be either X or Y only.
    Can anyone help me out pls
    tnx
    Che

    oops
    SQL> select client, max(decode("GROUP", 'X', GROUP_CODE)) X, max(decode("GROUP", 'Y', GROUP_CODE)) Y from client_details group by client;
    CLIENT X Y
    1234 code1 code2
    5555 code3

  • 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

Maybe you are looking for