473,666 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1584
"Danny" <da********@hot mail.com> wrote in message
news:N9******** **************@ news4.srv.hcvln y.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******@hotma il.com> wrote in message
news:2s******** *****@uni-berlin.de...
"Danny" <da********@hot mail.com> wrote in message
news:N9******** **************@ news4.srv.hcvln y.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
3740
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 name" . I get my results OK :-) when I extend the query and make a join with TABLE_B (conatins 2 coulmd "ref_to_tableA" INTEGER and "value" INTEGER)
6
5096
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 want to select only the most recent record. It is sorted descending by in the query and subquery. In the query Total, I select Group By , First and First
4
1444
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 an address
4
1702
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 can't figure out how to determine the racers age group even though it seems like it should be pretty easy. Below are some of the fields and example data in two tables: tblRacers IdRacers 1 2 FirstName Bill Bob
4
1290
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 and I am now thinking of doing the unthinkable with my tables and wonder whether anyone has used (or still uses) this sort of approach. The database stores libraries and classifies the types of book they keep. So I have the classic 3-table...
27
1903
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 work for a large University. I wrote a Windows-based database application for my department that is used in purchasing. The University has just released Web-base application that does the same thing using a sub set of the data that my application...
1
2844
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 tblParent.indexno, tblParent.custno, tblParent.compname, tblParent.tt, tblParent.ordnotes FROM tblParent INNER JOIN tblChild ON tblParent.tid = tblChild.tid
14
3483
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. However, the expectation changes - it may be 60% for a while, then change to 50%. Initially, I was averaging the expectation, along with the productivity, but what I'm being asked is to look at the average productivity/performance compared to...
0
3063
prabirchoudhury
by: prabirchoudhury | last post by:
CRITERIA; +-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+ | CritCode | int(4) | NO | PRI | 0 | | | Description | varchar(150) | YES | | NULL | | | CritGroup | varchar(10) | YES | | NULL | | | Detail | varchar(30) | YES | | NULL | ...
0
8454
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8787
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8645
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6203
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.