Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 9th, 2005, 04:02 PM
Friend of Wrox
 
Join Date: Oct 2003
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
 
Old March 10th, 2005, 01:29 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Try:
   Select
      SName, Material, Max(Score)
   From
      <table>
   Group By SName, Material
 
Old March 11th, 2005, 03:08 PM
Friend of Wrox
 
Join Date: Oct 2003
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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.