How to Create table which main Colums divided in to many colums

  • Hi all,

    i need to create table which has main columns and that main columns divided in to same separate columns like as following 2nd table.which table create using following 1st table.please tall me how im i do this?

    1st Table

    +--------+------+------+-----+-----------+

    + + + + + +

    + Name + Maths+ Engl + Art + Semester +

    + + + + + +

    +--------+------+------+-----+-----------+

    + Harsha + 85 + 90 + 78 + 1 +

    +--------+------+------+-----+-----------+

    + Mick + 80 + 80 + 78 + 2 +

    +--------+----- +------+---- +-----------+

    + Ann + 75 + 90 + 78 + 2 +

    +--------+----- +------+-----+-----------+

    + Shone + 65 + 85 + 78 + 4 +

    +--------+------+------+----+------------+

    + Jorge + 65 + 55 + 78 + 1 +

    +--------+------+------+----+------------+

    + Andrew + 50 + 60 + 78 + 2 +

    +--------+------+---- -+-----+------------+

    + Polle + 70 + 78 + 78 + 3 +

    +--------+------+-----+--- --+--------- --+

    ..

    ..

    2nd Table

    +--------+-------------------+--------------------+-------------------+-----------------+

    + + 1st Semester + 2nd Semester + 3rd Semester + 4th Semester +

    + Name +------+------+-----+------+------+-----+-----+------------+------------------+

    + +Maths+ Engl + Art + Maths+ Engl + Art +Maths+ Eng l+ Art + Maths+ Engl + Art +

    +--------+------+------+-----+------+------+-----+-----+------+-----+-----+-----+-----+

    + Harsha + 85 + 90 + 78 + 85 + 90 + 78 + 85 + 90 + 78 + 85 + 90 + 78 +

    +--------+------+------+-----+------+------+-----+-----+----- +-----+-----+-----+-----+

    + Mick + 80 + 80 + 78 + 85 + 90 + 78 + 85 + 90 + 78 + 85 + 90 + 78 +

    +--------+------+------+-----+------+------+-----+-----+---- -+-----+-----+-----+-----+

    + Ann + 75 + 90 + 78 + 85 + 90 + 78 + 85 + 90 + 78 + 85 + 90 + 78 +

    +--------+------+------+-----+------+----- +----- +-----+-----+-----+------+-----+-----+

    + Shone + 65 + 85 + 78 + 85 + 90 + 78 + 85 + 90 + 78 + 85 + 90 + 78 +

    +--------+------+------+-----+------+------+-----+-----+----- +-----+-----+-----+-----+

    + Jorge + 65 + 55 + 78 + 85 + 90 + 78 + 85 + 90 + 78 + 85 + 90 + 78 +

    +--------+------+------+-----+------+------+--- -+-----+-----+-----+---- -+-----+-----+

    + Andrew + 50 + 60 + 78 + 85 + 90 + 78 + 85 + 90 + 78 + 85 + 90 + 78 +

    +--------+------+------+-----+------+------+-----+-----+------+-----+-----+-----+-----+

    + Polle + 70 + 78 + 78 + 85 + 90 + 78 + 85 + 90 + 78 + 85 + 90 + 78 +

    +--------+------+------+-----+------+------+-----+------+------+-----+----+-----+-----+

    ..

    ..

  • Use Excel or a reporting tool (like Reporting Services or Crystal Reports) for this kind of output formatting.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Or, you could do a cross-tab...

    http://qa.sqlservercentral.com/articles/T-SQL/63681/

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply