473,507 Members | 3,706 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Find maximum value in one field per each group

I need a stored procedure or other method to find the maximum value
for each set of records. I would want to eliminate all of the non-
maximum records. An example of the data is below. For the example
below, I would want to return record 2,6,7, and 10. To pick between 7
and 8, I would want to pick the one with the minimum ID. Can anyone
supply some sample code? Note that some people may have only one
record.
ID Person Salary
1 44 20000
2 44 22000
3 44 21000
4 45 50000
5 45 51000
6 45 53000
7 46 45000
8 46 45000
9 46 40000
10 47 10000

Aug 4 '07 #1
1 3947
http://www.mvps.org/access/queries/qry0020.htm

ar****@yahoo.com wrote:
I need a stored procedure or other method to find the maximum value
for each set of records. I would want to eliminate all of the non-
maximum records. An example of the data is below. For the example
below, I would want to return record 2,6,7, and 10. To pick between 7
and 8, I would want to pick the one with the minimum ID. Can anyone
supply some sample code? Note that some people may have only one
record.
ID Person Salary
1 44 20000
2 44 22000
3 44 21000
4 45 50000
5 45 51000
6 45 53000
7 46 45000
8 46 45000
9 46 40000
10 47 10000
Aug 4 '07 #2

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

Similar topics

8
2946
by: Siemel Naran | last post by:
Hi. I have a table of products and versions, and these 2 columns are the unique key. My challenge is to write a SQL statement to find the latest version of each product. My solutions below...
0
5271
by: Matt | last post by:
I am running CR 8.5 from a (large) SQL Server db. My aim is to use crystal enterprise so end users in our sales team can access reports on demand for a given date range and client so I am trying...
1
1909
by: K. Davis | last post by:
I need to increment the maximum value of a field of a table by 1 when a form opens a blank record. (e.g. =max(!![trip_number}) so the logic and references are working at the form level. I've...
0
1797
by: JR | last post by:
Hi, i found a user control on the net see code below it is part of VSEssential but I like the coolProgressBar. Zo I want to use it into my program and I always get the error that it can't find...
1
2248
by: VG | last post by:
Hi folks, I have procedure that I am using to assign ID number vs Autonumber. It is working fine but something going wrong with my form that I have to replace the form with old version to make...
3
10894
by: jshunter | last post by:
Does anyone know of a built-in function to return the maximum possible value of a given datatype? I have to return the biggest value for a smalldatetime or datetime in a view if the field is null,...
2
2681
by: MyGreatProgramme | last post by:
I want to make a delete query that deletes all the items that are in the minorty. For example, in the field " Houses " there are 10 rows with value 1 , 3 rows with value 3 and 4 rows with...
2
6640
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
4
3938
by: SjaakBanaan | last post by:
Hey all, I have a question that ought to be simple but has given me headaches for a while. I have a table with contact email addresses, say. T ID ContID Priority Emailaddress...
0
7109
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
7372
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...
1
7029
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
7481
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
5619
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,...
1
5039
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...
0
3190
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.