I am trying to do some math in oracle that has me returning the sum of many rows, minus a value of 1 row in a different column on that same table. Is this possible?
For example,
select sum(column1) - (select column2 from table1 where month = to_date(201505, 'yyyymm')) from table1 where month >= to_date(201006, 'yyyymm');
where month = to_date(201505, 'yyyymm')
results in a single row ... but .. uh .. yeah .. :) – DittoSUM
) without any grouping; you need to add aGROUP BY
clause, grouping byLS_ASSET_ID
; besides, as DItto said, are you sure that the subquery will return exactly ONE value? otherwise you need to modify it with aMIN
,MAX
or whatever you need – Aleksej