Results 1 to 6 of 6

Thread: [RESOLVED] Need help in designing a query to show rows as columns in Sql 2000

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2013
    Posts
    66

    Resolved [RESOLVED] Need help in designing a query to show rows as columns in Sql 2000

    I have a table called markregister. It has data something like
    StudentId | PaperID | Marks
    1 | 1 |10
    1 | 2 |43
    1 | 3 |36

    The task is to show this data in a spreadsheet with 'Paper Name ' With that Paper Id as columns with corresponding marks in that subjects. Like

    Student Name | Paper1 | Paper2 | Paper3
    Henry | 10 | 43 | 36

    How Can I Achieve This using sql (Server 2000)?. Thank You

  2. #2
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,900

    Re: Need help in designing a query to show rows as columns in Sql 2000

    If the task is to show this in a spreadsheet you're probably best doing the pivot actually in the spreadsheet. Pivoting in excel is very instinctive and simple.

    If, however, you absolutely must do the pivot in sql server then what you're after is the PIVOT command.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Need help in designing a query to show rows as columns in Sql 2000

    Pivot query - https://www.google.com/search?q=pivot+query

    -tg

    edit - dagnabbit - Funky beat me to it.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2013
    Posts
    66

    Re: Need help in designing a query to show rows as columns in Sql 2000

    Does Sql 2000 Support PIVOT?. Also I am not using excel. It is a spread sheet control in vb6

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Need help in designing a query to show rows as columns in Sql 2000

    Huh.... I was all set to say "yeah, sure!" ... but then decided to double check... looks like it was added to SQL 2005... I'd swear I'd been doing it longer than that. Apparently not.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2013
    Posts
    66

    Re: Need help in designing a query to show rows as columns in Sql 2000

    Solved. I Did Some Violent Coding in front end and Achieved the Result.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width