Discoverer Custom SQL Report with Group By,Having

Hi all,
I'm working with Discoverer 4.1.41.05 and retrieve data from Oracle HRMS.
I want to create a report based on a custom SQL Folder in Discoverer Administration to solve the following scenario:
SELECT EMPLOYEE_NUMBER FROM PER_ALL_PEOPLE_F
MINUS
SELECT EMPLOYEE_NUMBER FROM PER_ALL_PEOPLE_F,PER_EVENTS, PER_BOOKINGS
GROUP BY EMPLOYEE_NUMBER
HAVING SUM(PER_EVENTS.ATTRIBUTE1) >= 10)
The problem is when I run the sql from SQL*Plus is working fine producing the correct result.
When I create the Custom Folder and create a Discoverer report based on it I retrieve all employees since the second select statement retrieve no rows!
Does anyone has any idea how I can solve this problem or if there is another way to create this scenario?
Any feedback is much appreciated.
Thanking you in advance.
Elena

Hi Elena,
I think you are missing some joins, you could try something like:
SELECT EMPLOYEE_NUMBER FROM PER_ALL_PEOPLE_F p
WHERE NOT EXISTS
(SELECT NULL
FROM PER_EVENTS e, PER_BOOKINGS b
WHERE b.person_id = p.person_id
AND e.event_id = b.event_id
GROUP BY b.person_id
HAVING SUM(e.ATTRIBUTE1) >= 10)
Rod West

