Самый простой и ориентированный на ColdFusion способ выполнить то, что вы ищете, - это просто использовать запрос запроса:
ОСНОВНОЙ ЗАПРОС:
<cfquery name="myta" datasource="zett">
SELECT w.t_firstname, w.t_lastname, w.t_total
FROM table_bst a
INNER (OR LEFT/RIGHT OUTER) JOIN table_zr w ON a.? = w.?
WHERE
[
1=1 is only really useful if you have some sort of if/else logic in your
WHERE clause, and it's used to make sure there is a value there if none
of the if/else conditions are met.
]
AND/OR [other stuff]
</cfquery>
Запрос запроса:
<cfquery name="meto" dbtype="query">
SELECT t_firstname AS FirstName, count(*) AS Status
FROM myta
GROUP BY FirstName
</cfquery>
ВЫВОД:
<table>
<cfif meto.recordcount EQ 0>
<tr><td style="color:#FF0000">There is currently an error</td></tr>
<cfelse>
<cfoutput query="meto">
<tr>
<td>#Firstname#:#Status#</td>
</tr>
</cfoutput>
</cfif>
</table>
https://trycf.com/gist/529c0bf10b7c6d7420eae399572744bb/lucee5?theme=monokai