Unix Technical Forum

select question

This is a discussion on select question within the SQL Server forums, part of the Microsoft SQL Server category; --> got a table with (class, name, exam, score) fields. To find max(score) for exam that starts with letter 'm' ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 06:18 PM
alexqa2003@yahoo.com
 
Posts: n/a
Default select question

got a table with (class, name, exam, score) fields.

To find max(score) for exam that starts with letter 'm'
grouped by class and name,did:

select max(score) from #temp where exam like 'm%'
group by class,name

this work only for selecting max(score) from #temp.
How to select all columns and max(score) at the same time,
how to do select *,max(score) from #temp?.
when tried, it gave multiple reults, error.





--
Sent by 3 from yahoo piece of com
This is a spam protected message. Please answer with reference header.
Posted via http://www.usenet-replayer.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 06:18 PM
John Bell
 
Posts: n/a
Default Re: select question

Hi

It is better to post DDL (Create table statements) example data (as insert
statements), your attempted statements and expected output, rather than a
verbose description as this removes all ambiguities.

You could try

SELECT Class, Name, Exam, ( SELECT MAX(Score) FROM #Temp T WHERE T.Class =
D.Class AND T.Name = D.Name ) as MaxScore
FROM #Temp D
WHERE D.Exam like 'm%'

John


"alexqa2003@yahoo.com" <u128845214@spawnkill.ip-mobilphone.net> wrote in
message news:l.1065912301.1229156494@[63.127.215.130]...
> got a table with (class, name, exam, score) fields.
>
> To find max(score) for exam that starts with letter 'm'
> grouped by class and name,did:
>
> select max(score) from #temp where exam like 'm%'
> group by class,name
>
> this work only for selecting max(score) from #temp.
> How to select all columns and max(score) at the same time,
> how to do select *,max(score) from #temp?.
> when tried, it gave multiple reults, error.
>
>
>
>
>
> --
> Sent by 3 from yahoo piece of com
> This is a spam protected message. Please answer with reference header.
> Posted via http://www.usenet-replayer.com



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:05 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com