Find the Subtotal in the query

Hello,
This is the query is working fine now this query needs a change to get subtotal by Q.CLI_TRD_ALW_STRT_C,
        Q.ARS_RATG_C.  how do i do this using the analytical function.. please help .. Thanks in advance.
SELECT  Q.CLI_TRD_ALW_STRT_C,
        Q.ARS_RATG_C,
        Q.PRO_DESC_T,
        COUNT(DISTINCT Q.ACC_I),
        COUNT(DISTINCT Q.PRO_CUSIP_I),
        SUM(Q.TOT_PAR_VAL_A) TOT_PAR_VAL_A,
        SUM(Q.TOT_MKT_VAL_A) TOT_MKT_VAL_A
FROM
    SELECT
        Q1.CLI_TRD_ALW_STRT_C,
        Q3.ARS_RATG_C,
        Q1.PRO_DESC_T,
        Q1.ACC_I,
        Q1.INIT_ACC_I,
        Q1.PRO_CUSIP_I,
        Q1.PRO_CLASFN_C,
        Q1.AST_CURR_TOT_Z,
        Q1.TOT_PAR_VAL_A,
        NVL(Q2.PRO_MARK_Y,100) AS PRO_MARK_Y,
        Q1.TOT_PAR_VAL_A * (NVL(Q2.PRO_MARK_Y,100) / 100) AS TOT_MKT_VAL_A
    FROM
        SELECT  A.CLI_TRD_ALW_STRT_C,
                B.PRO_DESC_T,
                A.ACC_I,
                A.INIT_ACC_I,
                B.PRO_CUSIP_I,
                B.PRO_CLASFN_C,
                A.AST_CURR_TOT_Z,
                CASE    WHEN SUBSTR(A.INIT_ACC_I, 3,1) = '#' THEN
                    A.AST_CURR_TOT_Z
                ELSE
                    DECODE(B.PRO_CLASFN_C, 'DAPR', A.AST_CURR_TOT_Z * B.PAR_VAL_A, 'MBAC', A.AST_CURR_TOT_Z)
                END AS TOT_PAR_VAL_A
        FROM
        SELECT  E.*,
                (E.AST_CURR_INT_Z + E.AST_CURR_EXT_Z) AS AST_CURR_TOT_Z
        FROM    ARS_OWNER.ARS_ELIGIBILITY_GRID_HIST E
        WHERE   E.EDW_PSTG_D = '30-SEP-2008'
        ) A,
        SELECT  AA.*, BB.PRO_DESC_T
        from
        SELECT  P.PW_SCTY_I,
                P.PRO_CUSIP_I,
                P.PRO_CLASFN_C,
                CASE
                    WHEN    P.PRO_CUSIP_I IN ('59318E201','575672308','59318C205','59318B207','59318D302','092508506','092508209', '27828S705', '89147U209') THEN
                        25000
                    WHEN    P.PRO_CUSIP_I IN ('575672308') THEN
                        50000   
                    ELSE
                        P.PAR_VAL_A
                END AS PAR_VAL_A       
        FROM    ARS_OWNER.ARS_PRODUCT_DIMN P
        WHERE   P.CURR_VER_C = 'Y'
        ) AA,
        SELECT
                D.PRO_CUSIP_I,
                D.PRO_DESC_T
        FROM    ARS_OWNER.ARS_PROP_CUSIP_LIST D
        ) BB
        WHERE   AA.PRO_CUSIP_I = BB.PRO_CUSIP_I (+)
        ) B
        WHERE   A.PW_SCTY_I = B.PW_SCTY_I
        ) Q1,
        SELECT
            PRO_CUSIP_I,
            PRO_MARK_Y
        FROM
            ARS_OWNER.ARS_MARK_FACT
        WHERE
            REC_EFF_D = '30-SEP-2008'
        ) Q2,
        SELECT
            PRO_CUSIP_I,
            ARS_RATG_C
        FROM
            ARS_OWNER.ARS_RATINGS_FACT
        WHERE
            REC_EFF_D = '30-SEP-2008'
        ) Q3       
    WHERE
        Q1.PRO_CUSIP_I = Q2.PRO_CUSIP_I (+)
        AND Q1.PRO_CUSIP_I = Q3.PRO_CUSIP_I (+)
) Q
GROUP BY    Q.CLI_TRD_ALW_STRT_C,
            Q.ARS_RATG_C,
            Q.PRO_DESC_T
