473,396 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Custom sorting and grouping in a query

Hello everyone,

I have a table with many columns. Two of them are VehicleNumber and
ShipDate. What I would like to do is sort all the data in ascending
date(ShipDate) but I also like to group the matching VehicleNumber
together at the same time(If they have same ShipDate; please note
grouping here means putting them in adjacent rows). VehicleNumber does
not need to get grouped together when they have different ShipDate. I
try simple queries but I keep getting "VehicleNumber not part of
aggregate function" and etc. Maybe my problem is because I am trying to
group VehicleNumber while my other fields have different values, as you
can see for example the Size column.

my sample table:
VehicleNumber ShipDate ... Size
123 9/9/2004 5
434 9/10/2004 5
123 9/9/2004 16
123 9/13/2004 4

my output query:
VehicleNumber ShipDate ... Size
123 9/9/2004 5
123 9/9/2004 16
434 9/10/2004 5
123 9/13/2004 4

Thank You a whole lot for helping me out.
Jim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #1
3 4877
Hi Jimmy,

I think you have two choices here:

[1] A simple select statement with an 'order by' ShipDate, VehicleNumber,
Size.
This would return a sorted listing of every record.

[2] A 'group by' statement:
Select ShipDate, VehicleNumber from tablename Group By ShipDate,
Vehicle Number.
In this case you must omit the Size field.

Suggest you try both, look at the listings and see if either will meet your
needs.

HTH -Linda

"Jimmy Tran" <hu*******@yahoo.com> wrote in message
news:41**********************@news.newsgroups.ws.. .
Hello everyone,

I have a table with many columns. Two of them are VehicleNumber and
ShipDate. What I would like to do is sort all the data in ascending
date(ShipDate) but I also like to group the matching VehicleNumber
together at the same time(If they have same ShipDate; please note
grouping here means putting them in adjacent rows). VehicleNumber does
not need to get grouped together when they have different ShipDate. I
try simple queries but I keep getting "VehicleNumber not part of
aggregate function" and etc. Maybe my problem is because I am trying to
group VehicleNumber while my other fields have different values, as you
can see for example the Size column.

my sample table:
VehicleNumber ShipDate ... Size
123 9/9/2004 5
434 9/10/2004 5
123 9/9/2004 16
123 9/13/2004 4

my output query:
VehicleNumber ShipDate ... Size
123 9/9/2004 5
123 9/9/2004 16
434 9/10/2004 5
123 9/13/2004 4

Thank You a whole lot for helping me out.
Jim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #2
What if I need to have all the other fields in the query and I only
want to group by Vehicle # and order by SHIP DATE. Is it possible to
do without getting the aggregrate error from Access?
Nov 13 '05 #3
hu*******@yahoo.com (Jimmy) wrote in message news:<fc**************************@posting.google. com>...
What if I need to have all the other fields in the query and I only
want to group by Vehicle # and order by SHIP DATE. Is it possible to
do without getting the aggregrate error from Access?


Create a select query, include your totals query and then throw in any
fields you want. And while you're at it, have a beer and a smoke.
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jur Schagen | last post by:
I have this weird sorting problem. I have a report that is based on a query. The query is sorted on field A, and if I run it seperately it is decently sorted on that field. However, if I call the...
3
by: Mat N | last post by:
Hi, I've been trying to work out how to create a report based on crosstab query for which the number of fields is variable. For example in a situation where you show customer billing by year in...
8
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
5
by: Mike | last post by:
Hello All, I have a report based upon a query. I have added a control to report footer that calcs the total cost of the inventory: =SUM(). When this total calculation is NOT on the report,...
1
by: jnikle | last post by:
I have a ProdMonth header/footer in a report that groups my data by month. The problem is that I need to group by fiscal month rather than calendar month, in this particular case 5/30/05 to...
8
by: nn0410 | last post by:
I have a report whose record source is a query. The query includes an ORDER BY clause that sorts on a particular set of columns. I would like to be able to run the same report with the same input...
5
by: Ralph | last post by:
Hi Everyone, I need some help!! I'm not sure if you could do this, but I want to be able to create a report based on one field in the database. This field contains File Paths like for example: ...
3
by: Jimmy | last post by:
Is there a way to sort/group a report based on the second column of a combo box, i.e. the text associated with the primary key number?
13
by: CD Tom | last post by:
I have a simple report that has two control sources (queries) each query has a different sort sequence. I'm using the db.querydef to change the query's sort option. When I run the report no sorting...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.