Click here to Skip to main content
15,919,178 members
Home / Discussions / Database
   

Database

 
AnswerRe: Access Database is omitting the very first record and it returns the rest of the records Pin
PIEBALDconsult25-Mar-10 15:01
mvePIEBALDconsult25-Mar-10 15:01 
Questionneed good database structure for tracking counter state Pin
aki.oki25-Mar-10 2:54
aki.oki25-Mar-10 2:54 
AnswerRe: need good database structure for tracking counter state Pin
Mycroft Holmes25-Mar-10 14:49
professionalMycroft Holmes25-Mar-10 14:49 
QuestionUnable to Start MSSQL SERVER Pin
astrovirgin25-Mar-10 2:51
astrovirgin25-Mar-10 2:51 
AnswerRe: Unable to Start MSSQL SERVER Pin
R. Giskard Reventlov25-Mar-10 2:59
R. Giskard Reventlov25-Mar-10 2:59 
GeneralRe: Unable to Start MSSQL SERVER Pin
astrovirgin25-Mar-10 3:29
astrovirgin25-Mar-10 3:29 
GeneralRe: Unable to Start MSSQL SERVER Pin
R. Giskard Reventlov25-Mar-10 4:25
R. Giskard Reventlov25-Mar-10 4:25 
Questionhow to select a single row based on an aggregate SQL function result? Pin
michal.kreslik25-Mar-10 2:20
michal.kreslik25-Mar-10 2:20 
Hello,

let's have the following simple example. An SQL table consists of three columns:

RecordId,
GenerationId,
Fitness.

RecordId is a unique key. GenerationId and Fitness columns contain values that might and do repeat themselves over many rows.

Now how to do a simple select of the unique RecordId which has the highest Fitness, grouped by GenerationId?

Obviously,

SELECT max(Fitness) FROM myTable GROUP BY GenerationId

returns the highest Fitness for each GenerationId, but how to get the particular row which has this highest Fitness?

Fitness values might repeat themselves for the same GenerationId values, so an aggregate function also has to be used to select a distinct RecordId for a particular GenerationId. It doesn't matter which RecordId is selected as long as it has the highest Fitness for the particular GenerationId.

Thank you very much for any ideas!
Michal
AnswerRe: how to select a single row based on an aggregate SQL function result? Pin
michal.kreslik25-Mar-10 2:23
michal.kreslik25-Mar-10 2:23 
GeneralRe: how to select a single row based on an aggregate SQL function result? Pin
scottgp25-Mar-10 3:22
professionalscottgp25-Mar-10 3:22 
GeneralRe: how to select a single row based on an aggregate SQL function result? Pin
michal.kreslik25-Mar-10 3:39
michal.kreslik25-Mar-10 3:39 
GeneralRe: how to select a single row based on an aggregate SQL function result? Pin
i.j.russell25-Mar-10 4:34
i.j.russell25-Mar-10 4:34 
GeneralRe: how to select a single row based on an aggregate SQL function result? Pin
scottgp25-Mar-10 6:44
professionalscottgp25-Mar-10 6:44 
GeneralRe: how to select a single row based on an aggregate SQL function result? Pin
michal.kreslik31-Mar-10 23:21
michal.kreslik31-Mar-10 23:21 
QuestionProblem with SQL Query Pin
stanley1825-Mar-10 1:46
stanley1825-Mar-10 1:46 
AnswerRe: Problem with SQL Query Pin
Mschauder25-Mar-10 2:55
Mschauder25-Mar-10 2:55 
AnswerRe: Problem with SQL Query Pin
Jörgen Andersson26-Mar-10 11:23
professionalJörgen Andersson26-Mar-10 11:23 
Questionwhere the actual file is stored?? Pin
scorp_scorp25-Mar-10 1:05
scorp_scorp25-Mar-10 1:05 
AnswerRe: where the actual file is stored?? Pin
Jörgen Andersson25-Mar-10 1:22
professionalJörgen Andersson25-Mar-10 1:22 
GeneralRe: where the actual file is stored?? Pin
scorp_scorp26-Mar-10 7:22
scorp_scorp26-Mar-10 7:22 
GeneralRe: where the actual file is stored?? Pin
Jörgen Andersson26-Mar-10 9:47
professionalJörgen Andersson26-Mar-10 9:47 
QuestionAudit Trail and Entity Framework Pin
andreas.schaerer25-Mar-10 0:05
andreas.schaerer25-Mar-10 0:05 
AnswerRe: Audit Trail and Entity Framework Pin
Mycroft Holmes25-Mar-10 0:44
professionalMycroft Holmes25-Mar-10 0:44 
AnswerRe: Audit Trail and Entity Framework Pin
David Skelly25-Mar-10 3:18
David Skelly25-Mar-10 3:18 
AnswerRe: Audit Trail and Entity Framework Pin
scottgp25-Mar-10 3:33
professionalscottgp25-Mar-10 3:33 

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.