Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grouping issue
Message
From
12/06/2003 08:35:04
 
 
To
11/06/2003 23:52:52
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
00799203
Message ID:
00799298
Views:
28
Does this return the results that you're looking for?

SELECT t1.*
FROM Ppgval t1
WHERE gvald IN (SELECT max(gvald) FROM Ppgval t2
WHERE t1.node = t2.node And t1.rollno = t2.rollno)

-Mike

>Sergey:
>
>Oops! Time I put my head in a bucket of ice water! I wrote 'row' when I meant 'column' (Maybe that Preview button is for thinking about what you have written <g>)
>
>Using your most recent suggestion I sent the query
>
>SELECT t1.* FROM Ppgval t1
>  WHERE EXISTS ( SELECT * FROM Ppgval t2
>               WHERE t1.node = t2.node And t1.rollno = t2.rollno
>                     AND t1.gvald = MAX(t2.gvald))
>
>to SQL and got back the response:
>
>Server: Msg 147, Level 16, State 1, Line 1
>An aggregate may not appear in the WHERE clause unless it is in a subquery
>contained in a HAVING clause or a select list, and the column being
>aggregated is an outer reference.
>
>
>It seems to me that both these options only work with a GROUP BY clause.
>
>- g -
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Reply
Map
View

Click here to load this message in the networking platform