473,507 Members | 12,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Max Value AND Date it Occurred

Hi,

I have a lot of sample records done on different dates. It's easy to
get the maximum value for any sample parameter for any sample location,
but what if I want the date it was found?

For example, if I have a thousand locations and 20 parameters measured
at each loocation, and this sampling went on every day for a year, I
want to get the maximum value for each parameter at each location, AND
I want the data on which the maximum was found. Can I do that with one
SQL call? I can't get it.
I'm happy to write the query in SQL if need be.

Cheers,
Gary Ostroff

Nov 13 '05 #1
1 1837
go******@hydroqual.com wrote:
Hi,

I have a lot of sample records done on different dates. It's easy to
get the maximum value for any sample parameter for any sample location,
but what if I want the date it was found?

For example, if I have a thousand locations and 20 parameters measured
at each loocation, and this sampling went on every day for a year, I
want to get the maximum value for each parameter at each location, AND
I want the data on which the maximum was found. Can I do that with one
SQL call? I can't get it.
I'm happy to write the query in SQL if need be.


I certainly don't do this in one query. Anybody please teach me how.

Create a query that groups by parameter/location, and takes the max of
the date

Use this query in a join to the original table, linking location,
parameter name, and maxofdate, respectively, to location, parameter
name, and date -- of course --

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #2

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

Similar topics

5
3968
by: amber | last post by:
Hello, I'm not sure if this question should go in the SQL forum or this one... I'm using VB.NET and SQL Server. I'm using stored procedures to update and create new records in my database. On...
1
2461
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
1
1189
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
6
7970
by: amber | last post by:
Hello, I'm not sure if this question should go in the SQL forum or this one... I'm using VB.NET and SQL Server. I'm using stored procedures to update and create new records in my database. On...
2
2608
by: Hexman | last post by:
Hello All, Well I'm stumped once more. Need some help. Writing a simple select and update program using VB.Net 2005 and an Access DB. I'm using parameters in my update statement and when trying...
0
7221
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
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
7313
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,...
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...
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
1537
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 ...

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.