VERSION with ENHANCED SQL

not complete with search and sort, but hs the idea at pagination()