Click here to Skip to main content
15,909,503 members
Home / Discussions / Database
   

Database

 
Question'Best practices' info needed [modified] Pin
Gary Wheeler14-Jun-06 10:49
Gary Wheeler14-Jun-06 10:49 
AnswerRe: 'Best practices' info needed Pin
Colin Angus Mackay14-Jun-06 11:10
Colin Angus Mackay14-Jun-06 11:10 
GeneralRe: 'Best practices' info needed Pin
Gary Wheeler15-Jun-06 1:18
Gary Wheeler15-Jun-06 1:18 
QuestionDAO - Stored Procedure Execution Pin
KSMANN14-Jun-06 9:32
KSMANN14-Jun-06 9:32 
QuestionSystem.Data.DBConcurrencyException Pin
IMC200614-Jun-06 7:30
IMC200614-Jun-06 7:30 
Questionsqldataadapter sqlcommandbuilder stripping off identity column HELP??? Pin
isgrom14-Jun-06 7:16
isgrom14-Jun-06 7:16 
QuestionAggregation function error Pin
tadhg8814-Jun-06 4:02
tadhg8814-Jun-06 4:02 
AnswerRe: Aggregation function error Pin
Colin Angus Mackay14-Jun-06 5:34
Colin Angus Mackay14-Jun-06 5:34 
You've not told it how to group the averages, so it does not know of which to return the MAX().

SELECT matchid, AVG((CASE Code WHEN 'A' THEN 4.0 
                               WHEN 'B' THEN 3.0 
                               WHEN 'C' THEN 2.0 
                               WHEN 'D' THEN 1.0 
                               ELSE 0.0 END)
FROM ScoutingReport AS sr
WHERE sr.Type = 1
AND sr.ScoutId = 11619
GROUP BY matchid


The above will return the average for each matchid
If you want to find the MAX() of that then
SELECT MAX(average)
FROM
(
    SELECT matchid, AVG((CASE Code WHEN 'A' THEN 4.0 
                                   WHEN 'B' THEN 3.0 
                                   WHEN 'C' THEN 2.0 
                                   WHEN 'D' THEN 1.0 
                                   ELSE 0.0 END) AS average
    FROM ScoutingReport AS sr
    WHERE sr.Type = 1
    AND sr.ScoutId = 11619
    GROUP BY matchid
)


If that doesn't give you the answer you want then you might need to explain more how you want the calculation to work.


Scottish Developers upcoming sessions include:
.NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy

My: Website | Blog
GeneralRe: Aggregation function error Pin
tadhg8814-Jun-06 6:39
tadhg8814-Jun-06 6:39 
GeneralRe: Aggregation function error Pin
Colin Angus Mackay14-Jun-06 8:16
Colin Angus Mackay14-Jun-06 8:16 
GeneralRe: Aggregation function error [modified] Pin
tadhg8822-Jun-06 4:31
tadhg8822-Jun-06 4:31 
Questiondo tasks perodically on SQL Server 2000 Pin
{darkside}14-Jun-06 3:22
{darkside}14-Jun-06 3:22 
AnswerRe: do tasks perodically on SQL Server 2000 Pin
ToddHileHoffer14-Jun-06 3:33
ToddHileHoffer14-Jun-06 3:33 
AnswerRe: do tasks perodically on SQL Server 2000 Pin
Frank Kerrigan15-Jun-06 5:03
Frank Kerrigan15-Jun-06 5:03 
GeneralRe: do tasks perodically on SQL Server 2000 [modified] Pin
{darkside}21-Jun-06 11:39
{darkside}21-Jun-06 11:39 
QuestionDatabase design question [modified] Pin
ToddHileHoffer14-Jun-06 2:34
ToddHileHoffer14-Jun-06 2:34 
AnswerRe: Database design question [modified] Pin
Colin Angus Mackay14-Jun-06 5:38
Colin Angus Mackay14-Jun-06 5:38 
GeneralRe: Database design question Pin
Eric Dahlvang14-Jun-06 6:16
Eric Dahlvang14-Jun-06 6:16 
GeneralRe: Database design question Pin
ToddHileHoffer14-Jun-06 7:44
ToddHileHoffer14-Jun-06 7:44 
Questionwhere to store big data? Pin
Yelow14-Jun-06 1:58
Yelow14-Jun-06 1:58 
AnswerRe: where to store big data? Pin
albCode14-Jun-06 2:06
albCode14-Jun-06 2:06 
GeneralRe: where to store big data? Pin
Yelow14-Jun-06 2:53
Yelow14-Jun-06 2:53 
GeneralRe: where to store big data? Pin
jonathan1514-Jun-06 4:43
jonathan1514-Jun-06 4:43 
GeneralRe: where to store big data? Pin
r.stropek15-Jun-06 0:32
r.stropek15-Jun-06 0:32 
QuestionFull Text Search(Sql Server 2005) Pin
fetras14-Jun-06 0:54
fetras14-Jun-06 0:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.