Issue 1159

* Using improved SQL query created by @feeleep75
* Adjusted the query to further cut down the data returned

Fixes #1159 once merged.