468,539 Members | 1,618 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,539 developers. It's quick & easy.

most recent, min/max query

hello-

i have a sample database that i want to query for most recent SAMPLE,
min SAMPLE_RESULT, and max SAMPLE_RESULT.

the table is orgainzed as such:
SAMPLE | SAMPLE_DATE | SAMPLE_TIME | SAMPLE_RESULT

any ideas?

Nov 13 '05 #1
1 1307
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If possible, you should put the sample_date & time in one column, it
will eliminate the need to create an expression in the WHERE clause that
creates a DateTime data type. Since you don't give a DDL definition of
your table I'll have to guess at the data types. I'll assume that your
sample_date & time are stored as DateTime data types. If they aren't
DateTimes you have to convert them using the CDate() function before
adding them together. Note that #3:30# is 3:30 AM (0330) and #03:30PM#
is 3:30 PM (1530).

Just a guess:

SELECT sample, Min(sample_result) As min_result, Max(sample_result) as
max_result
FROM table_name as t
WHERE sample_date + sample_time =
(SELECT Min(sample_date + sample_time)
FROM table_name
WHERE sample = t.sample)

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQgzzYIechKqOuFEgEQJV7gCg1hDXXhtf7JQvZoI315JRPo E3Vw0AoJU3
1r2ZLlYyylNhERy9aWh3YSsN
=W7eX
-----END PGP SIGNATURE-----
getyourbiglobster wrote:
hello-

i have a sample database that i want to query for most recent SAMPLE,
min SAMPLE_RESULT, and max SAMPLE_RESULT.

the table is orgainzed as such:
SAMPLE | SAMPLE_DATE | SAMPLE_TIME | SAMPLE_RESULT

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by manny | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.