Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 9th, 2005, 03:02 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cairo, , Egypt.
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default Columns To Rows

I have A Table Like

SName Material Score Month year
a1 m1 20 1 2000
a2 m1 40 1 2000
a3 m1 60 1 2000
a4 m1 30 1 2000
a1 m2 20 1 2000
a2 m2 10 1 2000
a3 m2 60 1 2000
a4 m2 80 1 2000
a1 m3 70 1 2000
a2 m3 40 1 2000
a3 m3 20 1 2000
a4 m3 80 1 2000

i need to get output like
all Students Best Material Scores And Each Type Per Row

a1 a2 a3 a4
m3 m1 m1 m2
70 40 60 80


Any Could Help



Ahmed Ali
Software Developer
__________________
Ahmed Ali
Senior Software Developer
Reply With Quote
  #2 (permalink)  
Old March 10th, 2005, 12:29 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,346
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Try:
   Select
      SName, Material, Max(Score)
   From
      <table>
   Group By SName, Material
Reply With Quote
  #3 (permalink)  
Old March 11th, 2005, 02:08 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cairo, , Egypt.
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

What I need To Done Is Like that But I Need Extra Shape i need In Row Shape
All Descriped In Following Script

select sname
,(select top 1 inTab.mat
    from #StScore as inTab
    where inTab.sname=#StScore.sname
    order by inTab.score desc)
,max(score) as Sc
from #StScore
group by sname

The Result Is
a1 m3 90
a2 m3 70
a3 m1 50
a4 m1 60

What I need
a1 a2 a3 a4
m3 m3 m1 m1
90 70 50 60






Ahmed Ali
Software Developer
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Refer to Rows and Columns RayL Access VBA 3 May 23rd, 2007 09:13 AM
Rows 2 Columns kilika Oracle 0 October 14th, 2005 01:16 PM
showing columns as rows zee_ahmed2002 SQL Server 2000 2 October 28th, 2004 04:58 AM
Rows into columns shamsad SQL Language 0 April 7th, 2004 04:39 AM
Rows into columns shamsad Oracle 0 April 7th, 2004 04:38 AM



All times are GMT -4. The time now is 04:45 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.