Without using SubReport or SQL Command in Main Report, get desired results without duplicating

It seems so simple.  I just need the cost, at a certain time (based on a parameter), for each item.  I wrote a SQL Command that works beautifully, but when it connects to the existing report, it slows to a horrible crawl and cannot be used for tables with over 4 million records.  Here is the SQL Command that provides the desired results:
SELECT TOP 1 WITH TIES "INVENTITEMPRICE"."ITEMID", "INVENTITEMPRICE"."PRICETYPE", "INVENTITEMPRICE"."MARKUP", "INVENTITEMPRICE"."PRICEUNIT", "INVENTITEMPRICE"."PRICE", "INVENTITEMPRICE"."PRICEQTY", "INVENTITEMPRICE"."ACTIVATIONDATE", "INVENTITEMPRICE"."DATAAREAID"
FROM ("AX09PROD"."dbo"."INVENTITEMPRICE" "INVENTITEMPRICE" INNER JOIN "AX09PROD"."dbo"."INVENTTABLE" "INVENTTABLE" ON (("INVENTITEMPRICE"."ITEMID"="INVENTTABLE"."ITEMID") AND ("INVENTITEMPRICE"."DATAAREAID"="INVENTTABLE"."DATAAREAID")))
WHERE  ("INVENTITEMPRICE"."DATAAREAID"=N'TMC' AND "INVENTITEMPRICE"."PRICETYPE"=0 AND "INVENTITEMPRICE"."ACTIVATIONDATE"<={?As Of Date})
ORDER BY ROW_NUMBER () OVER(PARTITION BY "INVENTITEMPRICE"."ITEMID" ORDER BY "INVENTITEMPRICE"."ACTIVATIONDATE" DESC)
I've attached the report with saved data.  However, when I remove the restrictions of just certain items, it is unusable as it is SO SLOW!
I can also get the desired results from using a subreport but it takes forever to export due to the number of records/items.  Whenever possible, I avoid subreports for this reason.  I've attached that report with data as well.
Please be patient as I'm not savvy in SQL, but decent in generating reports.  What am I doing wrong?  This seems SO simple.  The premise is that I want the corresponding information based on the date entered:  If the date entered is 3/15/2014, the result should be 91.15 as indicated below.  I'd simply like this value to be placed in a formula per item.
Item 80014:
Activation Date
Cost Price
6/2/2014
104.43
4/1/2014
91.58
3/1/2014
91.15
2/1/2014
92.89
1/1/2014
93.57
Any assistance would be GREATLY appreciated!
Thanks!
Teena
Update:  I was unable to attach the reports with .rpt or .txt extensions.  There were well under 1MB.  Any suggestions?

hi Teena,
if you're going the inline subquery route, try something like the following...the last line in the sub-query 'where' clause should in theory take care of matching the correct price based on relating the item id's between your cost price & inventory data. this should leave you with distinct values for each itemid then. hopefully it won't error out as i'm just guessing on the syntax.
SELECT DISTINCT
"INVENTTABLE"."ITEMID",
"INVENTTRANS"."DATAAREAID",
"INVENTTRANS"."DATEPHYSICAL",
"INVENTTRANS"."QTY",
"INVENTTABLE"."ITEMGROUPID",
"INVENTTABLE"."ITEMNAME",
"INVENTTRANS"."TRANSREFID",
"INVENTTRANS"."STATUSISSUE",
"INVENTTABLE"."ITEMTYPE",
"INVENTTRANS"."TRANSTYPE",
"INVENTTRANS"."RECID",
"INVENTTRANS"."DIRECTION",
SELECT TOP 1 "INVENTITEMPRICE"."PRICE"
FROM "AX09PROD"."dbo"."INVENTITEMPRICE" "INVENTITEMPRICE"
WHERE  "INVENTITEMPRICE"."DATAAREAID" LIKE 'TMC%'
AND "INVENTITEMPRICE"."PRICETYPE"=0
AND "INVENTITEMPRICE"."ACTIVATIONDATE"<={?As Of Date}
AND "INVENTITEMPRICE"."ITEMID" = "INVENTTABLE"."ITEMID"
ORDER BY "INVENTITEMPRICE"."ACTIVATIONDATE" DESC
) AS ITEMPRICE
FROM  
"AX09PROD"."dbo"."INVENTTABLE" "INVENTTABLE"
LEFT OUTER JOIN "AX09PROD"."dbo"."INVENTTRANS" "INVENTTRANS"
ON ("INVENTTABLE"."DATAAREAID"="INVENTTRANS"."DATAAREAID")
AND ("INVENTTABLE"."ITEMID"="INVENTTRANS"."ITEMID")
WHERE 
"INVENTTRANS"."DATAAREAID" LIKE 'TMC%'
AND (("INVENTTABLE"."ITEMGROUPID" LIKE 'RAW%') OR ("INVENTTABLE"."ITEMGROUPID" BETWEEN '000' AND '999') OR ("INVENTTABLE"."ITEMGROUPID" LIKE 'Ship_Box'))
AND "INVENTTABLE"."ITEMTYPE" IN (0,1)
ORDER BY 
"INVENTTABLE"."ITEMGROUPID",
"INVENTTABLE"."ITEMID",
"INVENTTRANS"."DATEPHYSICAL" ASC
Message was edited by: Jamie Wiseman

