Sunday, March 11, 2012

Aggregates

I have a simple table that stores
name score
-- --
jim 343
bob 322
jane 122
Lets say i have a user defined function that applys a formula to the score
and I want to select the minimum value of the function.
eg.
SELECT name, score, MIN(dbo.alterScore(score))
FROM tester
I want to return the smallest value of the when the function is applied
along with the name and score.
How can I do this?
Many thanks.One way is:
SELECT TOP 1 name, score, MIN(dbo.alterScore(score)) AS MinScore
FROM tester
ORDER BY MinScore
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Mark Thomson" <@.@.@.> wrote in message
news:uZVc3NtjFHA.2852@.TK2MSFTNGP15.phx.gbl...
I have a simple table that stores
name score
-- --
jim 343
bob 322
jane 122
Lets say i have a user defined function that applys a formula to the score
and I want to select the minimum value of the function.
eg.
SELECT name, score, MIN(dbo.alterScore(score))
FROM tester
I want to return the smallest value of the when the function is applied
along with the name and score.
How can I do this?
Many thanks.|||Why did you post the same question twice to the same group within 30 minutes
of each other?!
Your question was already answered (by multiple people) in your previous
thread titled "Easy SQL Problem"
"Mark Thomson" <@.@.@.> wrote in message
news:uZVc3NtjFHA.2852@.TK2MSFTNGP15.phx.gbl...
> I have a simple table that stores
> name score
> -- --
> jim 343
> bob 322
> jane 122
>
> Lets say i have a user defined function that applys a formula to the score
> and I want to select the minimum value of the function.
> eg.
> SELECT name, score, MIN(dbo.alterScore(score))
> FROM tester
>
> I want to return the smallest value of the when the function is applied
> along with the name and score.
> How can I do this?
> Many thanks.
>

No comments:

Post a Comment