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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort/Group Question

Status
Not open for further replies.

Imconfused

Technical User
Aug 25, 2003
12
US
I need to perform a sort within my query or create a sub query that performs the needed function. Within a particular field, each record contains a 5 digit numeric value. I need to sort/group this field based on the last digit of the numeric value of each record. I feel like I may need to create sub-queries that will perform this function based on each specific numeric value (last digit) which it may be any number from 1 to 7 (therefore creating 7 sub-queries).
1. How do I sort/group based on the last digit?
2. Are sub-queries the best way of maintaining separate groupings (these will be used to produce reports based on the groupings)?
 
Try something like this:

SELECT RIGHT(FIELDNAME, 1) FROM TABLENAME GROUP BY RIGHT(FIELDNAME, 1)
 
Les,

I'm not sure I understand. Is this an expression?
 
Add a new field that looks like this:

TheNumber: right([fieldname],1)

That will give you the last digit on its own and allow you to sort by that if that's what you mean. If you need totals by this digit then you can make it a summary query and group by this field too. Explain your situation a little more if you're still confused.

Kevin
 
Hence, my name: I'm Confused

But it worked just fine, thanks for the help, this is a lot better than trying to figure it out by reading "Access For Dummies".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top