Ask a Question related to Coldfusion Database Access, Design and Development.
-
helenmhudson #1
subqueries in query of queries
I've been looking at this for a while so I might be punch drunk.
I have a query of queries on a mySQL sales database. I want to display
columns across for the monthly sales values - client names on the Y axis,
monthly sales on the Y axis... pretty common situation.
I've been working on a solution which merges several
SELECT
statements (one per month where only the month I'm interested in has values
and the other is 0 ) and then all unioned with
UNION ALL
and then, around all that, I have a summing statement, adding them all
together.
I'm trying to do this now in a cfm file and the query of queries is rebelling
at the first
(
(when I'm about to get into my subquery).
My questions are:
1. can query of queries support subqueries (perhaps my syntax is wrong)
2. anyone have a better way of displaying montly values on a summing database
Any advice much appreciated!
Helen
helenmhudson Guest
-
query of queries with avg()
cfmx 6.1 when i use avg() in a query of queries it rounds the results (actually rounds results down)...so i'm wondering if i am doing this... -
2 queries to 1 query
Hello, Can somebody help me to combine these two queries into one query. <cfquery datasource="#DATAS#" name="getMainNav"> SELECT * FROM... -
Query of Queries in 7.0
I am running MX 6.1 and was wondering of the QofQ problem still exists (in the new version, 7.0) where CF tries to guess at the column datatype... -
Query of Queries on query New type query
In CF5 we have a page that creates a query, using queryNew and querySetCell and the like, we then used dbtype="query" and gave it's name so we could... -
Query of Queries?
I have a table named therapists with a field named modalities which contains a comma delimited list of id #s. I need to loop through a list of... -
Dan Bracuk #2
Re: subqueries in query of queries
I don't think QofQ supports subqueries in the from clause which is what you need. An alternative approach would be to loop through your query and create a 2D array.
Dan Bracuk Guest
-
LL@Work #3
Re: subqueries in query of queries
You could try this approach:
First, split out the subquery into its own query:
<cfquery name="mySubquery" dbtype="query">
select myfields from myquery
</cfquery>
Then, store the results into a quoted list:
<cfset MyList = QuotedValueList(mysubquery.myfields)>
Then, use the resulting list in the WHERE clause of your main query (be sure
to use the PreserveSingleQuotes function):
<cfquery name="myfinalQuery" dbtype="query">
Select allMyFields
from myOtherQuery
Where myfield NOT IN (#PreserveSingleQuotes(MyList)#)
</cfquery>
LL@Work Guest



Reply With Quote

