아래와 같은 매 시간 리포트 테이블이 있습니다.
MinV MaxV MinTime MaxTime
-32673 31258 2011-05-24 14:30:18.000 2011-05-24 14:27:23.000
-32090 32328 2011-05-24 21:23:28.000 2011-05-24 21:45:37.000
-32724 32752 2011-05-24 22:40:25.000 2011-05-24 22:57:19.000
-32645 32745 2011-05-24 23:12:46.000 2011-05-24 23:00:14.000
-29316 27671 2011-05-24 16:34:24.000 2011-05-24 15:33:16.000
-30567 32678 2011-05-24 20:55:28.000 2011-05-24 20:57:14.000
DiffMinV DiffMaxV DiffMinTime DiffMaxTime
-46964 61726 2011-05-24 14:19:44.000 2011-05-24 14:19:50.000
-55024 61726 2011-05-24 21:15:34.000 2011-05-24 21:13:18.000
-50188 61726 2011-05-24 22:31:55.000 2011-05-24 22:01:04.000
-61287 61726 2011-05-24 23:02:21.000 2011-05-24 23:01:09.000
-55024 39343 2011-05-24 15:33:19.000 2011-05-24 15:33:31.000
-48576 61725 2011-05-24 20:59:27.000 2011-05-24 20:53:45.000
위는 하나의 테이블 입니다.
하루중에
min(MinV), MinTime
max(MaxV), MaxTime
min(DiffMinV), DiffMinTime
max(DiffMaxV), DiffMaxTime
을 한 쿼리로 한번에 구할 수 있는 방법이 없나요?
지금은 그냥
쿼리 네번 날립니다.
SELECT top 1
[MinV]
,[MinTime]
FROM ReportHourTable where [_oleReportDateTime]>= '2011-5-24 0:0:0' and [_oleReportDateTime]<= '2011-5-24 23:0:0' and _ID=1 order by [MinV] asc
SELECT top 1
[MaxV]
,[MaxTime]
FROM ReportHourTable where [_oleReportDateTime]>= '2011-5-24 0:0:0' and [_oleReportDateTime]<= '2011-5-24 23:0:0' and _ID=1 order by [Max] desc
.
.
좀 좋은 방법 없을까요?
|