Similar Messages

  • Use subreport total in formula in main report

    Hi,
    I have a subreport which is a total figure. I just want to muliply this by a number in a field on the main report, can this be done?
    Any help appreciated!

    Symptom
    A report contains a subreport. Data from the subreport is required for calculations in the main report.
    How can you share subreport data with the main report in version 7 (or higher) of the Crystal Reports Designer?
    Resolution
    Shared variables, introduced in Crystal Reports version 7, make it easier to pass values from a subreport to the main report. Using shared variables requires two formulas: one to store the value in a shared variable, the other to retrieve the value from the shared variable.
    The most important thing to remember when using shared variables is that Crystal Reports must first evaluate the formula where the value is stored before evaluating the formula that retrieves the shared variable.
    For example if you want to pass a grand total from the subreport to do a calculation in the main report, follow these steps:
    1. In the subreport, create a formula similar to the one below:
    //@SubFormula
    //Stores the grand total of the
    //{Orders.Order Amount} field
    //in a currency variable called 'myTotal'
    WhilePrintingRecords;
    Shared CurrencyVar myTotal := Sum ({Orders.Order Amount})
    2. Place this formula in your subreport.
    3. In the main report, create a formula that declares the same variable name:
    //@MainFormula
    //Returns the value that was stored
    //in the shared currency variable called
    //myTotal in the subreport
    WhilePrintingRecords;
    Shared CurrencyVar myTotal;
    myTotal
    4. Place @MainFormula in a main report section that is beneath the section containing the subreport.
    NOTE:======
    For the shared variable to return the correct value in the main report, you must place @MainFormula in a main report section that is beneath the section containing the subreport. This ensures Crystal Reports evaluates the @SubFormula before @MainFormula.
    One way to do this is to insert a section below the section containing the subreport, and place @MainFormula in this new sub-section:
    · On the 'Format' menu, click 'Section'.
    · On the 'Sections' list, click the section containing the subreport.
    · Click 'Insert' (at top of dialog box). This inserts an additional subsection.
    · Click 'OK' to return to the report, and insert @MainFormula into this new sub-section.
    The next time you preview the report, @MainFormula displays the value from the subreport. In this particular example, that value was the grand total of the {Orders.Order Amount} field.
    ============
    5. Once you have verified that @MainFormula is returning the correct value from the subreport, you can include this formula in other main report formulas, such as:
    //@NewFormula
    //includes data from subreport
    {@MainFormula}+ Sum ({Customer.Last Year's Sales})
    · Place this formula in the same section as @MainFormula, or in a section further down on the report.
    You have now successfully shared data from a subreport with the main report.
    NOTE: =====
    This is not possible with On Demand Subreports in Crystal Reports.

  • How to get step results without tracing?

    Hi everybody,
    I've written an operator interface in VB6 and I need the result of each step.
    The problem is, that I can't use tracing.
    Is there a posibility to get the results without tracing?
    Thank you in advance for your help!!

    Hi,
    The Operator Interface displays each step in the window when tracing is enabled, otherwise nothing is displayed during execution for the sequencefile.
    Providing the Report is enabled, either in the configuration report options or via the Sequence Callback ReportOptions and the Sequence being run is using the process model entry point (Single Pass or TestUUT's), a report will be generated. Tracing doesn't affect whether a report is generated.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • Crystal Report performance - subreports or sql command?

    Hello,
    bit of quandary, I've an existing report that contains six subreports all sharing the same parameter to the main report, a 'projectID' field.
    The main report approximately returns 300 records/projects and each of the 6 subreports are passed the corresponding 'projectID' field 300 times.
    Now, I've succesfully incorporated the main report query and corresponding subreports into a TSQL command containing a number of subqueries in the Select clause:
    SELECT   PROJECT.PROJECTID, PROJECT.TITLE, PROJECT.REFERENCE, PROJECTSTATUS.PROJECTSTATUS, PROJECT.INPUT_DATE
    ,(SELECT max(INPUT_DATE) FROM V_PROJECT_NOTE AS VPN
    WHERE PROJECT.PROJECTID = VPN.PROJECTID) AS LastHeadline
    ,(SELECT
    MAX(CASE
         WHEN MODIFIED_DATE IS NULL THEN INPUT_DATE
         WHEN INPUT_DATE > MODIFIED_DATE THEN INPUT_DATE
              ELSE MODIFIED_DATE
    END) FROM ISSUE WHERE PROJECT.PROJECTID = ISSUE.PROJECTID) AS LastNewIssue
    ,(SELECT max(ISSUENOTE.INPUT_DATE) FROM ISSUE
    INNER JOIN ISSUENOTE ON ISSUE.ISSUEID = ISSUENOTE.ISSUEID
    WHERE PROJECT.PROJECTID = ISSUE.PROJECTID ) AS LastIssueNote 
    ,(SELECT max(modified_date) FROM V_PROJECT_RISK_LAST_AMMENDED AS VPR
    WHERE PROJECT.PROJECTID = VPR.PROJECTID) AS LastRiskLogUpdate
    ,(SELECT max(INPUT_DATE) FROM PROJECT_CHECKLIST AS PC
    WHERE PROJECT.PROJECTID = PC.PROJECTID) AS LastChecklistUpdate
    ,(SELECT max(input_date) FROM V_PROJECT_ACTIVITY_LAST_AMMENDED AS VPA
    WHERE PROJECT.PROJECTID = VPA.PROJECTID) AS LastGANTTUpdate 
    ,V_PROJECT_KEYCONTACT.USERNAME AS KeyContact
    ,(SELECT     USERPROFILE.USERNAME AS Supervisor
    FROM         USERPROFILE INNER JOIN
                          PROJECT_MEMBER AS SUPERVISOR ON USERPROFILE.USERID = SUPERVISOR.USERID RIGHT OUTER JOIN
                          PROJECT_MEMBER AS KEYCONTACT ON SUPERVISOR.PROJECT_MEMBERID = KEYCONTACT.PARENTID
    WHERE PROJECT.PROJECTID = KEYCONTACT.PROJECTID
    AND KEYCONTACT.KEY_CONTACT =1) AS Supervisor
    FROM         PROJECT INNER JOIN
                          PROJECTSTATUS ON PROJECT.PROJECTSTATUSID = PROJECTSTATUS.PROJECTSTATUSID LEFT OUTER JOIN
                          V_PROJECT_KEYCONTACT ON PROJECT.PROJECTID = V_PROJECT_KEYCONTACT.PROJECTID
    WHERE V_PROJECT_KEYCONTACT.USERNAME IN ('aaa','bbb','ccc')
    AND (PROJECTSTATUS.PROJECTSTATUS IN ('111', '222', '333'))
    AND ((PROJECT.TITLE NOT LIKE 'xxx%') AND (PROJECT.TITLE NOT LIKE 'yyy%') AND (PROJECT.TITLE NOT LIKE 'zzz%'))
    ORDER BY V_PROJECT_KEYCONTACT.USERNAME, PROJECT.INPUT_DATE
    Now, I've run both SQL Server Profiler and looked at the Performance Information in Crystal and the SQL command method is an order of magnitude less efficient!!
    I may have to post my query on a TSQL forum but was wondering if anyone on here can possible shed any light on it?
    Thanks in advance,
    Dom

    Dom,
    I assume that the last edit was to remove a few curse words...
    The reality is that we can give a good explanation as to why the sub-report version would execute faster that the command version w/o seeing the report (with the sub-reports included).
    Looking at the SQL, I can tell that it's a fairly expensive query, firing several sub-queries for every row returned by the outer query. That said, I sounds like the same thing is taking place with the sub-report version too... So I would think that the performance would be similar.
    The only thing that I can think of, and this is just a guess... With the sub-report version, each all queries are being run independently and then combined locally by CR, whereas the command version, everything is combined. The more complex the query, the harder the optimizer has to work to come up with the best execution plan... and the greater the likelihood that that the resulting plan isn't as optimized as it could be.
    That said, I'd still think the command version would be faster over all. Are you seeing real differences between the two reports, in the amount of time that it takes from refresh to final render?
    Either way, I think moving all of those sub-queries from the select list (where they are executing once for every row) down to the FROM area (where they only have to execute once) should increase the speed dramatically and surpass the sub-report version by a decent margin.
    Give this version of your SQL a test drive and see if it yields an improvement.
    SELECT  
    PROJECT.PROJECTID,
    PROJECT.TITLE,
    PROJECT.REFERENCE,
    PROJECTSTATUS.PROJECTSTATUS,
    PROJECT.INPUT_DATE,
    VPN.LastHeadline,
    ISSUE.LastNewIssue,
    ISSUE_NOTE.LastIssueNote,
    VPR.LastRiskLogUpdate,
    PC.LastChecklistUpdate,
    VPA.LastGANTTUpdate,
    V_PROJECT_KEYCONTACT.USERNAME AS KeyContact,
    Supervisor.Supervisor
    FROM PROJECT
    INNER JOIN PROJECTSTATUS ON PROJECT.PROJECTSTATUSID = PROJECTSTATUS.PROJECTSTATUSID
    LEFT OUTER JOIN V_PROJECT_KEYCONTACT ON PROJECT.PROJECTID = V_PROJECT_KEYCONTACT.PROJECTID
    LEFT OUTER JOIN (
         SELECT PROJECTID,
         max(INPUT_DATE) AS LastHeadline
         FROM V_PROJECT_NOTE
         GROUP BYPROJECTID) AS VPN ON PROJECT.PROJECTID = VPN.PROJECTID
    LEFT OUTER JOIN (
         SELECT PROJECTID,
         MAX(CASE
              WHEN MODIFIED_DATE IS NULL THEN INPUT_DATE
              WHEN INPUT_DATE > MODIFIED_DATE THEN INPUT_DATE
              ELSE MODIFIED_DATE END) AS LastNewIssue
         FROM ISSUE
         GROUP BY PROJECTID) AS ISSUE ON PROJECT.PROJECTID = ISSUE.PROJECTID
    LEFT OUTER JOIN (
         SELECT ISSUE.PROJECTID,
         max(ISSUENOTE.INPUT_DATE) AS LastIssueNote
         FROM ISSUE
         INNER JOIN ISSUENOTE ON ISSUE.ISSUEID = ISSUENOTE.ISSUEID
         GROUP BY ISSUE.PROJECTID) AS ISSUE_NOTE ON PROJECT.PROJECTID = ISSUE_NOTE.PROJECTID
    LEFT OUTER JOIN (
         SELECT PROJECTID,
         max(modified_date) AS LastRiskLogUpdate
         FROM V_PROJECT_RISK_LAST_AMMENDED
         GROUP BY PROJECTID) AS VPR ON PROJECT.PROJECTID = VPR.PROJECTID
    LEFT OUTER JOIN (
         SELECT PROJECTID,
         max(INPUT_DATE) AS LastChecklistUpdate
         FROM PROJECT_CHECKLIST
         GROUP BY PROJECTID) AS PC ON PROJECT.PROJECTID = PC.PROJECTID
    LEFT OUTER JOIN (
         SELECT PROJECTID,
         max(input_date) AS LastGANTTUpdate
         FROM V_PROJECT_ACTIVITY_LAST_AMMENDED
         GROUP BY PROJECTID) AS VPA ON PROJECT.PROJECTID = VPA.PROJECTID
    LEFT OUTER JOIN (
         SELECT PROJECTID,
         USERPROFILE.USERNAME AS Supervisor
         FROM USERPROFILE
         INNER JOIN PROJECT_MEMBER AS SUPERVISOR ON USERPROFILE.USERID = SUPERVISOR.USERID RIGHT
         OUTER JOIN PROJECT_MEMBER AS KEYCONTACT ON SUPERVISOR.PROJECT_MEMBERID = KEYCONTACT.PARENTID
         WHERE KEYCONTACT.KEY_CONTACT =1) AS Supervisor ON PROJECT.PROJECTID = Supervisor.PROJECTID
    WHERE V_PROJECT_KEYCONTACT.USERNAME IN ('aaa','bbb','ccc')
    AND (PROJECTSTATUS.PROJECTSTATUS IN ('111', '222', '333'))
    AND ((PROJECT.TITLE NOT LIKE 'xxx%')
    AND (PROJECT.TITLE NOT LIKE 'yyy%')
    AND (PROJECT.TITLE NOT LIKE 'zzz%'))
    ORDER BY V_PROJECT_KEYCONTACT.USERNAME, PROJECT.INPUT_DATE
    HTH,
    Jason

  • Can subreports use same selection parameter(s) as main report?

    Hi,
    Is it possible to create subreports that use the selection selection parameter(s) as the main report.
    And if so, would the user need to make their selections twice, or just once when they open the report?
    Thanks, Jon

    Hi
    Yes you can use the same parameter for both your subreport and the main report with running the parameter just once,.
    Create a parameter in your main report and link the same field(for which you have created the parameter) of subreport with this parameter.
    Now when you refrresh the report, you would input the values and the subreport would also return records based on those values.
    Note that this is simple when you are using same datasource and tables for both subreport and main report. Otherwise you need to have same structures for tables and data type as well for subreport and the main report.
    Hope this helps!!
    Regards
    Sourashree

  • How to set client within SQL statement without using another pl/sql stmt.

    I have a following select statement
    SELECT SUM (w.prior_forecasted_costs + w.prior_committed_costs)
    FROM xxsuf.job_cost_summary_table w,
    apps.pa_periods p,
    pa.pa_resources bz,
    pa.pa_resource_list_members cz,
    pa.pa_tasks dz
    WHERE w.project_id = z.project_id
    AND w.task_id = dz.task_id
    AND dz.task_number '98000'
    AND w.resource_list_member_id = cz.resource_list_member_id
    AND cz.resource_id = bz.resource_id
    AND NOT EXISTS (SELECT NULL
    FROM pa.pa_tasks zz
    WHERE zz.parent_task_id = dz.task_id)
    AND w.resource_list_member_id != 1000
    AND p.period_name = w.pa_period
    AND p.current_pa_period_flag = 'Y'
    Above select statement uses pa_periods view which only works when I set my client using "exec DBMS_Application_Info.set_client_info(83);" in Toad or SQL*Plus session.
    I was wondering how can I achieve it within select statement. so that I don't have to use another PL/SQL statement to set my client. Is there anyway to set client with my org id within above select statement ?
    Please advise.
    --Rakesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You can simply create a function which calls dbms_application_info and use that in your sql statement as in
    SQL> create or replace function set_client_info (i_info varchar2)
       return varchar2
    as
    begin
       dbms_application_info.set_client_info (i_info);
       return i_info;
    end set_client_info;
    Function created.
    SQL> create or replace view v_emp
    as
      select * from emp where empno = to_number(sys_context('userenv','client_info'))
    View created.
    SQL> select ename from v_emp where set_client_info(7788) is not null
    ENAME    
    SCOTT    
    1 row selected.
    SQL> select ename from v_emp where set_client_info(7900) is not null
    ENAME    
    JAMES    
    1 row selected.

  • Shared DateVar in Subreport and datediff calculation in Main Report?

    Hello experts,
    I am using CRXI sp2.  I have a report that contains two subreports for different dates in the same date field that are identified by a Service Code.  The subreports have been placed in the same group footer 1a to be displayed and the calculation resides in the main report group footer 1b.  The shared variables are as follows:
    whileprintingrecords;
    shared datevar Codedate5473;
    Codedate5473:={@Codedate5473};
    and
    whileprintingrecords;
    shared Datevar Codedate5623;
    Codedate5623:={@Codedate5623}
    The main report has the following calculation is in group footer 1a.
    Whileprintingrecords;
    Shared numbervar daysbetween;
    if (isnull({@Shared 5623})or isnull({@Shared 5473})) then 0
    else daysbetween:= datediff("d",{@Shared 5623},{@Shared 5473})
    This returns negative numbers as well as calculations where one of the shared variables is null.
    I reset the calculation in the report header as well.
    Thanks for your help in advance.
    Kevin

    Hi Kevin,
    I can reproduce your issue, As per my knowledge the crystal will make some issues in null value computation as well as  shared variable  computation
    In your report i can see , you tried to access values from subreport to main report through shared variable. that will make problem. we can access values from main report to subreport without any issue using shared..dont ask me the reason..i am not the right person to say that... lol.
    The another wrong thing  i was found in your formula is , you are not resetting the shared variable any where.. so once the date field is null, the shared variable returning the previous value.
    So this is the solution for you..
    1,You have to add one more subreport for displaying your result., Lets say 'Sub report3'
    and create a formula, like.(Same which you have write before for the result)
    shared datevar Codedate5473;
    shared Datevar Codedate5623;
    numbervar daysbetween;
    WhilePrintingRecords;
    daysbetween:= datediff("d",Codedate5473,Codedate5623);
    daysbetween;
    2, Re- write your first two formulas like this
    For Subreport1,
    WhilePrintingRecords;
    shared dateVar Codedate5473;
    if isnull({Codedate5473}) then
    Codedate5473:=date(0,0,0)
    else
    Codedate5473:=date({Codedate5473});
    For subreport2
    WhilePrintingRecords;
    shared dateVar Codedate5623;
    if isnull({Codedate5623}) then
    Codedate5623:=date(0,0,0)
    else
    Codedate5623:=date({Codedate5623});
    Hope this will works for you,
    Cheers,
    Salah.
    Edited by: salahudheen muhammed on Aug 7, 2009 1:05 PM

  • How To Suppress Records In Subreport Based on Value in Main Report

    I want to supress records in the Details section of my subreport based on a value in the Details of my Main report (main report could have same record as subreport).
    I created the following formula with a shared variable and placed it in the Details section of my main report:
    WhilePrintingRecords;
    Shared StringVar sCertCode :={ACCPASCERT.CERT_CODE}
    I placed the subeport in the Group Footer of the Main Report.
    In the subreport, in the Section Expert I added the following formula for Supress of the Details section:
    WhilePrintingRecords;
    Shared StringVar sCertCode;
    sCertCode = {ACCJBCERTS.PERS_CODE}
    Unfortunately even though the value in the main report is the same as the value in the subreport, those records are not being suppressed in the subreport.
    Would appreciate any ideas.
    Thanks.

    Thanks Zilla.
    The group is not based on Cert_Code but on another database field.
    I can try linking on the Cert_Code. But, how do you make the link "<" ">" when linking the main report and the subreport. I don't see that as an option?
    Edited by: Giulia Smyth on Feb 27, 2009 4:05 PM

  • Getting same results without inline view

    Hi gurus,
    My database version is 10.2.0.4.0.
    I have a couple of tables as follows:
    CREATE TABLE xxgroups(group_number NUMBER, description VARCHAR2(30));
    INSERT INTO xxgroups VALUES(1,'Group 1');
    INSERT INTO xxgroups VALUES(2,'Group 2');
    INSERT INTO xxgroups VALUES(3,'Group 3');
    INSERT INTO xxgroups VALUES(4,'Group 4');
    INSERT INTO xxgroups VALUES(5,'Group 5');
    CREATE TABLE xxgroup_persons(group_number NUMBER, person_number NUMBER, first_name VARCHAR2(30), last_name VARCHAR2(30));
    INSERT INTO xxgroup_persons VALUES(1, 1, 'John', 'Smith');
    INSERT INTO xxgroup_persons VALUES(1, 2, 'James', 'Smith');
    INSERT INTO xxgroup_persons VALUES(1, 3, 'Joe', 'William');
    INSERT INTO xxgroup_persons VALUES(2, 4, 'Julien', 'Ford');
    INSERT INTO xxgroup_persons VALUES(2, 5, 'James', 'Kelly');
    INSERT INTO xxgroup_persons VALUES(3, 6, 'Francis', 'Smith');
    INSERT INTO xxgroup_persons VALUES(5, 7, 'Jerry', 'Ford');
    INSERT INTO xxgroup_persons VALUES(5, 8, 'Alfred', 'Willis');
    INSERT INTO xxgroup_persons VALUES(5, 9, 'Jon', 'Preston');
    COMMIT;I'd like to get a query to return for each group, the person with lower person_number (if no person assigned to the group, then the query should still return the group with empty person). I know I can do it using for instance:
    SELECT group_number, person_number, first_name, last_name
    FROM (SELECT a.group_number, b.person_number, b.first_name, b.last_name
               , RANK() OVER (PARTITION BY a.group_number ORDER BY person_number) person_order
          FROM xxgroups a, xxgroup_persons b
          WHERE a.group_number = b.group_number (+)
    WHERE person_order = 1
    ORDER BY group_number;
    GROUP_NUMBER PERSON_NUMBER FIRST_NAME                     LAST_NAME
               1             1 John                           Smith
               2             4 Julien                         Ford
               3             6 Francis                        Smith
               4
               5             7 Jerry                          Fordbut would it be possible to get the same results without using inline view?
    Thanks.

    You could try this the KEEP function:
    scott@orapdt>  SELECT a.group_number,
      2         min(b.person_number) as person_number,
      3         min(b.first_name) keep (dense_rank first order by person_number) as first_name,
      4         min(b.last_name) keep (dense_rank first order by person_number) as last_name      
      5  FROM xxgroups a, xxgroup_persons b
      6  WHERE a.group_number = b.group_number (+)
      7  group by a.group_number;
    GROUP_NUMBER PERSON_NUMBER FIRST_NAME                     LAST_NAME
               1             1 John                           Smith
               2             4 Julien                         Ford
               3             6 Francis                        Smith
               4
               5             7 Jerry                          Ford
    5 rows selected.

  • When I try to use "store locator", e.g., Eddie Bauer, I get no result with Firefox 4 on Mac OS. Chrome and Safari work OK.

    At various web sites, e.g., Eddie Bauer and Walmart, when I try to use their "store locator", I get no result.

    go to '''TOOLS '''then '''OPTIONS''' then '''ADVANCED''' then '''NETWORK tab''' then '''SETTINGS tab''' and select the options '''NO PROXY''' click '''OK''' and '''OK '''again in the next screen. With that you have disabled the proxy settings.
    ''if you like to not disable the proxy settings choose'' : '''Auto-detect proxy settings for this network''' (it is in the same session)
    thank you
    Please mark "Solved" the answer that really solve the problem, to help others with a similar problem.

  • Since I upgraded iphoto, the program shuts down.  It loads for 2 minutes then just closes.  Ihave sent reports in and updated the program but it has been so frustrating.  I can't use iPhoto at all and can't even get at photos without it locking up. Help?

    Since I upgraded to iphoto 11, I have not be able to access my photos without the program locking up, not respondiong, and shutting down. iphoto has went into repair on its own, but still shuts down.   I have sent in reports each time, but have not figured out the problem.  Has anyone else had this problem?

    Post the first 50 - 100 lines of the crash log?
    As a Test:
    Hold down the option (or alt) key and launch iPhoto. From the resulting menu select 'Create Library'
    Import a few pics into this new, blank library. Is the Problem repeated there?
    Post back with the result.

  • Execute command on UNIX and get the result

    I want to write a Java program, which can execute a shell script in UNIX and get back the result. Any idea?

    Check these two tips:
    How to execute a command from code
    http://www.java-tips.org/java-se-tips/java.lang/how-to-execute-a-command-from-code.html
    How to read output from a Command execution
    http://www.java-tips.org/java-se-tips/java.lang/how-to-read-output-from-a-command-execution.html

  • Using unlinked sql command and table in a subreport

    All,
    Does CR allow using an unlinked sql command and a table in the same subreport?  I am passing the CurrentCEUserName from the main report to the sql command in the subreport (via linked parameter).  The sql command then executes a query to pass the parameter to the database (example: select myfunction('{?myparam}' from dual).  I need this to run before subreport's table query is executed. 
    This all appears to work except that the parameter passed to the sql command isn't set when the command executes.  The value is always null when the sql command is executed.  If I add the parameter to the report output it shows the expected value. 
    Also, if I have a subreport that just has a single sql command the parameter is set correctly prior to executing the command.
    any help would be appreciated.
    thanks!

    If you are looking for Crystal to run the SQL Command, then the SQL it generates itself, I think the answer is no, it won't do that.  Crystal expects all of the data sources to be linked, I believe.  I'm not sure what you would expect to happen if they are not...  However, you can make your SQL Command something like (MS SQL; sorry, it's been too long since I've used Oracle...):
    declare @result varchar(100);
    set @result = ( select myfunction('{?myparam}') );
    select * from table;
    which would run the first select calling your function, basically throw away the result (or you can do with it as needed), then return the fields from your table.
    HTH,
    Carl

  • How to use a subreport field as selection criteria for the main report

    Dear All,
       I created a report with one subreport and im comparing information from both reports but i need to apply selection criteria in the main report using one of the fields in the subreport, the problem is that the subreport field doesnt appear in the select expert screen. By any chance, someone knows how make a subreport field be used by the select expert.
    Thanks,
    Martha Medrano

    Dear Dom,
       I created the subreport table called IIM (748 items) in sql in the main report as you suggested with the below code:
    SELECT "IIM"."IPROD", "IIM"."IDESC", "IIM"."IID"
    FROM   "S102F360"."BPCS405CDF"."IIM" "IIM"
    WHERE   NOT ("IIM"."IDESC" LIKE 'GEN%' OR "IIM"."IDESC" LIKE 'OBS%') AND "IIM"."IID"<>'IZ' AND "IIM"."IPROD" LIKE '3%'
    and i have another table called ITEM_MASTER (3221 items):
    SELECT "ITEM_MASTER"."ITEM_ID", "ITEM_MASTER"."DESCRIPTION"
    FROM   "WHSPRO"."dbo"."ITEM_MASTER" "ITEM_MASTER"
    ORDER BY "ITEM_MASTER"."ITEM_ID"
    and im trying to display all items in the ITEM_MASTER table that are not in the IIM file but i haven't been able to accomplish this, i am using as primary the ITEM_MASTER table with 'Inner Join' as Join Type,  and '!=" as Link Type. Do you have any ideas on how can i display the requested items.
    Thanks for your help

  • Summary field of subreport used in main report formula calculation

    I have a summary field in a subreport that I want to use in a calculation of a percentage using a second summary field in the main report as the denominator.  How do I do this in a new formula?

    Thank You Ian Waterman,...
    Couple of questions:
    Where you say "... in subreport
    @ eval
    whileprinting records;
    shared number x:=your summary
    Am I correct that this is to be a new formula created in the subreport design?
    What should I put for the "x" in the formula?
    Should the "your summary" be:  "DistinctCount of Activated_Survey.Seq.Incident"  which I have showing in the Report Footer of the subreport?
    Where in the subreport should I place the formula?  Can it be hidden?
    Where you say "In subreport header..."
    @reset
    whileprintingrecords;
    shared number x:=0
    Am I correct that this is to be a new formula created in the subreport design?
    What should I put for the "x" in the formula?
    Where in the subreport should I place the formula?  Can it also be hidden?
    Where you say "In the main report in section after subreport..."
    I have the subreport sitting up in the main Report Header as I only want the subreport summary field showing. 
    In the subreport, I have the Report Header and Details section hidden.
    @calc
    whileprintingrecords;
    (shared number x / main report summary) * 100
    Am I correct that this is to be a new formula in the main report?
    However, what I need to have happen is that the main report summary field of: "Count of Answered_Survey.Seq.Incident" needs to be divided by the subreport summary field of "DistinctCount of Activated_Survey.Seq.Incident" * 100.
    What do I modify in the formula?
    Thanks.

Maybe you are looking for

  • "Drive no longer recognized"

    When I start up my imac all of a sudden I get the following: "The disk you inserted is not recognized" with the option to ignore, initialize or eject. The drive is a Western Digital MyBook Basic 1.5TB drive that I have been using for about a month wi

  • Disable inline viewing of attachments in Mavericks mail

    Dear all In previous version of the OS, there was an easy terminal fix to disable inline viewing of attachments in mail. Instead of bulky and cumbersome images and PDFs, I used to get nice, neat icons. This terminal fix doesn't seem to work in Maveri

  • This is for people who wants to mirror all they apple devices when they travel.

    this is for people who wants to mirror all they apple devices when they travel and don't want to unplug everything from the apple tv and take it with them, you can get the amazon fire tv stick and download an app called airplay upnp or the reflector

  • HOW TO DUBUG BACKGROUND JOB?

    1)HOW TO DUBUG THE BACKGROUND JOB? 2) HOW TO DEBUG THE BACKGROUND JOB WHICH IS ALREADY RUNNING?? CAN YOU PLZ REPLY TO THE ABOVE TWO QUESTIONS....??? URGENT... THANKS IN ADVANCE SRI

  • Setting Prompt precedence

    I have set of prompts which are available in BI Query and used in WebI. My problem in WebI is that I am not able to get the prompt order which is set in BI Query. How I can set the prompt order in WebI if these prompts are created in BI Query. Thanks