Ask a Question related to Coldfusion - Getting Started, Design and Development.
-
gogl #1
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 incorrectly. here is my
example:
<cfscript>
q1="select * from mbr";
q2="select avg(mbrlos) as alos from mbr";
q3="select avg(mbrlos) as alos from qry1";
</cfscript>
<h3>Query 1 (qry1)</h3> select * from mbr
<cfquery name="qry1" datasource="qqtest">
#q1#
</cfquery>
<cfdump var="#qry1#" />
<h3>Query 2 (qry2)</h3> select avg(mbrlos) as alos from mbr
<cfquery name="qry2" datasource="qqtest">
#q2#
</cfquery>
<cfdump var="#qry2#" />
<h3>Query 3 (qry3)</h3> select avg(mbrlos) as alos from qry1
<cfquery name="qry3" dbtype="query">
#q3#
</cfquery>
<cfdump var="#qry3#" />
output for query 1 looks like:
query
MBRID MBRLOS MBRNAME
1 1 5 bob
2 2 2 john
3 3 1 jim
4 4 7 sam
output for query 2 looks like:
query
ALOS
1 3.75
output for query 3 looks like:
query
ALOS
1 3
gogl Guest
-
Need Help with Query of Queries
I have the query "almost" there but I'm not sure exactly how to accomplish this. I need all recrods meeting the criteria from the AppliedLicense... -
Query of Queries
I think that we're using 5 on both environments (not checked that though - they shouldn't be different anyway)... It seems that i've fixed it...... -
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... -
PeteMares #2
Re: query of queries with avg()
Not really sure since I am still new, but just as a guess could it have to do
with you variable type. If they are stored as an INT then they will be
averaged as an INT. And INT only does whole numbers.
Sorry if I am not close at all.
PeteMares Guest
-
eastinq #3
Re: query of queries with avg()
PeteMares is correct. I don't know if there is a way to change the data type
of the column once it is in a query object. If MBRLOS was a character data
type, you would have gotten an error message on qry3, but not on qry2. You can
get the decimal results from QoQ by changing the database data type to decimal
or doing this.
select avg(mbrlos * 1.0) as alos from qry1
eastinq Guest
-
gogl #4
Re: query of queries with avg()
perfect. thank you both. i will try this out agains my real dataset and see how it goes. this looks very promising.
cheers.
gogl Guest



Reply With Quote