ORDER BY    Q.CLI_TRD_ALW_STRT_C,
Q.ARS_RATG_C,
            Q.PRO_DESC_T;
           

Here is the query. I wanted to have the subtotal
(group by) for Q.CLI_TRD_ALW_STRT_C,    Q.ARS_RATG_C.
SELECT  Q.CLI_TRD_ALW_STRT_C,
        Q.ARS_RATG_C,
        Q.PRO_DESC_T,
        COUNT(DISTINCT Q.ACC_I),
        COUNT(DISTINCT Q.PRO_CUSIP_I),
        SUM(Q.TOT_PAR_VAL_A) TOT_PAR_VAL_A,
        SUM(Q.TOT_MKT_VAL_A) TOT_MKT_VAL_A
FROM
    SELECT /*+ use_hash(q1 q3) no_use_merge(q1 q2 q3)*/
        Q1.CLI_TRD_ALW_STRT_C,
        Q3.ARS_RATG_C,
        Q1.PRO_DESC_T,
        Q1.ACC_I,
        Q1.INIT_ACC_I,
        Q1.PRO_CUSIP_I,
        Q1.PRO_CLASFN_C,
        Q1.AST_CURR_TOT_Z,
        Q1.TOT_PAR_VAL_A,
        NVL(Q2.PRO_MARK_Y,100) AS PRO_MARK_Y,
        Q1.TOT_PAR_VAL_A * (NVL(Q2.PRO_MARK_Y,100) / 100) AS TOT_MKT_VAL_A
    FROM
      Q1,
        SELECT
            PRO_CUSIP_I,
            PRO_MARK_Y
        FROM
            ARS_OWNER.ARS_MARK_FACT
        WHERE
            REC_EFF_D = '30-SEP-2008'
        ) Q2,
        SELECT
            PRO_CUSIP_I,
            ARS_RATG_C
        FROM
            ARS_OWNER.ARS_RATINGS_FACT
        WHERE
            REC_EFF_D = '30-SEP-2008'
        ) Q3       
    WHERE
        Q1.PRO_CUSIP_I = Q2.PRO_CUSIP_I (+)
        AND Q1.PRO_CUSIP_I = Q3.PRO_CUSIP_I (+)
) Q
GROUP BY    Q.CLI_TRD_ALW_STRT_C,
            Q.ARS_RATG_C,
            Q.PRO_DESC_T
ORDER BY    Q.CLI_TRD_ALW_STRT_C,
            Q.ARS_RATG_C,
            Q.PRO_DESC_T
/

