coldFusion QoQ problem

I am trying to write the QofQ and it cause me an error message

 <cfquery name="getContigSessionAfterDelete" dbtype="query" >
                	SELECT *  
                	FROM    qGetResult as a
                    JOIN   (SELECT carKey, min(sessionStart) AS minStart, max(sessionEnd) AS maxEnd
                        FROM qGetResult
                        WHERE  1 IN (contiguous)
                        GROUP BY carKey) c
                        ON      c.carKey = a.carKey
                AND   ( a.sessionStart BETWEEN DATEADD(n, -29, maxEnd)   AND DATEADD(n, 29, maxEnd)
                    OR  a.sessionEnd   BETWEEN DATEADD(n, -29,minStart) AND DATEADD(n, 29, minStart) )
                </cfquery>

Open in new window

LVL 19
erikTsomikSystem Architect, CF programmer Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
try this instead:

SELECT *  
                      FROM    qGetResult as a
                    JOIN   (SELECT carKey, min(sessionStart) AS minStart, max(sessionEnd) AS maxEnd
                        FROM qGetResult
                        WHERE  1 IN (contiguous)
                        GROUP BY carKey) c
                        ON      c.carKey = a.carKey
                WHERE ( a.sessionStart BETWEEN DATEADD(n, -29, maxEnd)   AND DATEADD(n, 29, maxEnd)
                    OR  a.sessionEnd   BETWEEN DATEADD(n, -29,minStart) AND DATEADD(n, 29, minStart) )
0
_agx_Commented:
QoQ's aren't db queries.  They're very rudimentary and only support a small subset of SQL operations. Things like derived tables, date functions, aren't supported.

The simplest option is do those calculations and comparisons in your base database query.
0
gdemariaCommented:
In addition to agx's comment, ask yourself why you want to do a query of query?   A lot of people want to do it so they don't have to go back to the database to save processing time.  This is actually incorrect, the database processes the query much faster than the QoQ in most cases.   So, change your QofQ into a cfquery and you should get what you need and faster!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.