Similar Messages

  • Aggregrate function in report with group by

    I have SQL report with all the records and Total of some of the fields in end.
    I wanted to group them by item1 and than show the Total for the fields for each Item

    In your report have a break formatting section, select the column you wish to break (sub-total on).. make sur eto set the sum checkbox on the column you ar edoing the break on too! It will then build the sub-total line for you..
    Thank you,
    Tony Miller
    Webster, TX
    Never argue with an idiot. They drag you down to their level, then beat you with experience.
    If this question is answered, please mark the thread as closed and assign points where earned..

  • Matrix report with group.

    dear all,
    can anyone guide me how to build a matrix report with group using scott schema.
    i can not be able to build a query.
    Thanks
    Muhammad Nadeem

    The example given by Oracle (from the above link) using the following SQL for a matrix report is flawed.
    SELECT DEPTNO, JOB, SUM(SAL)
    FROM EMP
    GROUP BY DEPTNO, JOB
    ORDER BY DEPTNO, JOB
    The SUM function handled by the query restricts you from doing so many things - especially when you want the empty fields to be filled by 0 (by using the Value if Null property).
    If the query is changed to ''SELECT DEPTNO, JOB, SAL FROM EMP' , and use the SUM function in the wizard to build the Matrix cell, then the 'Value if Null' property can be used without any issues.
    This also makes Section 25.6 (Add zeroes in place of blanks) of the documentation a joke.
    Anyway, that's my cents worth....

  • Report with grouping issue

    I have a report which have year(2008), Category(0-1,2-3, ALL), product(0,1,2,3,4..), % sales. I group by all the category elements and called it as All, I am not getting the right percentage sales for the Category ALL other wise for 0-1,2-3 i am getting it right. Please advise where i am doing it wrong. please find the blog for a screen shot of my issue.
    http://ravibiblog.blogspot.com/2012/04/report-with-grouping-issue.html
    Thanks,
    RC

    Pl post details of OS, database and EBS versions. Pl see if these MOS Docs can help
    FARXPBSH Failing With "Program was terminated by signal 11" or "Program was terminated by signal 10"          (Doc ID 742729.1)
    Publishing RXAPPYAC: The FARXPBSH Ends With 'Signal 11' Error          (Doc ID 432797.1)
    RXi RX Reports Failing With Program Was Terminated By Signal 10 or 11 Errors After FA Rollup Patch 6          (Doc ID 737963.1)
    Program was Terminated by Signal 11 when Running Rxi Reports          (Doc ID 559425.1)
    HTH
    Srini

  • SQL Report with Scroll - javascript

    This is an example of Apex SQL Report with Scroll - made with javascript: http://tryapexnow.com/apex/f?p=12090:9
    Waiting for comments here.

    Yes, because of the page generated by APEX, if you use the Report Template APEX 4.0 Standard, the div created for the report table has the ID "with_scroll" but there is another div which actually contains the table, and it's ID is "report_with_scroll", they just add a "report_" in front of it.
    I find the table by searching through the childs of that div: var table = document.getElementById(myRegion).rows[1].cells[0].firstChild;
    You can use the first one, with the ID "with_scroll", but this code line will be longer.
    Also to addapt the script for other report templates, you just need to see the code generated by every template, and correct this line, to get the real table containing your report.

  • SQL report with delete capability

    I want to create a SQL report with the capability of delete rows (show checkboxes next to each row). Is this possible?

    You can create a page type of Tabular Form, remove all buttons but delete, change all the edit boxes to display as text (saves state) and use that.

  • Pl-sql report with parameter

    Hi
    I have created report with region source as pl-sql. In pl-sql block, calling package where i am passing query. In query's where clause i want to pass paramter value which user had selected.
    There are two regions on page. On upper part, there is select list, on lower part there is report with pl-sql region but value of select list is not found in query. I am trying to access with bind variable, select list of item :SL_TEXT. But it is not showing any value in it.
    How to use select list value in query of report? Or let me know how to use parameter in pl-sql report which is selected in other region?
    Thanks in advance

    I am attempting to define the variable as a date variable through Oracle BI and yes it does use a colon to signal variable substitution.
    So thank you the first way you stated should work.
    The only problem I'm running into now I believe steems from the date format that column that I am trying to filter on. It is in what appears to be the worst format possible.
    Is it common for dates to be stored in a DD-MON-YY format? (e.g. 01-JAN-08) I thought we as a community had moved past that post Y2K scare. lol.
    When I set up the bind variable in BI it allows me to define the date format, much similar to the TO_DATE function but then it says (must be java date format). So I'm thinking that maybe DD-MON-YY is not a java date format.
    In that case is there a way to cast or convert my date format in the sql so that it is a supported java date format?
    Or should I just give up and pass it as a varchar2?

  • Problem of POP LOV  in a  SQL Report  with pagination

    I am using a pop up lov (along with some other fields), HTMLDB_ITEM.POPUP_FROM_LOV(5, null, 'EMPLOYEE_LIST', '20', '50')), in a sql report. This is a report with pagination. Whenever I select any value from pop up lov on first page of the report it gets populated properly in the corresponding text field. But from second page onwards it doesn’t populate any value.
    For example, my report fetches a total of 50 rows, of which I am displaying 15 at a time. The popup lov comes with a text field for each row. Whenever I do select from popup lov for 1-15 rows which come on page 1, the values come up in the text field properly, but for rows 16-30 on second page, 31-45 on third 46-50 on fourth the values do not get populated. When I changed the pagination settings to display 40 rows..the values were still coming properly on page 1(1-40 rows) and not on the next page. Any clues… how to resolve this problem?

    good find. this is a bug that has already been identified and will be corrected in the upcoming patch release for htmldb. a good work-around for now is to use the equivalent declarative options in the tool. so rather than coding your query like...
    select ename , HTMLDB_ITEM.POPUP_FROM_LOV(2, null, 'DEPARTMENT', '20', '50') as "department" from emp
    ...just code it like this...
    select ename , null as "department" from emp
    ...and then use the column attributes screen for your "department" column to indicate that you'd like that col to be rendered as a "Popup LOV (named LOV)" using your DEPARTMENT list of values.
    hope this helps,
    raj

  • In need help: Analytic Report with Group by

    Good morning,
    I am trying to create a report with subtotal and grand total, which of couse goes to the group by clause, with rollup, cube, grouping... etc. I'd like to use rollup, then some columns in the Select list have to be put into the Group By clause, which is not supposed to be. So I had to use one of SUM, AVG, MIN and MAX functions, to make those columns as *aggregated, which is wrong.
    Another alternative I tried is to use Cube and Grouping_id to be the filter. However, that is still very cumbentsome and error-prone, also the order of the display is absolutely out of control.
    I am trying hard to stick to the first option of using the Rollup, since the result is very close to what I want, but avoid the usage of aggregation functions. For example, if I want to display column A, which should not be grouped. Other than using those aggregation functions, what I can do?
    Thanks in advance.

    Luc,
    this is a simple and a good reference for analytic functions:
    http://www.orafaq.com/node/55
    It takes some time to understand how they work and also it takes some time to understand how to utilize them. I have solved some issues in reporting using them, avoiding the overkill of aggregates.
    Denes Kubicek

  • Profit center wise customer balance Report with reference field

    Dear Experts
    I am using the report S_AC0_52000887 - Receivables: Profit Center but it does not show with reference.
    how can i see this report with reference. (e.g. reference field at the time of posting document) In the background of this report called by report painter and we can see the characteristics are there. I am not able to add the reference field in the characteristics. Can someone please give some insights.
    Regards,
    Vishal

    Hi Vishal,
    Please use FAGLL03 give the customer recon a/c you can see all the customers with profit center wise report.
    Regards,
    Raman

  • Grand total (Report footer) issue in a Report with Group selection.

    Hi,
    The case is simple, i have to summrise the NetValue field of a  report at the Group level and at the Report level(Grand Total).
    I also use a Group selection filter (I have grouped my records by MaterialDesc) to keep the desired groups.
    As you already guessed, my group totals are fine but the grand totals(report footer) contain both filtered and non filtered group records. Is there any way to avoid this problem and get a Grand Total from the filtered group records?
    Thank you.

    You can not use standard summaries with Group Suppression you must use either Running Totals or variables.
    In Running Total  evaluate click theformual button and eneter reverse condition to your group suppression.
    If you can not do that then you must use a Var
    In group footer where total is currently correct place a formula like this and suppress it
    @eval
    whileprintingrecords;
    global numbervar RepTot;
    If ..whatever your suppression condition is not true... then reptot:= reptot + sum( valuefield, groupfield);
    In report footer
    @display
    whileprintingrecords;
    global numbervar RepTot;
    Ian

  • SQL Report with 1 updatable column - help urgent

    Hi,
    I have a SQL report. I am using collection to store value of selected record by link column.
    I have a updatable text item (NULL) in the column. I am able to store that value in the collection.
    Any clue?
    Code
    1. Creating a collection in parent page:
    apex_collection.create_or_truncate_collection
    (p_collection_name => 'ORDER');
    2. Query to populate item rows with option to key 'QTY' before pressing 'Add to Order' link.
    select
    itemcode,
    description,
    NULL AS qty,
    'Add to Order' add_to_order
    from itemtab
    3. Made 'QTY' to Text item -- to allow users to key value
    4. Created 'hidden & protected' items P1_ITEMCODE, P1_QTY
    5. Set values of itemcode, qty in add_to_order link
    6. Created a process to add values into collection:
    for x in (select * from itemtab where itemcode = :P1_ITEMCODE)
    loop
    apex_collection.add_member(p_collection_name => 'ORDER',
    p_c001 => x.ITEMCODE,
    p_c002 => x.DESCRIPTION,
    p_c003 => :P1_QTY
    end loop;
    7. Display value of itemcode, description, qty in report region
    select c001, c002, c003
    from apex_collections
    where collection_name = 'ORDER'
    Probem: The value of qty is not being stored in the collection and not appearing in the #7 report. itemcode and description values are fine.
    Thanks,
    Dip

    Dip,
    I'm guessing here as I can't see your application, I think your missing the page process to collect the data from your QTY field.
    I created a quick demo of what i think your trying to achieve on apex.oracle.com
    http://apex.oracle.com/pls/apex/f?p=19923:2
    I added this to the html expression on the report Field add to:
    <input type="button" onclick="doSubmit(#RANDOM_ID#)" value="Add To" />
    Then the page process to collect and set the page item:
    DECLARE
    l_qty number;
    BEGIN
    FOR i in 1..APEX_APPLICATION.G_F03.COUNT LOOP
    l_qty := nvl(APEX_APPLICATION.G_F03(i),0);
    IF l_qty > 0
    THEN
    :P2_QTY := l_qty;
    :P2_RANDOM_ID := :REQUEST;
    EXIT;
    END IF;
    END LOOP;
    END;
    Let me know if this helps
    Mark
    Don't forget to mark reply as helpful or correct as this may help others reading this thread in the future!
    Edited by: cptbutcher on Mar 25, 2010 10:40 PM

  • Use SSAS Tabular KPI in SSRS report with groups

    I have a SSAS tabular model that I have built KPIs in. I have tried several attempts to use the KPI in SSRS with multiple groups, but as you probably know when you aggregate the KPI it does not calculate correctly. How do you use SSAS KPIs with SSRS groups?
    Thanks in advance.

    Hi Micheal,
    According to your description, you want to use the KPI created in SSAS tabular for SSRS multiple groups. Right?
    In Analysis Services, when we create KPI, it works for each detail record. This KPI will not consider any aggregation value. So when you aggregate the KPI in SSRS, it can't return correct result. However, in Reporting Services, you can use Variable
    to define a "KPI" and apply condition with aggregation function(like sum, average) based on this "KPI" in Expression to return the correct result. Also you can use the Indicator in SSRS to achieve this requirement. Please refer to
    links below:
    Report and Group Variables Collections References (Report Builder and SSRS)
    Indicators (Report Builder and SSRS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou
    TechNet Community Support

  • SQL SELECT with GROUP BY: Retrieve records for a list of customers

    I need to write a SQL statement to retrieve a list of customers, which are in two tables of different natures, say T1 and T2.
    The customer is a FK in both tables. Both tables have a column which is the date of an order.
    INPUT:
    * list of customers, say '12345, 34567, 45678'
    OUTPUT
    * REF CURSOR to a recordset containing: {custID, startDate, endDate}
    Algorithm
    * For each customer, find the date of first order (from T1 and T2)
    * For that date, t0, startDate=t0-10 days; endDate := t0+15 days;
    I have a feeling some GROUP BY is involved to do the trick.
    Can it be done without any looping? I am just not experienced enough to solve this in an optimal way.
    Any help, please?
    Thank you.

    Hi,
    I'm not sure what your data is, or shat you want for output.
    If your tables can have many rows for the same customer_id, but your output should have only one row per customer_id, then it sounds like you do need to "GROUP BY custiomer_id".
    If the data is coming from two different tables, first do a UNION of those two tables in a sub-query (like union_data below), and then do a GROUP BY on the results of the sub-query.
    It will probably be more efficient if you GROUP BY in the sub-query, too.
    I believe you need something like this:
    WITH     union_data     AS
         SELECT       customer_id
         ,       MIN (order_date)     AS start_dt
         FROM       t1
         WHERE       customer_id     IN (12345, 34567, 45678)
         GROUP BY  customer_id
    UNION ALL
         SELECT       customer_id                    -- column names may be different from t1
         ,       MIN (order_date)     AS start_dt
         FROM       t2
         WHERE       customer_id     IN (12345, 34567, 45678)
         GROUP BY  customer_id
    SELECT       customer_id
    ,       MIN (start_date)      AS start_date
    ,       MIN (start_date) - 10      AS t0
    ,       MIN (start_date) + 5      AS end_date
    FROM       union_data
    GROUP BY  customer_id;If you need help, post a little sample data (CREATE TABLE and INSERT statements for both tables, relevant columns only), and the results you want to get from that data.

  • SQL Report with Total Salary

    I have a select statement like this:
    Select first_name, last_name, salary From Employee
    I am getting report properly with this query. But my question is : How can get total salary at the bottom of report?
    If I crate another region with a new SQL, I could do that but I want in single SQL or PL/SQL.
    Any help would be appreciated.
    Thanks,
    Mushtak

    Hi, you can do something like this:
    Select first_name, last_name, salary From Employee
    Union
    Select null first_name, 'Total salary' last_name, Sum(salary) From Employee
    order by first_name
    Hope this helps
    George

Maybe you are looking for

  • Error: "One of the USB devices attached to this computer has malfunctioned"

    I have been trying to troubleshoot this on my own for awhile. I am currently using a 20GB iPod that has a touch screen and uses a dock. The unusual thing about my problem is that my original iPod's battery eventually wore out and, since it was out of

  • My boot drive space constantly decreases until reboot

    So the longer I leave my imac on, running 10.7.4, the slower and slower it gets, and the more spinning beach balls I get. At the same time, there becomes less and less free space on my boot drive. I mean over the course of 2 days it can drop from 77G

  • Ff 3.6.12 and 4.0 beta6 both hang when I type Tools, Option

    when I select tools, options, nothing happens, no window opens. After a short time (Not Responding) appears in the top menu bar I also get an alert when I try to restart FF The operation can not be completed because of an internal failure. A secure n

  • Deleting photos from iPod Touch

    I have been reading the posts on this and find that by checking off only the albums and not syncing my iPod Photo folder, I've managed to get rid of a lot of the excess photos I've been plagued with.  But I still have an album containing photos calle

  • 2 iPads previously using same Appleid.

    I have 2 iPads, and was using the same appleid on both. I just created a new iTunes account, but want to erase the old content from 1 iPad. If I erase the iPad and content will it delete the content from both? When I went to reset the content and set