473,406 Members | 2,281 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,406 software developers and data experts.

Doing a group by query but need to sort on a different field

HI,

I am trying to do a group by such as this:
"select code, colors from productdb group by code, colors"

I need to sort on the key field, but cannot throw in the 'ordre by key',
because i will get that 'not part of an aggregate function error'

i could add it to the aggregate function, but it will return too many
records as I just want to return the unique code and color options.

what to do?

Nov 13 '05 #1
2 1569
"Danny" <da********@hotmail.com> wrote in message
news:N9**********************@news4.srv.hcvlny.cv. net...
HI,

I am trying to do a group by such as this:
"select code, colors from productdb group by code, colors"

I need to sort on the key field, but cannot throw in the 'ordre by key',
because i will get that 'not part of an aggregate function error'

i could add it to the aggregate function, but it will return too many
records as I just want to return the unique code and color options.

what to do?

select code, colors from productdb
group by code, colors
order by min(id)
Nov 13 '05 #2
Hi John,

WOW, that did it!!
You saved me much pain.

Thanks again
Danny

"John Winterbottom" <as******@hotmail.com> wrote in message
news:2s*************@uni-berlin.de...
"Danny" <da********@hotmail.com> wrote in message
news:N9**********************@news4.srv.hcvlny.cv. net...
HI,

I am trying to do a group by such as this:
"select code, colors from productdb group by code, colors"

I need to sort on the key field, but cannot throw in the 'ordre by key',
because i will get that 'not part of an aggregate function error'

i could add it to the aggregate function, but it will return too many
records as I just want to return the unique code and color options.

what to do?

select code, colors from productdb
group by code, colors
order by min(id)

Nov 13 '05 #3

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

Similar topics

4
by: Yonatan Maman | last post by:
Hi Im using access 2000. and I have a strange problem. when I execute a query on TABLE_A (TABLE_A contains 2 colums: "id" INTEGER and "name" MEMO) Query1: "select id, name from TABLE_A ORDER BY...
6
by: neptune | last post by:
I must be missing something obvious. I have 3 fields and sample data. 7890 26592 7/15/2003 7890 13645 10/6/1999 7890 58741 6/21/1992 I...
4
by: Philippe | last post by:
Hello, I encounter a problem that I cannot solve myself... The problem is the following: I make a table: several records: the first field is always a number, the following field is always...
4
by: Gordon White | last post by:
I'm working on a DB for a local 5K race. I want to make the DB as flexible as possible and to avoid hard coding anything that I don't need to so that we can reuse this for other races. As such, I...
4
by: Stefan Kowalski | last post by:
I recently posted a question which was answered by Allen Browne and gave me some tips to structure the tables. However, when it comes to searching the database, performance is unacceptably slow...
27
by: Greg Smith | last post by:
Hello, I have been given a programming task that falls into the "impossible" category with my current skill set. I am hoping somebody out there knows how to do this and can save my b-t. I...
1
by: A_PK | last post by:
I got one field, NOTE, its type is Ntext field. I have problem when query the statement using GROUP BY, could some pls kindly guide me. please found the sql query below... SELECT...
14
by: Tina | last post by:
My employer tracks productivity/performance of clinicians (how much they bill) each week, its averages for the month, and the 6 months. These averages are compared to their expected productivity....
0
prabirchoudhury
by: prabirchoudhury | last post by:
CRITERIA; +-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.