Re: maxrecords property doesn't work for me
- From: PKI_Dave <PKIDave@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 24 Jan 2008 06:35:00 -0800
Bob,
Thanks for the help. I just implemented your SQL statement and tested it.
It works great. I don't know SQL very well, so I tried implementing the
solution with code before asking for help. Your solution is quite elegant.
Thanks
"Bob Barrows [MVP]" wrote:
Bob Barrows [MVP] wrote:.
PKI_Dave wrote:
Thanks. I'll give it a try if it results in what I need.
It isn't the same as the five lowest scores
since it will need to disregard scores posted prior to the 10th
oldest.
That's what my suggested query does.
The real
logic required makes this a little difficult. What I want is to find
the 10 most recent records and then sum the lowest 5 scores from
these last 10 records.
Well that can be accomplished by a further subquery
strSQL = "SELECT SUM(q1.CurrentDifferential) as scoretotal " & _
"FROM (
"SELECT TOP 5 q.ScoreDate, q.CurrentDifferential " & _
"FROM (" & _
"SELECT TOP 10 ScoreDate, CurrentDifferential FROM Score " & _
"WHERE PlayerName = '" & strPlayersName & _
"' ORDER BY ScoreDate DESC) As q " & _
"ORDER BY q.ScoreDate ASC) As q1"
Ah. Another problem - not really a typo. It should be:
strSQL = "SELECT SUM(q1.CurrentDifferential) as scoretotal " & _
"FROM (
"SELECT TOP 5 q.ScoreDate, q.CurrentDifferential " & _
"FROM (" & _
"SELECT TOP 10 ScoreDate, CurrentDifferential FROM Score " & _
"WHERE PlayerName = '" & strPlayersName & _
"' ORDER BY ScoreDate DESC) As q " & _
"ORDER BY q.CurrentDifferential ASC) As q1"
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
- Follow-Ups:
- Re: maxrecords property doesn't work for me
- From: Stephen Howe
- Re: maxrecords property doesn't work for me
- References:
- Re: maxrecords property doesn't work for me
- From: Bob Barrows [MVP]
- Re: maxrecords property doesn't work for me
- From: Bob Barrows [MVP]
- Re: maxrecords property doesn't work for me
- From: Bob Barrows [MVP]
- Re: maxrecords property doesn't work for me
- From: Bob Barrows [MVP]
- Re: maxrecords property doesn't work for me
- Prev by Date: Re: Newbie
- Next by Date: Problem with ODBC Connection Strings
- Previous by thread: Re: maxrecords property doesn't work for me
- Next by thread: Re: maxrecords property doesn't work for me
- Index(es):
Relevant Pages
|