complete select query for income