SELECT a.cust_id as sort1,b.order_id as sort2, ; a.cust_id, a.company, b.order_id,b.to_name; FROM customer a INNER JOIN orders b ; ON a.cust_id = b.cust_id ; where order_id = ; (select min(order_id) from orders C where b.cust_id = c.cust_id) ; union ; SELECT a.cust_id as sort1,b.order_id as sort2, ; '' as cust_id, '' as company, b.order_id,b.to_name; FROM customer a INNER JOIN orders b ; ON a.cust_id = b.cust_id ; where order_id # ; (select min(order_id) from orders C where b.cust_id = c.cust_id) ; order by 1,2Cetin