Similar Messages

  • How to find the query name using infoset name

    Hi Experts
           Iam new to the sap queries(SQ01,SQ02), some queries already created.
          now i want to do some modification, my problem is i am not able to find the query name.
          I know the infoset name, can you tell me how to find the query name using the infoset name, is ther any table for this.
    i tried in sq01 also, but its confusion, pls advice me on this.
    thanks in advance.
    regards
    rajaram

    Hi
    try like this..
    SQ02 --> go to --> Query Directory..
    from there you can get all the queries belong to a Infoset.

  • How to find the query that generates print preview?

    Hello,
    How can I find the query that gets executed to generate  print preview? On SAP Business One client if I open a Sales Quotation and click on print preview a report is generated. What queries are run in the background to generate this report?
    Thanks for your help.
    Regards,
    Sheetal

    Hi Sheetal,
    In such cases i am using a Profiler which is connected to my company's database. If you are using SQL-Server, the start the "Profiler", connect it to your database server and start the trace. When the trace is running, execute the SBO action. After you executed this action you will see in the profiler the excuted SQL-Statements.
    Regards,
    Christian

  • Using RSRT to find the Query properties

    Hi All,
    Can anyone let me know to find out the Query properties using RSRT if we dont have access to BEX Analyser etc.,
    The properties like:
    <b>1.Variables built
    2.Exceptions built
    3.Conditions built
    4.Cell definitions built
    5.Types of Key figures built
    6.Query properties like Scaling factors, Show negative values as etc.,</b>
    As we have in RSRT for seeing List of Objects in Free Characteristics, Filters, Rows, Columns etc.,
    Will be waiting for Answers on this.
    Points will be rewarded for sure.

    Please go to RSRT --> select your query --> Selct query display as "HTML" and execute.
    The next page you will the actual resule display on HTML page with all properties like Exception, Condition ,Properties, etc
    Hope this helps...
    Regards
    Pankaj

  • How to Find the Query used by the Workbook ?

    Hi ,
    I am currently involved in trouble shooting a work book where some master data values are not being displayed.
    How do i find, which Query the work books is using ? or Let me know as to how should i proceed in solving the same .

    Hi,
    If you have access to BW Admin workbench... then choose the option metadatarepository(left side) of the BW admin workbench, search for the workbook(Technical name) and click on the "Network display dataflow" link.
    If you want to know the relationship between workbook and the queries:
    Check table RSRWORKBOOK which contains the WORKBOOKID and the GENUNIID.
    Table RSRREPDIR contains GENUNIID, query name RNAME, AUTHOR, LASTUSER, INFOCUBE
    Table RSRINDEXT contains the WORKBOOKID and workbook TITLE
    You should join the tables by GENUNIID and select in RSRREPDIR the rows that have COMPTYPE='REP' for queries and object version active/modified.
    With this information an infoset query can be created to list all workbook-query-user relationship (and even the query-infocube relationship).
    Hope this helps u...
    Regards,
    KK.

  • How to find the query name by seeing the program name?

    Hi,
    i have one auto generated program in production AQCSPU==========ZPSPOWHO======
    Now user executing this program by taking help of se38 and sa38 t-code.But now suddenly sa38 and sa38 access blocked for the user so thay are now unable to execute the above program(which was a report).
    They are  asking to craete a t-code for this program.How to do it? because in dev. system this program doesnot exist.
    Please help regarding this issue.

    Hello,
    Sanjoy Ghose suggestion is a good one. It should work.
    However i would advice that you download the query and infoset from your production system and then upload in your development system. Then assign the Tcode and move it across production. The advantage being that tomorrow if authorization for creation/changes in queries is taken our in production then you have a development copy to work on.
    Use program 'RSAQR3TR' to download the query and the infoset.
    Thanks,
    Neeraj

  • How to find the query name when we know the program name? Urgent!!!!!

    The same as the title, thanks in advance!
    For example, the program for the query is:AQZZZSAPQUERY===ZPAYMENT_MEDIA.

    Hi ,
    I think you have not given the correct name of the program .
    normally it will be AQZZ/SAPQUERY/ABZPAYMENT_MEDIA====
    Take the characters from the end i.e. before '=' sign and search in SQ01 to get the query name.
    for your example, Query name may be ZPAYMETN_MEDIA itself.
    Hope it helps you.
    Kind Regards,
    Ravi Sankar.Z

  • Unable to find the query

    hello all!!!!!
    i had posted a query in the last fortnight and i dont remember the date. the subject was "how to deploy an application developed in JDeveloper". i have gone through 12-13 pages but could not find it. i have to go through the answer once again. how can i search for that query? i did not find any search option for the threads.
    please help

    Do you mean this:
    deploying a web application
    You can just click your own name on the left of your post and you see all the latest posts you did.
    Regards
    Edit: John was a little faster then me :-)

  • TCODE to find the query...

    Hi All..
    Can anyone please help me in finding out the queries using a particular aggragate/cube (both) is there any TCODE for this.
    Waiting for replies in the earliest.
    Thank a lot in advance!!

    Hi,
    You may try tx RSRT.I think this helps you.
    Regards,

  • How to find out the query is accessing the DB tables or not

    Hi Gurus ,
    How to find out the query is accessing the DB tables or not.
    Where exactly we will find this information in SAP BW.
    I know that this information we can find in ST03. But where exactly we will find the query information along with DB information?

    Lakshmi
    Activate BI Technical Content for Query analysis and run query against that.
    Hope this helps
    Thanks
    sat

  • How to find the Executed time of query

    hi,
       i want to find out the execution time of query like a sales report executed in 10 min. how to find out that? is there is any TC for that or what is the option to use that?
    and how to fing out execution time of Data source to info providers.. or DSOs to IC? like how much time taken to load data?
    regards,
    preety

    Hello Preety,
          Goto RSRT give the query name and see the technical property you will find the query generation time.
    For the time taken for execution Select the execute and debug mode in the options select display statistics.
    Execute the query
    Click back
    You can see the statistics.
    Thanks
    Chandran

  • RC 8 error while transporting the query from Dev to Qa - Element missing

    Hi All,
    I have made a multiprovider by copying one existing one.
    I have copies one of the Bex queries using RSZC from the source to Target MP.
    While transporting the query from Dev to QA i have got the following error. (I have already moved the Multi Prov in a previous TR) 
    Has anyone seen similar types before. Any inputs will be highly appreciated.
    Start of the after-import method RS_ELEM_AFTER_IMPORT for object type(s) ELEM (Activation Mode)     
    Error when activating element 4LUSZK561QN74UDBJ7BPU9GFM                                             
    Element 4LUSZJXHIS1HM7TVDD9DK7HPU is missing in version M                                           
    End of after import methode RS_ELEM_AFTER_IMPORT (Activation Mode) - runtime: 00:00:06                                                                               
    Start of the after-import method RS_ELEM_AFTER_IMPORT for object type(s) ELEM (Delete Mode)         
    End of after import methode RS_ELEM_AFTER_IMPORT (Delete Mode) - runtime: 00:00:14                  
    Errors occurred during post-handling RS_AFTER_IMPORT for ELEM L                                     
    RS_AFTER_IMPORT belongs to package RS                                                               
    The errors affect the following components:                                                         
       BW-WHM (Warehouse Management)                                                                    
    Post-import method RS_AFTER_IMPORT completed for ELEM L, date and time: 20110517070045              
    Post-import methods of change/transport request BDAK959603 completed                                
         Start of subsequent processing ... 20110517070025                                              
         End of subsequent processing... 20110517070045                                            
    Kind regards,

    Hi Jith,
    First of all try to consolidate all your objects in a single TR and then move to Q from D.
    In this case check for the list of objects that you have in your TRs. If TR 3 have all the Objects that were in TR1, TR2, then transporting TR3 alone will work.
    Also, you can find the information related to the elements that were missed in your TR1,TR2 by following process.
    1. Go to your transport Logs and then to the entries marked as Error.
    2. There you will find the Query Element Ids, copy them
    3. Now, go to Table(Se16) RSZELTDIR, there enter those query elements.
    Now, you can able to find the elements that you have missed in your TRs. Hope this helps you.

  • How to find the total number of pair under particular parent according to pattern 1:2or2:1,1:1 day to day maximum up to 5 pair caping daily

    Dear friends,
    I provide full details here ,my database table structure ,data and stored procedure and my problem ,
    please review it and provide the solution or any idea to solve my problem.
    I am working on a project in which members are added in a tree pattern, and get the payment accordingly.
    below is my table structure ,data and stored procedure
    CREATE TABLE Associate_Income
    ID varchar(30) NOT NULL,
    ParentID varchar(30) NULL,
    IsLeft tinyint NULL,
    IsRight tinyint NULL,
    joingdate datetime NOT NULL
    go
    INSERT Associate_Income
    (ID, ParentID, IsLeft, IsRight, joingdate)
    SELECT 'Ramesh123', NULL, NULL, NULL '2014-01-03 16:31:15.000' UNION ALL
    SELECT 'Sonu', 'Ramesh123', 1, NULL, '2014-01-03 16:45:21.000' UNION ALL
    SELECT 'Pawan kumar', 'Ramesh123', NULL, 1, '2014-01-04 16:50:23.000' UNION ALL
    SELECT 'Ravi123', 'Sonu', 1, NULL, '2014-01-04 17:03:22.000' UNION ALL
    SELECT 'Vineet123', 'Sonu', NULL, 1, '2014-01-04 17:26:01.000' UNION ALL
    SELECT 'dev123', 'Ravi123', 1, NULL, '2014-01-05 19:35:16.000' UNION ALL
    SELECT 'Mukesh123', 'Ravi123', NULL, 1, '2014-01-05 19:40:41.000' UNION ALL
    SELECT 'poonam123', 'Vineet123', 1, NULL, '2014-01-05 19:49:49.000' UNION ALL
    SELECT 'monu', 'Pawan kumar', 1, NULL, '2014-01-05 17:32:58.000' UNION ALL
    SELECT 'Arti123', 'Pawan kumar', NULL, 1, '2014-01-05 19:54:35.000' UNION ALL
    My  database table Associate_Income  structure and data is as follow:
    ID ParentID IsLeft IsRight joingdate
    Ramesh123 NULL NULL NULL 2014-01-03 16:31:15.000
    Sonu Ramesh123 1 NULL 2014-01-03 16:45:21.000
    Pawan kumar Ramesh123 NULL 1 2014-01-04 16:50:23.000
    Ravi123 Sonu 1 NULL 2014-01-04 17:03:22.000
    Vineet123 Sonu NULL 1 2014-01-04 17:26:01.000
    dev123 Ravi123 1 NULL 2014-01-05 19:35:16.000
    Mukesh123 Ravi123 NULL 1 2014-01-05 19:40:41.000
    poonam123 Vineet123 1 NULL 2014-01-05 19:49:49.000
    monu Pawan kumar 1 NULL 2014-01-05 17:32:58.000
    Arti123 Pawan kumar NULL 1 2014-01-05 19:54:35.000
    by using below stored procedure i can count the total number of pairs under particular node in 2:1,1:1 ratio means first pair is completed when two node added to the left side of given parent node and one node added
    right side of given parent node after that all pairs are completed when one node added left side and one node added right side of parent node (1:1 ratio)
    example if i execute my stored procedure as follows it would return following.
    EXEC count_pairs 'Ramesh123'
    3
    so there is 3 pairs as shown in my figure.
    when we execute my stored procedure for ParentID 'sonu' it would return following.
    EXEC count_pairs 'sonu'
    2
    so there is 2 pairs as shown in my figure.
    My problem is to find the query which can return the total number of pair under particular node any given parent  node. day to
    day maximum 5 pairs in a day please any one can suggest us
    CREATE proc [dbo].[count_pairs]
    @ParentID nvarchar(50)
    as
    begin
    Declare @ParentSUM SMALLINT = 0
    Declare @SubLeftID nvarchar(50)
    Declare @SubRightID nvarchar(50)
    SELECT @SubLeftID = CASE WHEN [IsLeft] = 1 THEN [ID] ELSE @SubLeftID END
    ,@SubRightID = CASE WHEN [IsRight] = 1 THEN [ID] ELSE @SubRightID END
    FROM Associate_Income
    WHERE ParentID = @ParentID
    IF @SubLeftID IS NOT NULL AND @SubRightID IS NOT NULL AND EXISTS(SELECT 1 FROM Associate_Income WHERE [IsLeft] = 1 AND ParentID = @SubLeftID)
    BEGIN
    SET @ParentSUM = 1
    ;WITH Associate_Income_CTE AS
    SELECT [ID], [ParentID], [IsLeft], [IsRight], 0 AS [Level]
    FROM Associate_Income
    WHERE [ParentID] = @ParentID
    UNION ALL
    SELECT RecursiveMember.[ID], RecursiveMember.[ParentID], RecursiveMember.[IsLeft], RecursiveMember.[IsRight], Level + 1
    FROM Associate_Income RecursiveMember
    INNER JOIN Associate_Income_CTE AnchorMember
    ON RecursiveMember.[ParentID] = AnchorMember.[ID]
    SELECT @ParentSUM = @ParentSUM + COUNT([ParentID])
    FROM
    SELECT [ParentID]
    ,'IsLeft' AS [Direction]
    ,1 AS [Value]
    FROM Associate_Income
    WHERE [IsLeft] = 1
    AND [ID] <> @ParentID --AND [ID] NOT IN (@SubLeftID, @ParentID)
    AND [ParentID] NOT IN (@ParentID, @SubLeftID)
    UNION ALL
    SELECT [ParentID]
    ,'IsRight' AS [Direction]
    ,1 AS [Value]
    FROM Associate_Income
    WHERE [IsRight] = 1
    AND [ParentID] <> @ParentID
    ) AS Associate_Income
    PIVOT
    MAX([Value]) FOR [Direction] IN ([IsLeft], [IsRight])
    ) PVT
    WHERE [IsLeft] IS NOT NULL AND [IsRight] IS NOT NULL
    END
    SELECT @ParentSUM
    Jitendra Kumar Sr. Software Developer at Ruvixo Technologies 7895253402

    I don't think this is homework, I am not sure how helpful it was by Kalman to merge the two threads. It appears that two different persons posted the questions. It could be though, that it is the same problem and Jitendra has taken over Chandra's
    task.
    However, I was not able to understand the problem nor the figure. And nor the definition of pairs in this context. My assumption is that what Jitendra posted is an abstraction of the actual problem in order to not reveal intellecutal property. Possibly this
    makes the problem more difficult to understand for us outsiders.
    I've come so far that I worked out a table definition and INSERT statements with sample data, as well as a call to the procedure which returns 3 and this appears to map to the figure, but I don't know what it means. Since I don't know what this
    is about, I have not made any attepmts to understand the code, but I would appreciate clarification about the underlying business rules as well as the expected results for various test cases.
    CREATE TABLE Associate_Income(ID varchar(30) NOT NULL,
    ParentID varchar(30) NULL,
    IsLeft tinyint NULL,
    IsRight tinyint NULL,
    joingdate datetime NOT NULL)
    go
    INSERT Associate_Income (ID, ParentID, IsLeft, IsRight, joingdate)
    SELECT 'Ramesh123', NULL, NULL, NULL, '2014-01-03 16:31:15.000' UNION ALL
    SELECT 'Sonu', 'Ramesh123', 1, NULL, '2014-01-03 16:45:21.000' UNION ALL
    SELECT 'Pawan kumar', 'Ramesh123', NULL, 1, '2014-01-04 16:50:23.000' UNION ALL
    SELECT 'Ravi123', 'Sonu', 1, NULL, '2014-01-04 17:03:22.000' UNION ALL
    SELECT 'Vineet123', 'Sonu', NULL, 1, '2014-01-04 17:26:01.000' UNION ALL
    SELECT 'dev123', 'Ravi123', 1, NULL, '2014-01-05 19:35:16.000' UNION ALL
    SELECT 'Mukesh123', 'Ravi123', NULL, 1, '2014-01-05 19:40:41.000' UNION ALL
    SELECT 'poonam123', 'Vineet123', 1, NULL, '2014-01-05 19:49:49.000' UNION ALL
    SELECT 'monu', 'Pawan kumar', 1, NULL, '2014-01-05 17:32:58.000' UNION ALL
    SELECT 'Arti123', 'Pawan kumar', NULL, 1, '2014-01-05 19:54:35.000'
    go
    CREATE proc [dbo].[count_pairs]
    @ParentID nvarchar(50)
    as
    begin
    Declare @ParentSUM SMALLINT = 0
    Declare @SubLeftID nvarchar(50)
    Declare @SubRightID nvarchar(50)
    SELECT @SubLeftID = CASE WHEN [IsLeft] = 1 THEN [ID] ELSE @SubLeftID END
    ,@SubRightID = CASE WHEN [IsRight] = 1 THEN [ID] ELSE @SubRightID END
    FROM Associate_Income
    WHERE ParentID = @ParentID
    IF @SubLeftID IS NOT NULL AND @SubRightID IS NOT NULL AND EXISTS(SELECT 1 FROM Associate_Income WHERE [IsLeft] = 1 AND ParentID = @SubLeftID)
    BEGIN
    SET @ParentSUM = 1
    ;WITH Associate_Income_CTE AS
    SELECT [ID], [ParentID], [IsLeft], [IsRight], 0 AS [Level]
    FROM Associate_Income
    WHERE [ParentID] = @ParentID
    UNION ALL
    SELECT RecursiveMember.[ID], RecursiveMember.[ParentID], RecursiveMember.[IsLeft], RecursiveMember.[IsRight], Level + 1
    FROM Associate_Income RecursiveMember
    INNER JOIN Associate_Income_CTE AnchorMember
    ON RecursiveMember.[ParentID] = AnchorMember.[ID]
    SELECT @ParentSUM = @ParentSUM + COUNT([ParentID])
    FROM
    SELECT [ParentID]
    ,'IsLeft' AS [Direction]
    ,1 AS [Value]
    FROM Associate_Income
    WHERE [IsLeft] = 1
    AND [ID] <> @ParentID --AND [ID] NOT IN (@SubLeftID, @ParentID)
    AND [ParentID] NOT IN (@ParentID, @SubLeftID)
    UNION ALL
    SELECT [ParentID]
    ,'IsRight' AS [Direction]
    ,1 AS [Value]
    FROM Associate_Income
    WHERE [IsRight] = 1
    AND [ParentID] <> @ParentID
    ) AS Associate_Income
    PIVOT
    MAX([Value]) FOR [Direction] IN ([IsLeft], [IsRight])
    ) PVT
    WHERE [IsLeft] IS NOT NULL AND [IsRight] IS NOT NULL
    END
    SELECT @ParentSUM
    END
    go
    EXEC count_pairs 'Ramesh123'
    go
    DROP PROCEDURE count_pairs
    DROP TABLE Associate_Income
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Oracle View that stores the Query execution time

    Hi Gurus
    i m using Oracle 10G in Unix. I wudiold like to know which Data dictionary view stores the execution of a query. If it is not stored then hw to find the query execution time other than (Set timing on) command. What is the use of elapsed time and what is the difference between execution time and elapsed time? How to calculate the execution time of a query.
    THanks
    Ram

    If you have a specific query you're going to run in SQL*Plus, just do
    a 'set timing on' before you execute the query.
    If you've got application SQL coming in from all over the place, you can
    identify specific SQL in V$SQL/ and look at ELAPSED_TIME/EXECUTIONS
    to get an average elapsed time.
    If you've got an application running SQL, and you need to know the
    specific timing of a specific execution (as opposed to an average),
    you can use DBMS_SUPPORT to set trace in the session that your
    application is running in, and then use TkProf to process the resulting
    trace file.

  • Where is the query window in SSMSE 2008 Express?

    I have been trying to find the query window in SQL Server 2008 Express.  I've been using SSMSE 2005 Express from a Start Menu button called "SQL Server Management Studio Express."  So far I have installed
    Microsoft SQL Server 2008 R2 RTM - Express with Management Tools, and also
    Microsoft® SQL Server® 2008 Management Studio Express, and finally
    SQL Server 2008 Express Service Pack 3.  These are all the "86" installs for Windows 7, 32-bit, for example "SQLManagementStudio_x86_ENU.exe." 
    However I still can't find a button to open an application that will allow me to run queries.  All the Start Menu buttons I have now are Microsoft SQL Server 2008 - Configuration Tools, Microsoft SQL Server 2008 R2 - Import and Export Data (32-bit), and
    Microsoft SQL Server 2008 R2 - Configuration Tools.  The "Installed SQL Server features discovery report" shows nothing installed, but I've seen others say the same thing, so I'm not sure that's even working properly. 
    All I'm really trying to do is connect to a pre-existing SQL Server 2008 database on another server from my computer, and bounce SQL queries off of it.  Also it would be nice if there were an "Enterprise Manager" application such as I used to
    have with SQL Server 2000 that would actually graphically help write the queries. 
    Can somebody help me unwind this?  Thank you.
     

    I finally got this working.  I believe the problem was that I really was not running the installation as an administrator, when I thought that I was.  All is working fine now.
    Having said that, this is a very strange installation.  There are many versions and service packs to versions.  It's difficult to understand what is even needed.  At one point the only update allowed was if I installed SDK, which I don't think
    I needed.  After updating service packs, none of the version information seemed to change.  Installation was something of a shotgun technique; just keep throwing things at it until it works.  The strange thing to me is knowing how much work
    must go into writing all of these programs, and then finding installation to be such a muddled process.
    In the end, I'll take whatever works.  Thanks to those who tried to assist.

  • Finding the VO of a regionRN

    Hi,
    Can any one help me how to find the VO of "Personalize Stack Layout: (AppsNavigateFlatStack)" in Oracle Applications Home Page.
    Here i want to find the query(VO) used to list the Responsibilities assigned to the current user.
    thanks in advance..

    There would be an 'About This Page' link at the bottom left of the page.
    You can click on that, and find all the required details about the page

Maybe you are looking for

  • Error on verifying message against security policy Error code:1000

    Hi all, i ma getting the following error while calling a bssv(secured wsdl having https extension)  webservice from SOA.

  • Leave assisstant ( Creation of leave request on behalf of EE )

    Dears , Is it possible to create a separate workset , role in order to handle the creation of Leave request on behalf of EE . requirement on my company is to create a separate role to create leave requests on behalf of EE , while the creator should '

  • Problem with Windows 8.1 (64 bit) install

    I purchased PS 5.0 many years ago and purchased the upgrade to PS 7.0 a couple or so years ago.  I can't seem to install it on my new (Lenovo) computer that runs the Windows 8.1 (64 bit) OS.  Please Help.

  • Clearing adjustments icon

    If I want to clear all History and adjustments, I know I can "Clear All" on the History but how do I clear the "Adjustments" so the little icon on the filmstrip thumbnail image (+/-) "this image has adjustments" goes away, too?

  • Click boxes that do not behave-edit or trah them?

    I am getting better at doing things and note that I am creating a simulation that is categorized as "custom." This is fine as it gives me what I want but now with more experince I am seeing two items... 1-Run from slide "n" will generate the slides b