Hello Brigham,
This discussion group being the forum meant for general discussion of the platform, you may post your question related to the SQL query on
dba.stackexchange.com where you will have access to a large community of enthusiasts and experts to share ideas with and get support. That being said, I found
this thread on stackoverflow which discuss the similar question so I'd like to share with you.