Re: Ranking Dates
- From: John W. Vinson <jvinson@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Aug 2007 13:19:09 -0600
On Fri, 24 Aug 2007 18:37:07 GMT, "ekomsky via AccessMonster.com" <u36881@uwe>
wrote:
I have a table called MLS DATA i am trying to rank the dates in it. i just
want a value 1 being the highest date and or the lowest, and so forth.
Which way to ranking goes doesn't matter. Here is my SQL Statement. It
won't work. Thank you in advace for any help.
DateRank: (SELECT COUNT(*) FROM [MLS DATA] WHERE [Invoice_Date]<=[MLS DATA].
[Invoice_Date])
[Invoice_Date] is thefield i'm trying to rank
Hah. Second looks are always useful...
This subquery is returning the count of records for which the invoice date is
less than or equal to itself... i.e. every record in the table. If you were to
change the <= to < then you would get zero hits, since no date is less than
itself!
You need to reference the [MLS DATA] table with an alias, so that you have two
instances of it - the one in the "outer" query and the one in the subquery.
Try
DateRank: (SELECT COUNT(*) FROM [MLS DATA] AS SQ WHERE
[SQ].[Invoice_Date]<=[MLS DATA].[Invoice_Date])
John W. Vinson [MVP]
.
- Follow-Ups:
- Re: Ranking Dates
- From: ekomsky via AccessMonster.com
- Re: Ranking Dates
- References:
- Ranking Dates
- From: ekomsky via AccessMonster.com
- Ranking Dates
- Prev by Date: Re: Ranking Dates
- Next by Date: Re: Ranking Dates
- Previous by thread: Re: Ranking Dates
- Next by thread: Re: Ranking Dates
- Index(es):
Relevant Pages
|