I have a table in which minimum and maximum temperature is stored per order no and date. I want to pick the minimum temperature and maximum temperature for each day. This should be done using SQL script.
Asked
Active
Viewed 2,045 times
-4
-
1The question lacks research or trial from the askers side. – Mistu4u Oct 24 '12 at 09:07
2 Answers
0
You have to use group by
clause, and aggregate functions min
, max
as below:
select date, min(temperature), max(temperature)
from table
group by date
It will work if your date
have only year, month and day (01/11/2012).

Robert
- 25,425
- 8
- 67
- 81
0
In oracle:
SELECT TO_CHAR(DATE_VAL,'DD-MM-YYYY'), MAX(temperature),
MIN(temperature) FROM table_name group by TO_CHAR(DATE_VAL,'DD-MM-YYYY');
In MySQl:
SELECT DATE_FORMAT(DATE_VAL, '%d-%m-%Y'), max(temperature),
min(temperature) from table_name group by DATE_FORMAT(DATE_VAL, '%d-%m-%Y');

Md. Kamruzzaman
- 1,895
- 16
- 26