음..그러니까 날짜별로 값을 평균내서 가져와야 되는데 조건이 날짜가 인터벌 된다는 것인데요.즉 특정일로부터 원하는 일까지 하루씩끊어서 해당하는 평균값을 가져와야 되요.나중에 호환문제때문에 왠만하면 내장 프로시져로 작성하면 안되구요 쿼리로 해결을 봐야 하는데.지금은 허접하게 union을 써서
select avg("Price") from "Order" where "Date">1046185200 and "Date"<=1046185200+3600 union all select avg("Price") from "Order" where "Date">1046185200+3600 and "Date"<=1046185200+3600*2 union all select avg("Price") from "Order" where "Date">1046185200+3600*2 and "Date"<=1046185200+3600*3 union all select avg("Price") from "Order" where "Date">1046185200+3600*3 and "Date"<=1046185200+3600*4 union all select avg("Price") from "Order" where "Date">1046185200+3600*4 and "Date"<=1046185200+3600*5 union all select avg("Price") from "Order" where "Date">1046185200+3600*5 and "Date"<=1046185200+3600*6 union all select avg("Price") from "Order" where "Date">1046185200+3600*6 and "Date"<=1046185200+3600*7 union all select avg("Price") from "Order" where "Date">1046185200+3600*7 and "Date"<=1046185200+3600*8 union all select avg("Price") from "Order" where "Date">1046185200+3600*8 and "Date"<=1046185200+3600*9 union all select avg("Price") from "Order" where "Date">1046185200+3600*9 and "Date"<=1046185200+3600*10 union all select avg("Price") from "Order" where "Date">1046185200+3600*10 and "Date"<=1046185200+3600*11 union all select avg("Price") from "Order" where "Date">1046185200+3600*11 and "Date"<=1046185200+3600*12 union all select avg("Price") from "Order" where "Date">1046185200+3600*12 and "Date"<=1046185200+3600*13 union all select avg("Price") from "Order" where "Date">1046185200+3600*13 and "Date"<=1046185200+3600*14 union all select avg("Price") from "Order" where "Date">1046185200+3600*14 and "Date"<=1046185200+3600*15 union all select avg("Price") from "Order" where "Date">1046185200+3600*15 and "Date"<=1046185200+3600*16 union all select avg("Price") from "Order" where "Date">1046185200+3600*16 and "Date"<=1046185200+3600*17 union all select avg("Price") from "Order" where "Date">1046185200+3600*17 and "Date"<=1046185200+3600*18 union all select avg("Price") from "Order" where "Date">1046185200+3600*18 and "Date"<=1046185200+3600*19 union all select avg("Price") from "Order" where "Date">1046185200+3600*19 and "Date"<=1046185200+3600*20 union all select avg("Price") from "Order" where "Date">1046185200+3600*20 and "Date"<=1046185200+3600*21 union all select avg("Price") from "Order" where "Date">1046185200+3600*21 and "Date"<=1046185200+3600*22 union all select avg("Price") from "Order" where "Date">1046185200+3600*22 and "Date"<=1046185200+3600*23 union all select avg("Price") from "Order" where "Date">1046185200+3600*23 and "Date"<=1046185200+3600*24;
이렇게 했는데...값은 확실히 나오는데..시간이 무지하게 걸려요.다른대안이 없을까 해서 이곳에 올렸어요.제 생각으로는 임시테이블에 검색된 모든 값을 올려 놓고 위처럼 쿼리를 날리는 건데요.데이터가 몇만개가 되서 속도가 보장이 안되네요. 좀 살려주세요 고수님ㅜ.ㅜ
|