日期:2014-05-17 浏览次数:20771 次
CREATE TABLE NMPurchase ( ID NUMBER(3), MyDate DATE, COST NUMBER(4, 1) ); DELETE T190; INSERT INTO NMPurchase VALUES(1, to_date('2010-01-02 08:23:59', 'YYYY-MM-DD HH24:MI:SS'), 23.5); INSERT INTO NMPurchase VALUES(2, to_date('2010-01-02 09:23:59', 'YYYY-MM-DD HH24:MI:SS'), 24.5); INSERT INTO NMPurchase VALUES(3, to_date('2010-01-03 10:23:59', 'YYYY-MM-DD HH24:MI:SS'), 21.5); INSERT INTO NMPurchase VALUES(4, to_date('2010-01-04 11:23:59', 'YYYY-MM-DD HH24:MI:SS'), 26.5); INSERT INTO NMPurchase VALUES(5, to_date('2010-01-05 12:23:59', 'YYYY-MM-DD HH24:MI:SS'), 17.5); INSERT INTO NMPurchase VALUES(6, to_date('2010-01-06 13:23:59', 'YYYY-MM-DD HH24:MI:SS'), 20.5);
------解决方案--------------------
select (select max(cost) from table where date=(select max(date) from table)) - (select max(cost) from table where date=(select min(date) from table)) from dual