Question
Query of Queries Help
I have the following query. It calculates a total value, then
sums that total value for each site. I usd cast and divide by 1000
to eliminate the decimals and turn the remainder into a string.
<cfquery name="openValue" datasource="dbName">
SELECT cast(SUM(totalValue)/1000 as int) AS sumTotalValue, Site FROM
(
SELECT DISTINCT (a.quantity * a.value_amount) AS totalValue,
b.site
FROM UnReceivables_URDN a
INNER JOIN UnReceivables_Site_Master b
ON a.Site_ID = b.Site_ID
WHERE currentState NOT IN ('Voided','Closed')
GROUP BY a.quantity, a.value_amount, b.site
) AS I
WHERE site like '%%'
GROUP BY Site
ORDER BY Site
</cfquery>
I then want to use query of queries to take that converted string and concantenate it with the site. But I get an error saying (. is not in the select list.
<cfquery name="openValue1" dbtype="query">
select cast(sumTotalValue as varchar(10)) + site as newSite
from openValue
</cfquery>
I have never had any success usinq query or queries. It only seems to work if it is just a simple select. If you try to do other things with it, there is an error. I want to use views instead.
What is wrong with my query of queries. The tables are in sql server.
<cfquery name="openValue" datasource="dbName">
SELECT cast(SUM(totalValue)/1000 as int) AS sumTotalValue, Site FROM
(
SELECT DISTINCT (a.quantity * a.value_amount) AS totalValue,
b.site
FROM UnReceivables_URDN a
INNER JOIN UnReceivables_Site_Master b
ON a.Site_ID = b.Site_ID
WHERE currentState NOT IN ('Voided','Closed')
GROUP BY a.quantity, a.value_amount, b.site
) AS I
WHERE site like '%%'
GROUP BY Site
ORDER BY Site
</cfquery>
I then want to use query of queries to take that converted string and concantenate it with the site. But I get an error saying (. is not in the select list.
<cfquery name="openValue1" dbtype="query">
select cast(sumTotalValue as varchar(10)) + site as newSite
from openValue
</cfquery>
I have never had any success usinq query or queries. It only seems to work if it is just a simple select. If you try to do other things with it, there is an error. I want to use views instead.
What is wrong with my query of queries. The tables are in sql server.
