derived table is working