Performance issue: looping over queries with a query results set

I have code that works, but I think I should be able to run the code faster. I could try a stored procedure but there are so many variables to set. I tried with wrapping cftransation around the code, but it didn't make a noticeable difference. I need to go through the data singularly to fill my query object.
Here's an ABBREVIATED sample of the code:
<cfset tot_AllActiveListing = QueryNew(
"AnnounceNum, JP_PDLoc, JP_JS_Title, JP_JS_KWID, JP_JS, JP_Open, JP_Close, JP_CloseType, JP_CloseName, JP_PosNeed, JP_DirectHire, JP_Desc, JP_Draft, JP_Archived, JP_State, JP_AreaID, JP_AreaName, JP_AreaAlias, JP_Fac_SU, JP_Fac_Facility, JP_FAC_ID, JP_Grade1, JP_Grade2, JP_Grade3, JP_Grade4, JP_Grade5, JP_Posted, JP_TypeHire, JP_HRemail",
"VARCHAR,VARCHAR,VARCHAR,INTEGER,INTEGER,TIMESTAMP,TIMESTAMP,INTEGER,VARCHAR,INTEGER,BIT,V ARCHAR,BIT,BIT,VARCHAR,INTEGER,VARCHAR,VARCHAR,VARCHAR,VARCHAR,INTEGER,VARCHAR,VARCHAR,VAR CHAR,VARCHAR,VARCHAR,TIMESTAMP,INTEGER,VARCHAR")
/>
<cfquery name="getAllActiveListing" datasource="#request.at_datasource#">
    SELECT j.JOB_AnnounceNum, j.JOB_PDLoc, j.fk_JS_code, j.Job_JPOpen, j.Job_JPClose, j.fk_CloseType, j.JOB_JPPosNeed, j.JOB_DirectHire, j.JOB_JPDesc, j.Job_JPDraft, j.JOB_JPArchived, j.JOB_State,
    j.fk_FACID, j.Posted, j.JOB_IHSvITU, f.Fac_Area, f.Fac_ServiceUnit, f.fac_Facility, f.Fac_Addr1, f.Fac_Addr2, f.Fac_City, f.Fac_State, f.Fac_Zip
    from JOB_JP j INNER JOIN #generaldb#IHSFacility f
    ON j.fk_FACID  = f.Fac_ID
    WHERE
            JOB_JPDraft = 0
            and (Job_JPClose = #Now()# or Job_JPClose > #Now()# or fk_CloseType = 2 or fk_CloseType = 3)
            and (JOB_JPArchived = 0 or JOB_JPArchived IS NULL)
             <cfif IsDefined("qAltPostID") and qAltPostID.recordcount gt "0">
            and JOB_AnnounceNum IN (<cfqueryparam list="yes" cfsqltype="CF_SQL_varchar" value="#ValueList(qAltPostID.fk_Job_AnnounceNum)#">)
            <cfelseif option is "JPPostListing" and StructKeyExists(session,"IHSUID")>
            and  j.WhoCreated = #session.IHSUID#
             </cfif>
             Order by j.Job_JPOpen desc
    </cfquery>
    <cfloop from="1" to="#session.getAllActiveListing.recordcount#" index="i">       
            <cfquery name="getAllActiveListingGrade" datasource="#request.at_datasource#">
                SELECT fk_Job_AnnounceNum, Grade
                from Job_JP_Grade
                Where Job_JP_Grade.fk_Job_AnnounceNum = '#session.getAllActiveListing.Job_AnnounceNum[i]#'
            </cfquery>    
            <cfif IsDefined("session.getAllActiveListing") and session.getAllActiveListing.recordcount neq "0">       
                <cfquery name="getAllActiveListingIHSArea" datasource="#at_datasource#">
                SELECT JOBIHSArea_ID, JOBIHSArea_Name, JOBIHSArea_Alias
                from JOB_IHSArea_LKUP
                where JOBIHSArea_Alias = '#session.getAllActiveListing.Fac_Area[i]#'
                </cfquery>
            </cfif>       
            <cfset session.getAllActiveListingGrade = getAllActiveListingGrade />
            <cfquery name="getAllActiveListingCloseName" datasource="#at_datasource#">
            SELECT JOB_CloseName
            from JOB_CloseType_LKUP
            where JOB_CloseType_LKUP.JOB_CloseType = #session.getAllActiveListing.fk_CloseType[i]#
            </cfquery>
                <cfscript>                                       
                   newRow=QueryAddRow(tot_AllActiveListing);
                    QuerySetCell(tot_AllActiveListing, "AnnounceNum", "#session.getAllActiveListing.Job_AnnounceNum[i]#");
                    QuerySetCell(tot_AllActiveListing, "JP_PDLoc", "#session.getAllActiveListing.JOB_PDLoc[i]#");
                    QuerySetCell(tot_AllActiveListing, "JP_Draft", "#session.getAllActiveListing.Job_JPDraft[i]#");
                    QuerySetCell(tot_AllActiveListing, "JP_Archived", "#session.getAllActiveListing.Job_JParchived[i]#");
                    QuerySetCell(tot_AllActiveListing, "JP_Posted", "#session.getAllActiveListing.Posted[i]#");
                    QuerySetCell(tot_AllActiveListing, "JP_PosNeed", "#session.getAllActiveListing.JOB_JPPosNeed[i]#");
                    QuerySetCell(tot_AllActiveListing, "JP_DirectHire", "#session.getAllActiveListing.JOB_DirectHire[i]#");
                 </cfscript>       
        </cfloop>
Any ideas will be greatly appreciated. If stored procedures are the best way to handle this and will run appreciably faster, I'll try it.
Thanks.
JoyRose

Thanks for your reply.
So now here is the entire code written with LEFT JOIN:
<cfquery name="getAllActiveListing" datasource="#request.at_datasource#">
    SELECT j.JOB_AnnounceNum, j.JOB_PDLoc, j.fk_JS_code, j.Job_JPOpen, j.Job_JPClose, j.fk_CloseType, j.JOB_JPPosNeed, j.JOB_DirectHire, j.JOB_JPDesc, j.Job_JPDraft, j.JOB_JPArchived, j.JOB_State,
    j.fk_FACID, j.Posted, j.JOB_IHSvITU, f.Fac_Area, f.Fac_ServiceUnit, f.fac_Facility, f.Fac_Addr1, f.Fac_Addr2, f.Fac_City, f.Fac_State, f.Fac_Zip, g.Grade, a.JOBIHSArea_ID, a.JOBIHSArea_Name, a.JOBIHSArea_Alias, c.JOB_CloseName, s.Title, p.HRContact, p.HRContactType, e.Email, k.fk_KWID, k.fk_AnnounceNum, w.JOB_KWName, w.JOB_KWID
    from JOB_JP j INNER JOIN #generaldb#IHSFacility f
    ON j.fk_FACID  = f.Fac_ID
    LEFT OUTER JOIN JOB_JP_Grade g
    ON j.JOB_AnnounceNum = g.fk_Job_AnnounceNum
    LEFT OUTER JOIN JOB_IHSArea_LKUP a
    ON j.Fac_Area = a.JOBIHSArea_Alias
    LEFT OUTER JOIN JOB_CloseType_LKUP c
    ON j.fk_CloseType = c.JOB_CloseType
    LEFT OUTER JOIN JOB_Series_LKUP s
    ON j.fk_js_code = s.fk_js_code
    LEFT OUTER JOIN JOB_JPContacts p
    ON j.JOB_AnnounceNum = p.fk_Job_AnnounceNum
    LEFT OUTER JOIN #globalds#Email e
    ON p.HRContact = e.table_ID
    LEFT OUTER JOIN JOB_JPKW k
    ON j.JOB_AnnounceNum = k.fk_AnnounceNum
    LEFT OUTER JOIN JOB_KW_LKUP w
    ON k.fk_KWID = w.JOB_KWID 
    WHERE
            JOB_JPDraft = 0
            and (Job_JPClose = #Now()# or Job_JPClose > #Now()# or fk_CloseType = 2 or fk_CloseType = 3)
            and (JOB_JPArchived = 0 or JOB_JPArchived IS NULL)
             <cfif IsDefined("qAltPostID") and qAltPostID.recordcount gt "0">
            and JOB_AnnounceNum IN (<cfqueryparam list="yes" cfsqltype="CF_SQL_varchar" value="#ValueList(qAltPostID.fk_Job_AnnounceNum)#">)
            <cfelseif option is "JPPostListing" and StructKeyExists(session,"IHSUID")>
            and  j.WhoCreated = #session.IHSUID#
             </cfif>
             Order by j.Job_JPOpen desc
    </cfquery>
I'm concerned about the queries below that I converted to the LEFT JOIN code above..
<cfquery name="getAllActiveListingHRContact" datasource="#at_datasource#">
            SELECT HRContact, HRContactType
            from JOB_JPContacts
            where fk_Job_AnnounceNum = '#session.getAllActiveListing.JOB_AnnounceNum[i]#'
            </cfquery>
            <cfif CompareNoCase(getAllActiveListingHRContact.HRContactType,"HRContactID") is 0>       
                <cfquery name="getAllActiveListingHREmail" datasource="#globalds#">
                SELECT Email
                from Email
                where Table_ID = #getAllActiveListingHRContact.HRContact#
                </cfquery>
                <cfset session.getAllActiveListingHREmail = getAllActiveListingHREmail />
            </cfif>
            <cfquery name="getAllActiveListingMasterKey" datasource="#at_datasource#">
            SELECT fk_KWID, fk_AnnounceNum, JOB_KWName, JOB_KWID
            from JOB_JPKW, JOB_KW_LKUP
            where JOB_JPKW.fk_AnnounceNum = '#session.getAllActiveListing.JOB_AnnounceNum[i]#'
            and JOB_KW_LKUP.JOB_KWID = JOB_JPKW.fk_KWID
            </cfquery>
I appreciate your help with this.

Similar Messages

  • Can we perform Join operation using SQLCall with Datatabae Query

    Hi,
    I am working on Toplink SQLCall query. I am performing join operation but, it is giving error.
    so please, any can tell me . we can perform join operation using SQLCall with Database Query
    Thanking You.

    You can use joining with SQLCall queries in TopLink, provided your SQL returns all of the required fields.
    What is the query you are executing and what error are you getting?

  • Xcelsius with XMLA or XML Query Result Set

    Hi Experts,
    I want a direct connection from Xcelsius to my BW-Data. Because the new connection, coming with Fix Pack 2.1 is only avaiable for EHP 1 for NW 7.0 I tried to configure with XMLA and XML Query Result Set.
    This Document tells the necessary steps: How to integrate Xcelsius 2008 with SAP NetWeaver BI without Integration Kit.pdf.
    When I test my XML connection over http://<host>:<port>/TXmla/srvlet/TestXmla my Cubes will display.
    So I do a Webservice-Connection with WSDL-URL. At Input-Values there are some entries like CUBE_NAME, CATALOG_NAME...
    Output values arent avalible. How do I use these elements to show my Data in Xcelsius?
    My Problem with the XML Query Result Set Connection is, that when I Log On to VC the following error appears:
    You are not authorized to view the requested resource.
    So I get the authorisationobjects: S_DEVELOP and S_RS_COMP as describe in 'How To... Resolve Visual Composer Issues'.
    What values have I to enter by S_RS_COMP? And how can I enter my External Service in S_SERVICE. At the type WS the service isnt't avaiable.
    Regards,
    Jan

    To use XMLA web service you need a wrapper function build to convert the XMLA output to the Xcelsius format. There are some documents available in SDN on how to do this.
    You can use Live Office or Query as a Web service option to connect from Xcelsius to BW.
    S_RS_COMP is the query ID which you are trying to access, S_SERVICE you can either give * or try to set up authorization log and see the expected value.

  • Create a CF Query Result Set in Java

    I'd like to programatically build a ColdFusion query resultset inside of a Java class and return it to the calling application.  See the Java psudocode below to see what I'm talking about:
    public class MyClass {
         public coldfusion.sql.QueryTable getQuery() {
              // Create a query table object
              QueryTable myTable = ..?
              // Loop through some set of instance data for my class
              for(int c = 0; c < this.myWigets.length; c++) {
                   int row = c+1;
                   myTable.setField(row, nameCol, this.myWigets[c].name);
                   myTable.setField(row, colorCol, this.myWigets[c].color);
              return myTable;
    I've had stuff like this partially working in the past but had issues with things like query of queries and such probably due to the hacks used to create the QueryTable object.  I'm mainly just checking in to see if there has been any progress made in this area.  To me this seems like such an obvious thing for a Java developer working within CF to want to do.  I'm surprised Adobe doesn't have an officially supported API for doing this sort of thing (or maybe I'm just too dumb to find it.)    A few other notes... I'm not using CFX, and I'm not starting with a java.sql.ResultSet otherwise I would use the QueryTable(java.sql.ResultSet) constructor.  I need to build this thing from scratch programatically.
    Thanks for your time.  I hope this question makes sense to someone out there.
    - Mike

    I appologize.  I wasn't very clear with my original question.
    I'm creating an instance of my Java class from within CF using createObject("java", "com.example.MyClass").  So based on the sample code in my original post on the CF side I'd like to do something like this:
    <cfscript>
         myObj = createObject("java", "com.example.MyClass");
         myObj.doSomeStuff();
         myCFQuery = myObj.getQuery();  // Return a CF query from my java class
    </cfscript>
    ... then do stuff like ...
    <cfquery name="mySortedQuery" dbtype="query">
         select     *
         from       myCFQuery
         order      by color
    </cfquery>
    I appriciate your suggestions so far.  I have other solutions working already but they are not ideal.  I was just hoping someone had a clean and as-hack-free-as-possible way of creating a ColdFusion query result set in Java and passing it back to CF.
    Thanks again,
    Mike

  • Error in testing XML query result set web service

    Hi
    I was trying to test a <b>XML query result set web service</b> in BW system with tcode wsadmin but getting error like
    <b>Cannot download WSDL from http://ibmbtsb02.megacenter.de.ibm.com:8070/sap/bw/xml/soap/queyview?sap-client=001&wsdl=1.1&mode=sap_wsdl: F:\usr\sap\W70\DVEBMGS70\j2ee\cluster\server0\apps\sap.com\com.sap.engine.services.webservices.tool\servlet_jsp\wsnavigator\root\WEB-INF\temp\ws1139464945296\wsdls\wsdlroot.wsdl (The system cannot find the path specified)</b>
    I had tried it first time few days ago and was able to test it successfully with the same configuration settings.
    Could any one of you please provide any suggestion on this?
    Thanks in advance
    Sudip

    hi
    check this links it may help u.
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/e3072e65f04445a010847aa970b68b/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/d8/3bfc3f8fc2c542e10000000a1550b0/frameset.htm
    Regards,
    Manoseelan

  • Limit on Query result set

    Limit on Query result set
    Is there anyway in Oracle9i to limit query result
    I.e.: we can limit query result in MySQL
    SELECT * FROM EMP LIMIT 2;
    Will return only top 2 records
    Thanks in advance

    SELECT * FROM EMP WHERE ROWNUM <= 2;

  • Downloading Query result set

    Hi forum,
    We have a requirement to download query result set and distribute it as a periodic job. Can open hub be used for this purpose?
    Thanks in advance.
    Regards,

    Hai i beleive your using BI 7 you can meet your objective by using broadcast and schedule the same hope you have the right EP access too .
    Goodday

  • Looping over arraycollection with sap data

    Hello,
    I asked a lot of persons but i still have a problem.
    I am trying to make a organizational chart in Adobe Flex with data out of the SAP system.
    When I try to access my data that I have given trough the Flash Islands container it doesn’t work.
    I do:
    [Bindable]
    Public var datasource:Arraycollection;
    Then I want to loop over this datasource with a for loop but it says that the object is null.
    for (i = o; i < datasource.length; i++)
    When I use datasource as dataprovider for a datagrid in Flex, that works perfect.
    Please answer fast because I need it for school.
    greetings

    Hello,
    I asked a lot of persons but i still have a problem.
    I am trying to make a organizational chart in Adobe Flex with data out of the SAP system.
    When I try to access my data that I have given trough the Flash Islands container it doesn’t work.
    I do:
    [Bindable]
    Public var datasource:Arraycollection;
    Then I want to loop over this datasource with a for loop but it says that the object is null.
    for (i = o; i < datasource.length; i++)
    When I use datasource as dataprovider for a datagrid in Flex, that works perfect.
    Please answer fast because I need it for school.
    greetings

  • Performance issue in customized program with do-enddo

    Hi,
    We have a performance issue in customized program.
    In this program he used do-enddo twice. I mean nested do-endo.
    How can we increase the performance.
    And when we did the code inspector it displays 9 errors 'Char. strings w/o text elements will not be translated'.
    Is there any performance issue for this error?
    Regards,
    Chandu.
    Moderator message - Cross post locked
    Edited by: Rob Burbank on Oct 20, 2009 12:42 PM

    >  'Char. strings w/o text elements will not be translated'.
    > Is there any performance issue for this error?
    No, this is just not so clean programming. As for the rest, Please Read before Posting in the Performance and Tuning Forum and learn how to find out where the showstoppers really are.
    Thomas

  • Stepping through a query result set, replacing one string with another.

    I want to write a function that replaces the occurance of a string with another different string.  I need it to be a CF fuction that is callable from another CF function.  I want to "hand" this function an SQL statement (a string) like this:   (Please note, don't bother commenting that "there are eaiser ways to write this SQL..., I've made this simple example to get to the point where I need help.  I have to use a "sub_optimal" SQL syntax just to demonstrate the situation)
    Here is the string I want to pass to the function:
    SELECT
      [VERYLONGTABLENAME].FIRST_NAME,
      [VERYLONGTABLENAME].LAST_NAME,
      [VERYLONGTABLENAME].ADDRESSS
    FROM
      LONGTABLENAME [VERYLONGTABLENAME]
    Here is the contents of the ABRV table:
    TBL_NM,  ABRV    <!--- Header row--->
    VERYLONGTABLENAME, VLTN
    SOMEWHATLONGTALBENAME, SLTN
    MYTABLENAME, MTN
    ATABLENAME, ATN
    The function will return the original string, but with the abreviations in place of the long table names, example:
    SELECT
      VLTN.FIRST_NAME,
      VLTN.LAST_NAME,
      VLTN.ADDRESSS
    FROM
      LONGTABLENAME VLTN
    Notice that only the table names surrounded by brackets and that match a value in the ABRV table have been replaced.  The LONGTABLENAME immediately following the FROM is left as is.
    Now, here is my dum amatuer attempt at writing said function:  Please look at the comment lines for where I need help.
          <cffunction name="AbrvTblNms" output="false" access="remote" returntype="string" >
            <cfargument name="txt" type="string" required="true" />
            <cfset var qAbrvs="">  <!--- variable to hold the query results --->
            <cfset var output_str="#txt#">  <!--- I'm creating a local variable so I can manipulate the data handed in by the TXT parameter.  Is this necessary or can I just use the txt parameter? --->
            <cfquery name="qAbrvs" datasource="cfBAA_odbc" result="rsltAbrvs">
                SELECT TBL_NM, ABRV FROM BAA_TBL_ABRV ORDER BY 1
            </cfquery>
         <!--- I'm assuming that at this point the query has run and there are records in the result set --->
        <cfloop index="idx_str" list="#qAbrvs#">      <!--- Is this correct?  I think not. --->
        <cfset output_str = Replace(output_str, "#idx_str#", )  <!--- Is this correct?  I think not. --->
        </cfloop>               <!--- What am I looping on?  What is the index? How do I do the string replacement? --->
            <!--- The chunck below is a parital listing from my Delphi Object Pascal function that does the same thing
                   I need to know how to write this part in CF9
          while not Eof do
            begin
              s := StringReplace(s, '[' +FieldByName('TBL_NM').AsString + ']', FieldByName('ABRV').AsString, [rfReplaceAll]);
              Next;
            end;
            --->
        <cfreturn output_txt>
        </cffunction>
    I'm mainly struggling with syntax here.  I know what I want to happen, I know how to make it happen in another programming language, just not CF9.  Thanks for any help you can provide.

    RedOctober57 wrote:...
    Thanks for any help you can provide.
    One:
    <cfset var output_str="#txt#">  <!--- I'm creating a local
    variable so I can manipulate the data handed in by the TXT parameter.
    Is this necessary or can I just use the txt parameter? --->
    No you do not need to create a local variable that is a copy of the arguments variable as the arguments scope is already local to the function, but you do not properly reference the arguments scope, so you leave yourself open to using a 'txt' variable in another scope.  Thus the better practice would be to reference "arguments.txt" where you need to.
    Two:
    I know what I want to happen, I know how to make it happen in another programming language, just not CF9.
    Then a better start would be to descirbe what you want to happen and give a simple example in the other programming language.  Most of us are muti-lingual and can parse out clear and clean code in just about any syntax.
    Three:
    <cfloop index="idx_str" list="#qAbrvs#">      <!--- Is this correct?  I think not. --->
    I think you want to be looping over your "qAbrvs" record set returned by your earlier query, maybe.
    <cfloop query="qAbrvs">
    Four:
    <cfset output_str = Replace(output_str, "#idx_str#", )  <!--- Is this correct?  I think not. --->
    Continuing on that assumption I would guess you want to replace each instance of the long string with the short string form that record set.
    <cfset output_str = Replace(output_str,qAbrs.TBLNM,qAbrs.ABRV,"ALL")>
    Five:
    </cfloop>               <!--- What am I looping on?  What is the index? How do I do the string replacement? --->
    If this is true, then you are looping over the record set of tablenames and abreviations that you want to replace in the string.

  • Jdbc driver creates new thread for each statement with a query timeout set

    I am profiling a web application that is using the Microsoft JDBC driver, version 1.1 to connect to a sql server 2005 database. Each java.sql.Statement that is created, within the application, gets a query timeout value set on it ( statement.setQueryTimeout(...) ).
    I have discovered that the JDBC driver creates a new thread to monitor each Statement and the query timeout value. When the application is under load these threads are getting created faster then they are being destroyed and I am concerned that this will cause a performance problem in production.
    One option I have is to remove the query timeout value and the monitor threads will not be created, another is to change JDBC drivers.
    I'm curious is there any way to control this behavior so that these threads are not created or are managed more efficiently.  Is there a workaround that anyone is aware of?   Is this considered a bug?
    I have found a similar bug here for the 2000 driver:
    http://support.microsoft.com/default.aspx/kb/894552
    Cheers

    Hi,
    Thank you for using the Microsoft SQL Server JDBC driver.  You are correct that a new thread is started to monitor the query timeout when a statement is executed.  This is a potential performance issue that we may look at addressing in the upcoming v1.2 release.  The current behavior is not configurable.  The only workaround with the v1.1 driver is to limit your use of query timeouts to only those statements which you reasonably might expect to actually time out.
    We do take customer feedback very seriously, so if anyone else is concerned about this particular issue, please chime in and we will be able to give it appropriate weight.
    --David Olix [MSFT]

  • Help with MDX Query Result weirdness

    Hi,
    Feels like I'm posting a question every other day, hope I don't wear out my welcome.
    So I have a working query :
    with
    MEMBER Measures.[EmailCount] as IIF(ISEMPTY([Measures].[Tran Count]), 0 ,[Measures].[Tran Count])
    MEMBER Measures.AdvGroupTotal as
    SUM (EXISTING ([Dim IFA Details].[Parent Key].[Adviser Group] ,
    [Dim Date].[Fiscal].[Fiscal Year].&[FY 13/14]) , Measures.[Amount])
    MEMBER [Measures].[Income Range] as
    CASE
    WHEN Measures.AdvGroupTotal <= 10000 THEN '0-10000'
    WHEN Measures.AdvGroupTotal <= 50000 THEN '10001-50000'
    WHEN Measures.AdvGroupTotal <= 100000 THEN '50001-100000'
    WHEN Measures.AdvGroupTotal <= 200000 THEN '100001-200000'
    else '200000-'
    end
    SELECT { [Measures].[Amount] , Measures.[EmailCount], Measures.AdvGroupTotal, measures.[income range]}
    ON COLUMNS,
    [Dim IFA Details].[Parent Key].[Adviser Group].Members * [Dim Date].[Fiscal Quarter].children
    having Measures.AdvGroupTotal > 100
    on rows
    FROM [Income and Emails Cube]
    where
    ([Dim Date].[Fiscal].[Fiscal Year].&[FY 13/14]
    Great, gives me back what I expect
    So now I'm thinking, actually let's lose the Adviser Groups and just have it by Fiscal Quarter and Income Range, dropping that I lose my income range and get this:
    I figured its related to Income Range being a measure, so I tried making income range a calculated member of a dimension
    with
    MEMBER Measures.[EmailCount] as IIF(ISEMPTY([Measures].[Tran Count]), 0 ,[Measures].[Tran Count])
    MEMBER Measures.AdvGroupTotal as
    SUM (EXISTING ([Dim IFA Details].[Parent Key].[Adviser Group] ,
    [Dim Date].[Fiscal].[Fiscal Year].&[FY 13/14]) , Measures.[Amount])
    MEMBER [Dim IFA Details].[Parent Key].[Income Range] as
    CASE
    WHEN Measures.AdvGroupTotal <= 10000 THEN '0-10000'
    WHEN Measures.AdvGroupTotal <= 50000 THEN '10001-50000'
    WHEN Measures.AdvGroupTotal <= 100000 THEN '50001-100000'
    WHEN Measures.AdvGroupTotal <= 200000 THEN '100001-200000'
    else '200000-'
    end
    SELECT { [Measures].[Amount] , Measures.[EmailCount], Measures.AdvGroupTotal}
    ON COLUMNS,
    ( [Dim Date].[Fiscal Quarter].children, [Dim IFA Details].[Parent Key].[Income Range] )
    on rows
    FROM [Income and Emails Cube]
    where
    ([Dim Date].[Fiscal].[Fiscal Year].&[FY 13/14]
    This then came back with some unexpected results:
    The amount and email count are now the Income Range and still didnt get the income grouping I want.
    What am I doing wrong?
    Thanks for reading.
    Regards
    Jon

    Hi JLJ1976,
    According to your description, you have some issue when changing the measure into a dimension member. Right?
    In this scenario, the reason why you get the incorrect result set is you make a measure into dimension member. In your query, the Income Range is based on the Measure AdvGroup Total, and the AdvGroup Total value depends on how your dimension slice the cube.
    If you slice the cube on date members, you will get a much smaller AdvGroup Total value. So the Measure XXX return dynamic values because it always based on dimension slicer. For dimension members, they should be static values appear on axis to slice the cube
    data on a data. So you should make the Income Range into a calculated measure because it's based on a Quarter sliced Measure. Otherwise, it will return null value (in your query, it's the else part result) because you are measuring a measure.
    For more explanation about dimensions and Measures, please refer to links below:
    Measures and Measure Groups
    Introduction to Dimensions (Analysis Services - Multidimensional Data)
    Best Regards,
    Simon Hou
    TechNet Community Support

  • Query result set...

    I'm having trouble determining a good way to word my question. So, I believe my pseudo code below will be sufficient in doing so.
    Oracle version: 11.2g
    Data set
    WITH temp AS
    SELECT 1 col1, 1 day FROM dual UNION ALL
    SELECT 2 col1, 1 day FROM dual UNION ALL
    SELECT 3 col1, 1 day FROM dual UNION ALL
    SELECT 4 col1, 1 day FROM dual UNION ALL
    SELECT 5 col1, 1 day FROM dual UNION ALL
    SELECT 6 col1, 1 day FROM dual UNION ALL
    SELECT 7 col1, 2 day FROM dual UNION ALL
    SELECT 8 col1, 2 day FROM dual UNION ALL
    SELECT 9 col1, 2 day FROM dual UNION ALL
    SELECT 10 col1,2 day FROM dual
    SELECT *
      FROM temp
    Result of the query above:
    COL1     DAY
    1     1
    2     1
    3     1
    4     1
    5     1
    6     1
    7     2
    8     2
    9     2
    10     2
    DESIRED result set:
    DAY COL_TOTAL
    1   21 
    2   55   -- 21 + 33 (the sum of day 1 + the sum of day 2)I realize that I can get the desired result set from above with the code below. However, for my actual issue I have several other data points and 100 of distinct days that I need to do this for. So doing a 100 UNION statement isn't exactly going to work.
    WITH temp AS
    SELECT 1 col1, 1 day FROM dual UNION ALL
    SELECT 2 col1, 1 day FROM dual UNION ALL
    SELECT 3 col1, 1 day FROM dual UNION ALL
    SELECT 4 col1, 1 day FROM dual UNION ALL
    SELECT 5 col1, 1 day FROM dual UNION ALL
    SELECT 6 col1, 1 day FROM dual UNION ALL
    SELECT 7 col1, 2 day FROM dual UNION ALL
    SELECT 8 col1, 2 day FROM dual UNION ALL
    SELECT 9 col1, 2 day FROM dual UNION ALL
    SELECT 10 col1,2 day FROM dual
    SELECT SUM(col1) AS col_total
      FROM temp
    WHERE day <= 1
    UNION ALL
    SELECT SUM(col1) AS col_total
      FROM temp
    WHERE day <= 2Edited by: user652714 on Aug 13, 2012 9:55 PM

    Hi,
    I see now what you want . You can use this:
    select *
    from tt
    order by col_1;
         COL_1        DAY
             1          1
             2          1
             3          1
             4          1
             5          1
             6          1
             7          2
             8          2
             9          2
            10          2
    10 rows selected.
    select day, sum(total) over  (order by  day) COL_TOTAL
    from
    (select day, sum(col_1) TOTAL
    from tt
    group by day
        DAY  COL_TOTAL
             1         21
             2         55
    2 rows selected.

  • Large query result set

    Hi all,
    At the moment we have some java classes (not ejb - cmp/bmp) for search in
    our ejb application.
    Now we have a problem i.e. records have grown too high( millions ) and
    sometimes query results in retrieval of millions of records. It results in
    too much memory consumtion in our ejb application. What is the best way to
    address this issue.
    Any help will be highly appreciated.
    Thanks & regards,
    Parvez

    you can think of following options
    1) paging: read only few thousands at a time and maintain a index to page
    through complete dataset
    2) caching!
    a) you can create a serialized data file in server to cache the result set
    and can use that to browse through. you may do on the fly
    compression/uncompression while sending data to client.
    b) applet based solution where caching could be in client side. Look in
    http://www.sitraka.com/software/jclass/cs_ims.html
    thanks,
    Srinivas
    "chauhan" <[email protected]> wrote in message
    news:[email protected]...
    Thanks Slava Imeshev,
    We already have search criteria and a limit. When records exceeds thatlimit
    then we prompt user that it may take sometime, do you want to proceed? If
    he clicks yes then we retrieve those records. This results in lot ofmemory
    consumtion.
    I was thinking if there is some way that from database I can retrieve some
    block of records at a time rather the all records of a query. I wander how
    internet search sites work, where thousnds of sites/pages match criteriaand
    client can move back & front on any page.
    Regards,
    Parvez
    "Slava Imeshev" <[email protected]> wrote in message
    news:[email protected]...
    Hi chauhan,
    You may want to narrow search criteria along with processing a
    limited number of resulting records. I.e. if the size of the result
    is bigger than a limit, you stop fetching results and notify the client
    that search criteria should be narrowed.
    HTH.
    Regards,
    Slava Imeshev
    "chauhan" <[email protected]> wrote in message
    news:[email protected]...
    Hi all,
    At the moment we have some java classes (not ejb - cmp/bmp) for
    search
    in
    our ejb application.
    Now we have a problem i.e. records have grown too high( millions ) and
    sometimes query results in retrieval of millions of records. It
    results
    in
    too much memory consumtion in our ejb application. What is the best
    way
    to
    address this issue.
    Any help will be highly appreciated.
    Thanks & regards,
    Parvez

  • Help assigning a   calculated arbitrary  ID to a query result set

    Given the sample query result..
    (sorry about the formatting of the output)
    GROUPID LAST_NAME FIRST_NAME INITIALS EMAIL PHONE count(PHONE)
    GP2001 Troy Diana s [email protected] 123-456-7890 2
    GP2001 Troy Diana s [email protected] 123-456-7890 2
    GP2006 Thomas Carl p [email protected] 789-100-1112 1
    GP2007 Riker William T [email protected] 866-908-6654 1
    GP3001 Laforge Jody m jlaforge@enterprisenet 456-789-9000 3
    GP3001 Laforge Jody m [email protected] 456-789-9000 3
    GP3001 Laforge Jody m [email protected] 456-789-9000 3
    GROUP_ID is a calculated field from a select statement.
    Individuals with one phone number (ph_cnt = 1)
    is assigned an arbitrary unique GROUP_ID.
    Individuals, appearing more than once, with more than one phone (ph_cnt > 1)
    are giving the same GROUP_ID.
    I was thinking of using a case statement in this case...but got stuck on generating the GROUP_ID based
    on the phone count.
    select case
    when ph_cnt = 1 then select 'GP'||to_char(sysdate,'hhmisssss') from dual)
    when ph_cnt > 2 then <assign a unique group_id to each set of duplicates/triplicate...etc>
    end GROUP_ID,
    last_name,
    first_name,
    initials,
    email,
    phone
    (select last_name,
    first_name,
    initials,
    email,
    phone,
    count(phone) ph_cnt
    from my tab
    group by
    last_name,first_name,initials,email,phone)
    Edited by: ch**** on Apr 25, 2011 7:20 AM

    Try this,
    SELECT 'GP' || 1000 + DENSE_RANK () OVER (ORDER BY phone ASC) groupid,
           last_name,
           first_name,
           initials,
           email,
           phone,
           COUNT (1) OVER (PARTITION BY phone) ph_cnt
      FROM my tab;G.

Maybe you are looking for

  • What data does SNMP return and what is the best way to explore it?

    Hi All I have some queries about using SNMP on Cisco devices. 1. What is the best way to get an idea of what data MIBs can return? I have entered the commmand "show snmp mib". However, the number of MIBs generated is huge! 2. Can you enter a command

  • ORDERED hint in Oracle 11gR2

    Do we have any difference in 11g with the way /*+ ORDERED */ hint works, compared to 10g? Will this hint cause a plan change in 11g, compared to its plan when used in 10g (assuming no other items contribute to a change of plan)?

  • Smbdy stole my mac book air wt to do,  plz plz plz help me

    Smbdy stole my mac book air plz help me how to find

  • How to extend 0CRM_MKTELM  by CRM 4.0?

    Does anybody know how it is possible to extend 0CRM_MKTELM, which is loaded directly from CRM server? I've put 2 new fields in trade promotions mask in CRM (sell in and sell out date) and now I need to populate the corresponding infoobjects in BW. Th

  • Script jumps to another script

    Hello all, Here is a link if it may help: http://academic.algonquincollege.com/students/fabe0002/Threads2.swf Basis of this project: User has six selected answers, but only one is right. User drags answer to answer box, if wrong they are told so and