Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert text to number find Max

Status
Not open for further replies.

HomeGrowth

Technical User
Joined
Aug 19, 2004
Messages
76
Location
US
I have these records

DocNumber, VersionNumber(text field)
A,1.0
B,1.0
B,2.0
c,9.0
c,10.0

The result that i want is
A,1.0
B,2.0
c,10.0

In query, I convert the VersionNumber from text to number using CInt(VersionNumber). Now I want to find out which is the Max. In define the Totals, DocNumber is Group By and VersionNumber is Max. Access returned an error stating 'Data type mismatch in criteria expression'.
 




Code:
Select [b]DISTINCT[/b] ......

Skip,

[glasses]Did you hear what happened when the OO programmer lost his library?...
He's now living in OBJECT poverty![tongue]
 
SELECT DocNumber, Max(Val(VersionNumber))
FROM yourTable
GROUP BY DocNumber

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV

Thank for the sql code, it work fine. How do I retrieve the rest of the fields that belong to these record?
 
List them in the SELECT and GROUP BY e.g.
Code:
SELECT DocNumber, Field2, Field3, Max(Val(VersionNumber))
FROM yourTable
GROUP BY DocNumber, Field2, Field3
Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top