I have a few queries that count the amount of documents that are run, and it also displays the amount of seconds since the last document was processed. What I would like to do, is when there are no more documents to process, instead of displaying a 0, I would like to display a text indicating that there are no more pending documents. Here's what I have:
COUNT(CASE WHEN success IS NULL AND processed_dts IS NULL THEN 'No documents to process' END)
If I take out the COUNT, I will get an error because I am not using an aggregate function.