Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jung1975
Aged Yak Warrior
503 Posts |
Posted - 2005-01-06 : 17:10:02
|
I have a table looks like:Test Range ScoreMath High 89Matc Low 16English High 96English Low 33 I‘m trying to write a query that return the result looks like:Test High Low Math 89 16English 96 33 How can I accomplish this? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-01-06 : 17:13:59
|
| [code]CREATE TABLE Table1 (Test varchar(10), Score int)INSERT INTO Table1 VALUES('Math', 89)INSERT INTO Table1 VALUES('Math', 16)INSERT INTO Table1 VALUES('English', 96)INSERT INTO Table1 VALUES('English', 33)SELECT Test, High = (SELECT MAX(Score) FROM Table1 WHERE Test = t.Test), [Low] = (SELECT MIN(Score) FROM Table1 WHERE Test = t.Test)FROM Table1 tGROUP BY TestORDER BY Test DESCDROP TABLE Table1[/code]Tara |
 |
|
|
|
|
|