How to write a query that will retrieve the items with sold amount

oracle

Problem : I have a table which has three columns such as
item id ,transaction_date,Amount_sold.

I want to have a list of item with Amount sold which are sold today but if the same item was sold yesterday then it should not come in my list.

Best Answer

Not exists will work here

 select item_id, amount_sold 
       from table t
   where transaction_date = trunc(sysdate) 
     and not exists (select 1
                       from table t1
                      where t1.item_id = t.item_id
                          and t1.transaction_date = trunc(sysdate)-1;

EDIT based on OP's latest observations :

select item_id, SUM(amount_sold) as amount
       from table t
   where trunc(transaction_date) = trunc(sysdate) 
     and not exists (select 1
                       from table t1
                      where t1.item_id = t.item_id
                          and trunc(t1.transaction_date) = trunc(sysdate)-1
 group by item_id;