changed output from vector to data.table
corrected SQL query statement