Customer1 has 3 orders; Oct 1 for 5000 [Small], Nov 1 for 12000 [Large], Dec 1 for 7000 [Medium] >Customer2 has 0 orders; >Customer3 has 2 orders; Nov 1 for 7000 [Medium], Dec 1 for 11000 [Large] >Customer4 has 1 orders; Oct 1 for 4000 [Small] >Customer5 has 0 orders;>
Customer1 Dec 1 [Medium] >Customer2 {//} [] >Customer3 Dec 1 [Large] >Customer4 Oct 1 [Small] >Customer5 {//} []>
select t1.customer, t2.date, t3.size ; from customer t1 ; left join orders t2 on t1.custID = t2.custID ; and t2.date = (select max(date) from orders o1 where o1.cust_id = t2.custid ) ; left join lookup t3 on t2.amount = t3.amountCetin