我有一张表cad_changes
:
id unit_id old_value new_value change_date
--------------------------------------------------------------------
4615128 800 88809433 83028302 2018-03-01 17:02:59
4615144 800 83028302 87434702 2018-03-13 12:21:24
4615145 800 87434702 87869589 2018-03-13 12:27:56
4615150 800 87869589 100148757 2018-03-14 23:20:07
我什么时候可以使用返回此结果的select
我想结果
select max (new_value) - min(old_value)
where date = trunc(change_date)
答案 0 :(得分:0)
这个sql应该足够了:
select trunc(change_date) "Change Date",
to_char(max(new_value))||' - '||to_char(min(old_value)) "Values"
from cad_changes
group by trunc(change_date)
order by trunc(change_date);