View Full Version : sort query question


bar891
05-29-2008, 02:16 AM
How do i sort a query by one column that sort that information by another column?

Many Thanks

DCrake
05-29-2008, 02:56 AM
Rephrase you request using proper grammar then we may be able to help:(

bar891
05-29-2008, 03:37 AM
ok sorry,
I'm making a query of a table that has a column of item numbers and another column of item types. What is the best way to sort the item types and then sort that result by the item numbers.

DCrake
05-29-2008, 03:51 AM
It all depends on how you are using this query. If you are going to populate a listbox or combobox then sort by the name. People will find it easier to find items if they are sorted a-z.

David

bar891
05-29-2008, 04:15 AM
Does that mean i can't sort a sort (so too speak)?

DCrake
05-29-2008, 04:33 AM
Can't quite grasp what you are trying to achieve:confused: Can you give me an example of what you are attempting to do.

David

MSAccessRookie
05-29-2008, 05:48 AM
As I understand it, the table (or query) has two different columns to sort by, and I would think that something like this might work:

SELECT { List of Columns to Select }
FROM {Table / Query Name }
ORDER BY { Item Type Column Name }, { Item Number Column Name }

This will extract a list first ordered by Item Type, then ordered by Item number within each type. If Not, then I misunderstand and await a proper solution

georgedwilkinson
05-29-2008, 05:50 AM
Yes, you can sort by a number of criteria all at once (even things not in the query). In the SQL for your sort, you include an "order by" clause:

order by itemtype, itemnumber, someotherfieldnotinquery

You can get started in the visual query building tool by filling in the "Sort" field. Then make it work right by going to SQL view and fixing the order by clause.

MSAccessRookie
05-29-2008, 06:00 AM
Yes, you can sort by a number of criteria all at once (even things not in the query). In the SQL for your sort, you include an "order by" clause:

order by itemtype, itemnumber, someotherfieldnotinquery

You can get started in the visual query building tool by filling in the "Sort" field. Then make it work right by going to SQL view and fixing the order by clause.

Thanks George,

I come from an Oracle Background, so I think in terms of SQL Tools most of the time. I am still getting used to thinking in terms of the MS Access Tools.

georgedwilkinson
05-29-2008, 06:26 AM
If you use Oracle, it should be easier for you to just use SQL view all the time (that's what I do).