MySQL Forums
Forum List  »  Newbie

min and max function
Posted by: John More
Date: January 31, 2017 02:52PM

I am having trouble with the max function and I am not sure it is me or the software. I have a table with and id a value, a timestamp, and a sequence number in each row.
This query returns the following results
SELECT
deviceIdText,
value,
sequenceNumber,
timestamp
FROM
DevicesTelemetry.TMMeterCount where deviceId = x'0a17216927655931bd40b43971aae394' and day(timestamp) = 10;

deviceIdText value sequenceNumber timestamp
0A172169-2765-5931-BD40-B43971AAE394 99933 42975 2016-02-10 10:35:45
0A172169-2765-5931-BD40-B43971AAE394 99940 42980 2016-02-10 10:37:36
0A172169-2765-5931-BD40-B43971AAE394 99941 42987 2016-02-10 10:38:21
0A172169-2765-5931-BD40-B43971AAE394 99942 43005 2016-02-10 10:41:20
0A172169-2765-5931-BD40-B43971AAE394 99946 43006 2016-02-10 10:41:42
0A172169-2765-5931-BD40-B43971AAE394 99954 43019 2016-02-10 10:42:49
0A172169-2765-5931-BD40-B43971AAE394 99961 43028 2016-02-10 10:44:18
0A172169-2765-5931-BD40-B43971AAE394 99970 43033 2016-02-10 10:45:25
0A172169-2765-5931-BD40-B43971AAE394 99972 43035 2016-02-10 10:45:47
0A172169-2765-5931-BD40-B43971AAE394 99981 43044 2016-02-10 10:46:54
0A172169-2765-5931-BD40-B43971AAE394 99989 43054 2016-02-10 10:48:24
0A172169-2765-5931-BD40-B43971AAE394 99991 43062 2016-02-10 10:49:31
0A172169-2765-5931-BD40-B43971AAE394 99998 43065 2016-02-10 10:49:53
0A172169-2765-5931-BD40-B43971AAE394 99990 43083 2016-02-10 10:52:41

This next query I am expecting to return the min and maximum for the range returned above. As you can see the maximum value returned is the value from the second-last row of the available data. Any assistance you can provide is greatly appreciated. Thanks
SELECT
deviceIdText,
min(value) as minimum,
max(value) as maxiumum
FROM
DevicesTelemetry.TMMeterCount where deviceId = x'0a17216927655931bd40b43971aae394' and day(timestamp) = 10
group by day(timestamp);

deviceIdText minimum maxiumum
0A172169-2765-5931-BD40-B43971AAE394 99933 99998

Options: ReplyQuote


Subject
Written By
Posted
min and max function
January 31, 2017 02:52PM
January 31, 2017 03:22PM
January 31, 2017 03:48PM
January 31, 2017 05:50PM
January 31, 2017 08:49PM
January 31, 2017 09:20PM
January 31, 2017 10:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.