Total number of quiz questions in an introduction slide?

Hello,
   I have a simple Quiz with 10 total questions.  I have an introduction slide with some basic information. 
   I would like to include the total number of questions in the intro slide.  (I know I can just manually count up the questions and add that as a text caption).  I am wonder if there is a way to insert this dynamically as it is in the results slide. 
    {total-questions}       doesn't just work on its own on any other slide.
Thanks!  -Vinny

There is a quizzing system variable that has that value and you could
insert it in a text container cussing the X button in the Format accordion
. If you use CP8.it is in the style tab, in edit mode in  the Character
part
Not totally sure about the exact name of the var. Something like
cpQuizInfoTotal.... Look in the quizzing category of varaiables. No CP on
my phone.

Similar Messages

  • Interactive objects and quiz questions

    Hi everyone,
    I know that you can't add interactive objects to quiz questions, so what is the best way to accomplish my need of placing a button that, when clicked, plays a short mp3 audio file to a quiz question?
    Alternatively, if I am to replace my Captivate quiz questions with new custom slides, how can I replicate all of the multiple choice, etc question types? Are there widgets for these?
    I appreciate the help! I was looking around for reference items speaking to this issue but couldn't find any.

    Hello,
    On default question slides like on other slides, you can attach an audio clip to an object (even an object that is invisible to the user like a rectangle without a stroke and an fill with alpha=0%). The clip will play when the rectangle gets visible, but... you cannot put a button on a question slide. The only button that is possible is the static button widget but it has not the possibility to show/hide an object. You can attach the clip to the Success/Failure captions, eventually show/hide the invisible object with events like entering a slide, or Success/Failure actions but those events (appearing of captions, executing actions) cannot be controlled by a button.  If that is what you want, you need custom question slides. You didn't explain really at what moment you want to offer the audio, perhaps you do not need to give total control for playing by a button?
    Several blog posts I created talk about creating custom question slides with or without the help of widgets. Here is one link that shows a list of the articles/posts with widgets:
    Widgets and Custom Questions
    Not all question types are possible: if you want drag&drop functionalities I recommend the Drag&Drop widgets of InfoSemantics. Have a look here:
    http://www.infosemantics.com.au/dragdrop/whichwidget
    Another problem is the reporting of custom question slides. I already published two posts about that subject on my blog as well.
    Lilybiri

  • Multiple quiz questions

    Does anyone know a quick way of putting more than one quiz
    question on a single slide?

    Hi Ailse,
    Your idea of using masks is a good one. You're thinking like
    a true Captivate expert!
    You could also try taking a screenshot of the questions on
    each slide, cropping them to show only the interesting parts, then
    inserting those images on your Question slides so it looks like the
    other questions are all present on a single slide.
    Only the actual Captivate question would be "live" on a given
    slide and your images wouldn't reflect what the user answered on
    previous slides, but it should be fairly convincing, especially
    given the circumstances.
    If you want to go all out, temporarily change the font color
    of each question to gray before taking your screenshot, and the
    questions will appear "disabled" when you import them into
    Captivate. This would give the user a reason why the "non-live"
    questions are not working on a given slide.
    Regards,
    John

  • How to get a question in the course placed anywhere in the course and does not appear in the quiz result or total number of questions. Pretest would work except it can't go anywhere in the course (at least for me it can't)

    How to get a question in the course placed anywhere in the course and does not appear in the quiz result or total number of questions. Pretest would work except it can't go anywhere in the course (at least for me it can't)

    Use a normal question, and do not add the score to the total score. That will give you a correct score at the end. But the total number of questions, that system variable will still take into account all questions. You'll need a user variable, and calculate its value by subtracting 1 from the system variable cpQuizInfoTotalQuestionsPerProject. Same for the progress indicator if you want to show it?
    Customized Progress Indicator - Captivate blog
    If you want to allow Review, you'll have to tweak as well. You didn't specify the version, and all those questions I now mentioned.
    And my approach, since you talk about only one question: create a custom question, because you'll have total control then.

  • PowerShell Exchange 2007 Question To count up the total number of email addresses (view/hidden) per GAL

    Hello All:
    I am very new to Power Shell and need some help:
    I have 224 GAL's on our Exchange System (Ex 2007) where, I need to count the total number of email addresses/display names assigned to each GAL.  I am not sure how to set up a for-next loop in PowerShell.  I am not sure how to set a  input
    file/variable, with the names of each GAL.  (GAL is Global Address List)
    I think it's $GALLIST = 'NameofGal1, NameofGal2, etc thru to NameofGaln' where n is the last GAL in the list.
    So I need to now a command which would get all the gal names (Get-AddressList(?) for all the GAL's in the Exchange System and then pipe them into a function to count the number of email addresses.
    In making a start with the following code and got stuck:
    Get-Mailbox | Where {$_.GlobalAddressList -eq “GAL” -and $_.} | Select-Object Displayname, EmailAddresses, count
    Missing or invalid property reference or expression.
    At line:1 char:71
    + Get-Mailbox | Where {$_.GlobalAddressList -eq "GAL" -and $_.} <<<<  | Select-Object Displayname, EmailAddresses, count
    I think I know how to pipe the results to a csv file - with - Export-Csv  -path c:\filename.csv - NoTypeInformation.
    Please can someone advise.  Please help.
    Thanks in advance
    PS - is there a way to access, read and display variable name and value which stores the number of email addresses/per GAL in exchange 2007 database so you don't have carry out a count exercise.  Because this metadata will be in the Exchange DB? 
    Would this be easier to get?
    Started building conditional statement:
    Get-Mailbox | Where {$_.GlobalAddressList -eq "GAL" AND {{HiddenFromAddressListsEnabled -eq $True} OR {HiddenFromAddressListsEnabled -eq $False}} |
    If {{HiddenFromAddressListsEnabled -eq $True} | Select-Object Displayname, EmailAddresses, count ELSE {HiddenFromAddressListsEnabled -eq $False}} | Select-Object Displayname, EmailAddresses, count
    ENDIF
    Export-Csv -path c:\test.csv -NoTypeInformation
    Will this work?  Checking to see how to do a for-next loop.
    $GAL = Get-GlobalAddressList
    foreach($GAL IN $GAL)
    Get-Mailbox | Where {$_.GlobalAddressList -eq $GAL AND {{HiddenFromAddressListsEnabled -eq $True} OR {HiddenFromAddressListsEnabled -eq $False}} |
    If {{HiddenFromAddressListsEnabled -eq $True} | Select-Object Displayname, EmailAddresses, count AS "Count of Hidden Addresses" ELSE {HiddenFromAddressListsEnabled -eq $False}} | Select-Object Displayname, EmailAddresses, count AS "Count of 
    Visible Addresses" |
    Export-Csv -path c:\test.csv -NoTypeInformation |
    not sure if this works and looks spaghetti -like!

    Hi Everton,
    In addition, If you want to export GlobalAddressList, please refer to the script below:
    $filter = (Get-GlobalAddressList 'Default Global Address List').RecipientFilter
    #filter HiddenFromAddressListsEnabled is ture
    Get-Recipient -RecipientPreviewFilter $filter | Where-Object {$_.HiddenFromAddressListsEnabled -eq $ture} | Select-Object Name,PrimarySmtpAddress
    #filter HiddenFromAddressListsEnabled is false
    Get-Recipient -RecipientPreviewFilter $filter | Where-Object {$_.HiddenFromAddressListsEnabled -eq $false} | Select-Object Name,PrimarySmtpAddress
    Refer to:
    How to Export the Exchange 2010 Default Global Address List (GAL)
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • I have a question about the new version of itunes. in the old version at the bottom of the sceen it display the total number of media and the size of the files. how can i get the new version to diplay this?

    in the old version at the bottom of the sceen it displayed the total number of media and the size of the files. how can i get the new version to diplay this?

    You're welcome. It was frustrating for me as well until I stumbled across "the fix"

  • The quiz is not correctly calculating the number of quiz items in the published version

    The quiz is not correctly calculating the number of quiz items in the published version
    I created 20 quiz questions, but the output say there are 255.  The slides between do not have quizzing enabled.

    I have a similiar problem. However, I am tracking user activity through tracking "next" buttons. Each button (and other interactions) has a objective ID and interaction id. The objective id is the same throughout the course; however each interaction and quiz item have different interaction ids. The total quiz items is shown as 54 and the first question is shown as question 50 or 54.
    The course will be published to Blackboard as the LMS; I am using SCORM 1.2
    The following settings are needed to track the user activity throughout the course, specifically the "next" buttons:
    1. include in quiz
    2. report answers
    The  answers to the problem of total quiz items not matching the actual number of questions has you turn off the include in quiz for interactions. How is this problem resolved when you want these interactions included with the information passed through SCORM to the LMS?

  • What variable use to show number of quiz ?

    what variable use to show number of quiz ?
    (it like Absolute)
    it is not in (reference of captivate)
    for example, quiz have 5 page.
    on test page 1 show 1.
    on test page 2 show 2.
    on test page 5 show 5.
    it like microsoft word show page number when print
    sorry if you not understand.

    All quizzing system variables are described in these blog posts: System variables in Captivate 6 - Captivate blog    and for 7.0.1: New features in Captivate 7.01 - Captivate blog. In 8 no variables were added to the category Quizzing. And there is no progress quizzing system variable. Only the total number of questions, second part of the progress indicator, is available: cpQuizIntoTotalQuestionsPerProject.
    You'll have to create and populate a user variable. Some help maybe in: Customized Progress Indicator - Captivate blog

  • How to get the total number of occurrences based on the value of a column.

    Hello everyone,
    This is the first time that I will ask question here on your forum but has been following several threads ever since. I guess that now is my turn to ask a question. So anyway here is the thing, I have a query that should return count the number of rows depending on the value of SLOT. Something like this:
    WIPDATAVALUE          SLOT             N            M
    1-2                   TRALTEST43S1     1            3
    1-2                   TRALTEST43S1     2            3
    3                     TRALTEST43S1     3            3
    4-6                   TRALTEST43S2     1            4
    4-6                   TRALTEST43S2     2            4
    4-6                   TRALTEST43S2     3            4
    7                     TRALTEST43S2     4            4-----
    As you can see above, on the SLOT TRALTEST43S1, there are three occurrences so M (Total number of occurrences) should be three and that column N should count it. Same goes with the SLOT TRALTEST43S2. This is the query that I have so far:
    SELECT DISTINCT
    WIPDATAVALUE, SLOT
    , LEVEL AS n
    , m
    FROM
      SELECT
        WIPDATAVALUE
        , SLOT
        , (dulo - una) + 1 AS m
      FROM
        SELECT
          WIPDATAVALUE
          , SLOT
          , CASE WHEN INSTR(wipdatavalue, '-') = 0 THEN wipdatavalue ELSE SUBSTR(wipdatavalue, 1, INSTR(wipdatavalue, '-')-1) END AS una
          , CASE WHEN INSTR(wipdatavalue, '-') = 0 THEN wipdatavalue ELSE SUBSTR(wipdatavalue, INSTR(wipdatavalue, '-') + 1) END AS dulo
        FROM trprinting
        WHERE (containername = :lotID OR SLOT= :lotID) AND WIPDATAVALUE LIKE :wip
    ) CONNECT BY LEVEL <= m
    ORDER BY wipdatavalue;And that it results to something like this:
    WIPDATAVALUE          SLOT             N            M
    1-2                   TRALTEST43S1     1            2
    1-2                   TRALTEST43S1     2            2
    3                     TRALTEST43S1     1            1
    4-6                   TRALTEST43S2     1            3
    4-6                   TRALTEST43S2     2            3
    4-6                   TRALTEST43S2     3            3
    7                     TRALTEST43S2     1            1-----
    I think that my current query is basing its M and N results on WIPDATAVALUE and not the SLOT that is why I get the wrong output. I have also tried to use the WITH Statement and it works well but unfortunately, our system cant accept subquery factoring.
    I know you guys will be helping out because you are all awesome. Thanks everyone
    Edited by: 1001275 on Apr 19, 2013 8:07 PM
    Edited by: 1001275 on Apr 19, 2013 8:18 PM

    Hi,
    Sorry, it's still not clear what you want.
    Are you saying that, given this table:
    CREATE TABLE trprinting
      WIPDATAVALUE       VARCHAR2(255)
    , SLOT               VARCHAR2(255)
    INSERT INTO trprinting (wipdatavalue, slot) VALUES ('1-2',  'TRALTEST43S1');
    INSERT INTO trprinting (wipdatavalue, slot) VALUES ('3',    'TRALTEST43S1');
    INSERT INTO trprinting (wipdatavalue, slot) VALUES ('4-6',  'TRALTEST43S2');
    INSERT INTO trprinting (wipdatavalue, slot) VALUES ('7',    'TRALTEST43S2');you want to produce this output:
    WIPDATAVALUE SLOT                     N          M
    1-2          TRALTEST43S1             1          3
    1-2          TRALTEST43S1             2          3
    3            TRALTEST43S1             3          3
    4-6          TRALTEST43S2             1          4
    4-6          TRALTEST43S2             2          4
    4-6          TRALTEST43S2             3          4
    7            TRALTEST43S2             4          4? If so, here's one way:
    WITH     got_numbers     AS
         SELECT     wipdatavalue
         ,     slot
         ,     TO_NUMBER ( SUBSTR ( wipdatavalue
                               , 1
                           , INSTR ( wipdatavalue || '-'
                                ) - 1
                     )          AS low_number
         ,     TO_NUMBER ( SUBSTR ( wipdatavalue
                               , 1 + INSTR ( wipdatavalue
                     )          AS high_number
         FROM     trprinting
    SELECT       wipdatavalue
    ,       slot
    ,       ROW_NUMBER () OVER ( PARTITION BY  slot
                                 ORDER BY          low_number
                        )                    AS n
    ,       COUNT (*)     OVER ( PARTITION BY  slot )     AS m
    FROM       got_numbers
    CONNECT BY     LEVEL               <= high_number + 1 - low_number
         AND     low_number          = PRIOR low_number
         AND     PRIOR SYS_GUID ()      IS NOT NULL
    ORDER BY  low_number
    ,            n
    ;Much of the complexity here is caused by storing 2 numbers in 1 VARCHAR2 column, wipdatavalue. Relational databases work best when there is no more than 1 item in any given column of any given row. This is so basic to datbase design that it is called First Normal Form. Also, numbers belong in NUMBER columns, not VARCHAR2. If you stored your data like that in the fist place, then you wouldn't need the sub-query I called got_numbers, which is about 60% of the code above. (That could be reduced by replacing SUSTR and INSTR with the less efficient REGEGP_SUBSTR.)

  • To find total number of files inside folder

    Hai,
       In knowledge management is there any option to find total number of files inside folder...
        I also want to see the recently uploaded and modified documents in a seperate iview...
        Iam using NW2004s SP8..
        Very urgent..
        Waiting for a positive reply..
        Thanks&regards,
         Kiruthika.S

    Hi Kiruthika,
    1. You only need the configarchive if you don't want create all the KM configuration objects mentioned in the guide manually. So, just create the objects mentioned there and you don't need the configarchive
    Also, the scenario works also on 2004s.
    2. Please check this thread on how to show the total number of files inside a folder:
    https://forums.sdn.sap.com/thread.jspa?threadID=19610
    3. It would be nice if you would consider rewarding the time people like Saravanan spend to investigate and answer your question by assigning points via the colored stars.
    Best regards,
    Robert

  • How can I see the total number of books (size of library) on iBooks on my iMac and IPad Mini?

    I have installed iBooks on both my iMac (main library) as well as on my iPad Mini Retina. I can't seem to find where to see the total number of books in each library? Can anyone enlighten me please? I can see the covers, lists etc. but nowhere how many books I have total in each library (Total: X number of books stored) or something like that. Can someone point me where this information is viewable?

    Did you have 'find my iPhone' activated on it? Because if you go to iCloud.com you can log in there and you can remotely lock or wipe your device.  From what I hear, the police won't do anything about going and fetching stolen iPads and iPhones, but if you have find my iphone/ipad/ipod/mac turned on then it will give you a map of where it is. 
    Just keep in mind that sometimes iTunes does ask you for your password regardless, and only a few weeks ago apple brought in security questions, so everyone had to fill in security questions for their iTunes account to make it more secure If all else fails, ring Apple cusomer support and they might be able to bar your account or something, however you may have to make a new account (the might be able to set it up so you have all your previous information on a new account)
    Hope this helps!

  • How can I get a report with total number of pages printed on my HP Officejet Pro 8610?

    Since knowing the number of pages I print is so critical to a choice of using the "HP Instant Ink Plan" or not, how can I find the total number of pages I have printed on my brand-new (installed 2 days ago) 8610?  And if I can, is it a "resettable" or rolling total?  Don't see anything in user guide and a search yields nothing usable on this blog.
    Printer is installed wirelessly on an older PC with Windows XP SP3.  I can also of course intstall it with network cable but so far it works OK on my home network without network cable.  If it matters which OS, I also have a Lenovo laptop running Vista on which I can install this printer. 
    Please do not respond that I can find the total by counting the number of pieces of paper I have.  Surely the internals of this fine machine must have the requested data so that HP can tell my usage if I select the monthly ink plan!
    This 8610 was a good buy (net $89.00 after trade-in of my six year old J36xx Deskjet) at Office Depot/Max which of course influenced my decision to buy it.  So far I am very happy with printing qualities and speed, have not tried the scanner yet and will probably never use the fax since I have no land line phone. 
    Thanks,
    Harry
    This question was solved.
    View Solution.

    Hi,
    Section #2 of the Printer Ststus report will tell you. Please try:
    Printer status report
    Use the printer status report to view current printer information and ink cartridge status. Also use the printer status report to help you troubleshoot problems with the printer.
    The printer status report also contains a log of recent events.
    If you need to call HP, it is often useful to print the printer status report before calling.
    To print the Printer Status Report
    1. From the printer control panel display, touch and slide your finger across the screen and then touch Setup.
    2. Touch Print Reports and then touch Printer Status Report.
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • How do i find the total number of fields within all tables in one of my databases

    I'm in the process of creating some "gee whiz" metrics for one of my applications and want to find the total number of columns contained in its database.  Is there a stored procedure to get this information that would save me the effort
    of opening each of my 66 tables and counting the columns?  I also have the same question for my 138 views.  Thank you for any ideas you care to offer...............Phil Hoop
    Phil Hoop

    Hi Phil,
    Assumes SQL 2005 or higher
    Let 's try simple one ....
    SELECT COUNT(col.column_name), col.table_name
    FROM information_schema.columns col
    JOIN information_schema.tables tbl
    ON tbl.table_name = col.table_name
    AND tbl.table_schema = col.table_schema
    AND tbl.table_catalog = col.table_catalog
    AND tbl.table_type = 'VIEW'
    GROUP BY col.table_name
    Let me know if this will help you.
    If you think my suggestion is useful, please rate it as helpful.
    If it has helped you to resolve the problem, please Mark it as Answer.
    Varinder Sandhu www.varindersandhu.in

  • How to get total number of days

    Hi All,
    how to get total number of days , for example if month eq 05 then need to get total number of days until MAY 31.
    and how to get total number of days in a month.
    Thank You,,
    Sriii..

    Hi Sridhar,
    Pls Try to search before posting general questions.
    Try this,
    CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
        EXPORTING
          i_datum_bis                   = p_lv_date1
          i_datum_von                   = p_lv_date2
       IMPORTING
         e_tage                        = p_e_date_difference
       EXCEPTIONS
         days_method_not_defined       = 1
         OTHERS                        = 2
      IF sy-subrc  0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Regards,
    Sunil kairam.

  • 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]

Maybe you are looking for