• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cfthread with query

Advisor ,
Jul 08, 2013 Jul 08, 2013

Copy link to clipboard

Copied

Hi All,

Here is my query:

<cfquery name="qryData"  datasource="#application.DBconn#" >

        select columnA, columnB

        <cfloop from="1" to="5" index="y">

            ,SUM (Case when wType='FULL' then YEAR_#y# else 0 end) as FULL_#y#

            ,SUM (Case when wType='PART' then YEAR_#y# else 0 end) as PART_#y#

         </cfloop>

        from (

          select columnA, columnB, wType

          <cfloop from="1" to="5" index="y">

               ,SUM(case when fy = #y# then totalDI else 0 end) as YEAR_#y#

          </cfloop>

          from tableXX

          union all

          select columnA, columnB, wType

          <cfloop from="1" to="5" index="y">

               ,SUM(case when fy = #y# then totalCE else 0 end) as YEAR_#y#

          </cfloop>

          from viewYY

          )

        group by columnA, columnB, wType

        order by columnB

</cfquery>

How can i use cfthread to speed up the query?

I try:

<cfthread name="threadA" action="run">

<cfquery name="variables.qryA"  datasource="#application.DBconn#" >

     select columnA, columnB, wType

          <cfloop from="1" to="5" index="y">

               ,SUM(case when fy = #y# then totalDI else 0 end) as YEAR_#y#

          </cfloop>

          from tableXX

</cfquery>

</cfthread>

<cfthread name="threadB" action="run">

<cfquery name="variables.qryB"  datasource="#application.DBconn#" >

     select columnA, columnB, wType

          <cfloop from="1" to="5" index="y">

               ,SUM(case when fy = #y# then totalDI else 0 end) as YEAR_#y#

          </cfloop>

          from viewYY

</cfquery>

</cfthread>

<cfthread name="threadA, threadB"  action="join"  />

<cfquery name="qryData"  dbType="query" >

        select columnA, columnB

        <cfloop from="1" to="5" index="y">

            ,SUM (Case when wType='FULL' then YEAR_#y# else 0 end) as FULL_#y#

            ,SUM (Case when wType='PART' then YEAR_#y# else 0 end) as PART_#y#

         </cfloop>

        from (

          select * from variables.qryA

          union all

         select * from variables.qryB

         )

        group by columnA, columnB, wType

        order by columnB

</cfquery>

I got an error because i cannot use CASE in a Q of Q.

Maybe it is a way to use the cfthread inside my first query.

Any ideas?

Thanks!

Views

326

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Resources
Documentation