I believe you have a couple things confused here. The "Custom Query" resource on a page is for a SWQL query, not a SQL query. If you want to do something like that you'll need to convert your query to a SWQL query, which from what I'm seeing, might be impossible or at least >very< difficult. SWQL information can be found here.
The attachment you gave I believe is for an old-style server-based Report Writer-type report, which definitely only uses SQL. Not to mention the functions in the query are definitely SQL functions and not SWQL. The newer web-based reports you can do either SQL or SWQL, but I don't think you can do the "Search" functionality that you would get in the "Custom Query" resource.
Sorry I couldn't be of more help, just too much work to be done here. But hopefully I got you pointed in the right direction!
Thank you for the reply. I had thought it was possible because we set up a search function elsewhere (well someone did who is no longer here) but could be the complexity of this versus what was done elsewhere might not be possible. That being said, will just go with the reporting function I have already.