Execute a query for each value returned by subquery

Hy, I have a query and a subquery(both of them are selects) and I want the outer query to be executed for each value returned by the subquery but the outer query has to return only one result.
For example, the following query is right for what I want?:
the following query finds out which authors live in the same city by looking at the postal code:
select au_fname, au_lname, city
from authors
where city = all
(select city
from authors
where postalcode like "946%")
I undertand the sentence "select au_fname, au_lname, city from authors where city=" will be executed for each value returned by "select city from authors where postalcode like "946%"". Is this right?
Thanks

Hi,
user13162080 wrote:
Hy, I have a query and a subquery(both of them are selects) and I want the outer query to be executed for each value returned by the subquery but the outer query has to return only one result. Sorry, I don't understand what you want. What if several rows in the table meet all the criteria? Do you only want some kind of summary of all of them?
Whenever you have a question, post a little sample data (CREATE TABLE and INSERT statements), and the results you want from that data.
For example, the following query is right for what I want?:
the following query finds out which authors live in the same city by looking at the postal code:
select au_fname, au_lname, city
from authors
where city = all
(select city
from authors
where postalcode like "946%")As I said earlier, I don't know what you want , but whatever it is, the query above is probably not the right way to get it.
Perhaps you meant "IN" instead of "= ALL", like this:
SELECT  au_fname, au_lname, city
FROM      authors
WHERE      city     IN          -- ***NOT***  = all
          (   SELECT  city
              FROM    authors
              WHERE   postalcode LIKE "946%"
I undertand the sentence "select au_fname, au_lname, city from authors where city=" will be executed for each value returned by "select city from authors where postalcode like "946%"". Is this right?No; the main query will be executed once, and the sub-query will be executed once. The rows in the main query will be compared to the results of the sub-query, to see if they will be included in the result set or not. This goes both for the original query you posted, and the modified version I posted.
InoL wrote:
Maybe I don't understand exactly what you want, or you gave a bad example. But your example is simply:
select au_fname, au_lname, city
from authors
where postalcode like '946%'
No; consider this data:
INSERT INTO authors (au_lname, city, postalcode) VALUES ('Virgil',     'Oakland',     '94601');
INSERT INTO authors (au_lname, city, postalcode) VALUES ('Steinbeck',     'Oakland',     NULL);
INSERT INTO authors (au_lname, city, postalcode) VALUES ('Grass',     'Emeryville',     '94608');What OP posted would return no rows, because nobody is in both 'Oakland' and 'Emeryville'.
What you posted would return 'Virgil' and 'Grass'.
What I posted would reutn all 3 rows, including Steinbeck, whose city is known to be related to a '946%' postalcode, even though his own postalcode is missing.
Edited by: Frank Kulash on Feb 9, 2011 1:06 PM

Similar Messages

  • Splitting and executing the query for each 1 lac and executing parallel.

    Hi All,
    We have a table with around 10 keys and each key is having more than millions of records for a given date.
    And my requirement is to find the sum of the sale_price of each keys.
    ( example :
    Select key, sum(sale_price) from table1 where date1=sysdate
    group by key
    Since, each set of key contains more than a millions of records, It's time consumption is too high.
    Is thr any way to achieve as below,
    For key 1 (assume 1 million records)
    and we will spilt these into 100 parts and execute parallelly.
    At the end get sum of all 100 parts.
    Similarly for other keys....
    Is it possible to divide the records into 1 lac each and give it for parallel execution ?

    If the key column is also the partition key, I would expect that to work well with parallel query. What have you tried that isn't working? Also what is your Oracle version?

  • Issue While executing the Query for Pagination using ROWNUM with like

    Issue While executing the Query for Pagination using ROWNUM with like.
    Database is Oracle11G.
    Oracle Database Table contains 8-9 lakh records
    1) SQL equal (=)
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE A.REFERENCE = 'KMF22600920'
    Execution Time:- 0.00869245 seconds
    Returns 2 resultsets
    2) SQL like (one %)
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE A.REFERENCE = 'KMF22600920%'
    Execution Time:- 0.01094301 seconds
    Returns 2 resultsets
    3) SQL like (two%)
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE A.REFERENCE like '%KMF22600920%'
    Execution Time:- 6.43989658 seconds
    Returns 2 resultsets
    In Pagination, we are using Modified version of SQL Query 3) with ROWNUM as mentioned below :-
    4) SELECT * FROM (
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE REFERENCE like '%KMF22600920%' AND ROWNUM <= 20 ) WHERE RNUM > 0
    Execution Time:- Infinite
    ResultSets:- No as execution time is infinite
    a) Instead of like if we use = in the above query it is returning the 2 resultsets (execution time 0.02699282 seconds)
    b) Instead of two % in the above query, if use one example REFERENCE like 'KMF22600920%' it is returning the 2 resultsets (execution time 0.03313019 seconds)
    Issue:- When using two % in like in the above query i.e. REFERENCE like '%KMF22600920%' AND ROWNUM <= 20 ) , it is going to infinite.
    Could you please let us know what is the issue with two % used in like and rownum
    5) Modified version of Option1 query (move out the RNUM condition AND RNUM <= 20)
    SELECT * FROM (
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE REFERENCE like '%KMF22600920%' ) WHERE RNUM > 0 AND RNUM <= 20
    Execution Time:- 7.41368914 seconds
    Returns 2 resultsets
    Is the above query is best optimized query which should be used for the Pagination or still can improve on this ?

    This would be easier to diagnose if there was an explain plan posted for the 'good' and 'bad' queries. Generally speaking using '%' on both sides precludes the use of any indexes.

  • Calling a stored procedure for each row returned

    I need to call a stored procedure for each row returned by a repeating frame. I called the stored procedure from the repeating frame format trigger, but that did not work( it did no populated the tables populated by the stored procedure)
    How can I call a stored procedure for each row returned by a repeating frame.
    Thank you

    Include it as a formula column in your data model.

  • Export a report but one PDF for each value of characterisc

    Hi gurus!
    I have a big problem, and dont know how can solve
    Info to SAP    
    I have read this note, 1069368., and not solve my problem, the client wants to
    export the report per city, therefore how can we do it? one page per
    city, it is not sense to create 1000 report for it and not efficient...
    Do you know how we can do?
    For example, I want to see all sales per shop, however I need to send
    this information to many people, but one shop report per client,
    therefore I need one pdf per shop or one page pdf (like document) per
    shop separatly one shop per page.

    Hi,
    You can't drill down according to a characteristic and send it as each report for each values of characteristic using Web Template as far as I know.
    You have such provision in BEx Analyzer - "Add Drill down according to Characteristic in New Worksheets"
    This will give a data for each characteristic value in each worksheet.
    Eg:If you have a Characteristic "City" and drill down in New worksheet,then the data will be shown for each city in each worksheet.
    Insert a Analysis grid and Navigation pane,assign a Data Provider and then right click on the Characteristic in Navigation Pane-> You will get an option "Add Drill down according to City in New Worksheets".
    Then you can broadcast this workbook through Email to intended receipients.
    Rgds,
    Murali

  • Comma separated column into rows for each value

    experts,
    I have a two column table. The second column has comma separated string values. How can I put the values separate for each comma separated and make one row for each value?
    example,
    column1 |   StringColumn
    s1          |   test, joy, happy
    s2          |  USA, England, India
    I want the result to be like below
    column1   |     StringColumn
    s1            |      test
    s1            |      joy
    s1            |      happy
    s2            |     USA
    s2            |     England
    s2            |     India
    thanks in advance
    ebro

    Hello ebro,
    See the following for a possible solution:
    http://gallery.technet.microsoft.com/scriptcenter/Convert-Small-CSV-Value-to-ffc142ff
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • SQL Query for take values on excle sheet

     i have the query `select EmpId,AttenDate,status from dbo.Attendance`
    it will give me this
    1500011 2014-09-01 00:00:00.000
    A
    1500011 2014-09-02 00:00:00.000
    A
    1500011 2014-09-03 00:00:00.000
    A
    1500011 2014-09-04 00:00:00.000
    A
    1500011 2014-09-05 00:00:00.000
    A
    1500011 2014-09-06 00:00:00.000
    P
    1500011 2014-09-07 00:00:00.000
    A
    upto   2014-09-31  00:00:00.000
    A
    68 2014-08-01 00:00:00.000
    A
    68 2014-08-02 00:00:00.000
    P
    68 2014-08-03 00:00:00.000
    A
    68  2014-09-07 00:00:00.000 A
    upto   2014-09-31  00:00:00.000
    A
    Now i want to print it into the excel sheet 
    with is format
    Empid 1
    2 3
    4 5
    6 7
    8 upto 31
    1500011 A   A A
    A A
    P A 
    A upto A
    68     A
    A P
    ....................upto A
    Please suggest me??

     
    Hi SachinDholess,
    Based on my understanding, you want to merge the attendance records for each EmpID into one row as below snapshot rather than in rows, right?
    According to your description, I created and populate the attendance records of September for EmpID
    1500011 and records of August and September for EmpID 68
    to simulate your scenario. In this scenario, the Stored Procedure
    procGetEmpAtt would help you to get the data like above snapshot during a given period. Please see the below code.
    USE TestDB;
    IF OBJECT_ID('dbo.Attendance') IS NOT NULL
    DROP TABLE dbo.Attendance;
    GO
    CREATE TABLE Attendance
    EmpID INT,
    AttenDate DATETIME,
    [status] VARCHAR(99)
    GO
    --Create and Populate the Nums Auxiliary Table
    SET NOCOUNT ON;
    SET ROWCOUNT 0;
    IF OBJECT_ID('dbo.Nums', 'U') IS NOT NULL
    DROP TABLE dbo.Nums;
    CREATE TABLE dbo.Nums(n INT NOT NULL PRIMARY KEY);
    DECLARE @max AS INT, @rc AS INT;
    SET @max = 1000;
    SET @rc = 1;
    INSERT INTO dbo.Nums(n) VALUES(1);
    WHILE @rc * 2 <= @max
    BEGIN
    INSERT INTO dbo.Nums(n) SELECT n + @rc FROM dbo.Nums;
    SET @rc = @rc * 2;
    END
    INSERT INTO dbo.Nums(n)
    SELECT n + @rc FROM dbo.Nums WHERE n + @rc <= @max;
    GO
    --Insert records of September for EmpID 1500011
    INSERT INTO Attendance VALUES(1500011,'2014-09-01 00:00:00.000', 'A');
    INSERT INTO Attendance
    SELECT EmpID, DATEADD(DAY,n,AttenDate), [status] FROM Attendance join nums ON nums.n<30
    WHERE EMPID=1500011;
    --Insert records of September and August for EmpID 68
    INSERT INTO Attendance VALUES(68,'2014-08-01 00:00:00.000', 'A');
    INSERT INTO Attendance
    SELECT EmpID, DATEADD(DAY,n,AttenDate), [status] FROM Attendance join nums ON nums.n<61
    WHERE EMPID=68;
    DROP TABLE dbo.Nums;
    IF (OBJECT_ID('procGetEmpAtt', 'P') IS NOT NULL)
    DROP PROC procGetEmpAtt
    GO
    CREATE PROC procGetEmpAtt(@startDT DATETIME, @endDT DATETIME)
    AS
    DECLARE @DynamicPivotQuery AS NVARCHAR(MAX);
    DECLARE @ColumnName AS NVARCHAR(MAX);
    DECLARE @Columns AS NVARCHAR(MAX);
    --Get distinct values of the PIVOT Column
    SELECT @ColumnName= ISNULL(@ColumnName + ',','')+ 'ISNULL('+QUOTENAME(dt)+',''Not Recored'') AS '+QUOTENAME(dt),
    @Columns=ISNULL(@Columns + ',','')+QUOTENAME(dt)
    FROM (SELECT DISTINCT CONVERT(varchar(12) , AttenDate, 112 ) as dt FROM Attendance WHERE AttenDate BETWEEN @startDT AND @endDT ) AS A ;
    --Prepare the dynamic PIVOT query
    SET @DynamicPivotQuery =
    N'SELECT EmpID, ' + @ColumnName + '
    FROM Attendance
    PIVOT(MAX([status])
    FOR AttenDate IN (' + @Columns + ')) AS PVTTable ORDER BY EmpID DESC' ;
    --Execute the dynamic Pivot Query
    EXEC sp_executesql @DynamicPivotQuery ;
    GO
    Test example
    SET NOCOUNT ON;
    SET ROWCOUNT 0;
    EXEC procGetEmpAtt
    @startDT='2014-08-29',
    @endDT='2014-09-15'
    The key in this  Stored Procedure is the dynamic Pivot statement, click
    here for more details.
    By the way, I didn’t quite get your point until I copied your description into a Word document. Kindly mind the format of the description you post, a better  formatted one would lead to a much quicker response.
    If you have any question, feel free to let me know.
    Best Regards,
    Eric Zhang

  • Utl file - I need to get new line for each value

    I wrote an utl_file package to generate an html file. It is working fine, however, I am having difficulty formating my output.
    I like to have values returned one line at a time. For instance,
    Name:Sam Ok
    area code: 407
    phone: 333-4444
    picture: display here.
    It is displaying values on one line.
    Please help if you can. Here is the code.
    Thanks,
    sam
    CREATE OR REPLACE PROCEDURE Cr_Movie_PRV_HTML(
    P_Filename IN varchar2,
    p_Id IN mist_physician.mp_phys_Id%TYPE
    AS
    CURSOR C_mist IS
    SELECT mp_name,
    mp_update_datetime,
    mp_area_code,
    mp_phone,
    mp_address,
    mp_fax
    FROM Mist_Physician
    WHERE Mp_phys_id = P_Id;
    v_mp_name mist_physician.mp_name%type;
    v_mp_update_datetime mist_physician.mp_update_datetime%type;
    v_mp_areacode mist_physician.mp_area_code%type;
    v_phone mist_physician.mp_phone%type;
    v_mp_address mist_physician.mp_address%type;
    v_mp_fax mist_physician.mp_fax%type;
    V_FileHandle UTL_FILE.FILE_TYPE; -- This will be used to store the filename
    BEGIN
    --Open The specified file to write into and get V_FileHandle.
    V_FileHandle := UTL_FILE.FOPEN('c:\mist_info', P_FileName, 'w');
    IF Utl_File.IS_OPEN(V_FileHandle) = FALSE THEN
    RAISE_APPLICATION_ERROR(-20000,'Error opening '||P_FileName||' for WRITE');
    END IF;
    Let's build the header file that will be inside the file that will  identify why thus file is created.
    utl_file.put_line(V_FileHandle,'#---------------------------------------');
    utl_file.put_line(V_FileHandle,'Name'||' : '||mist_Rec.mp_name);
    utl_file.put_line(V_FileHandle,'Date');
    utl_file.put_line(V_FileHandle,'Phone');
    utl_file.put_line(V_FileHandle,'Address');
    utl_file.put_line(V_FileHandle,'# Generated on: '||to_char(sysdate, 'Mon DD, YYYY (Dy) HH:MI:SS AM'));
    utl_file.put_line(V_FileHandle,'#-----------------------------------------');
    utl_file.put_line(V_FileHandle,' ');
    -- Next we will query data from the Movie table. Only data that are relevant.
    -- Using PUT_LINE, write text with the field arguments out to the file
    BEGIN
    FOR Mist_Rec IN C_Mist LOOP
    UTL_FILE.PUT_LINE(V_FileHandle,'Name'||':'||Mist_Rec.Mp_Name||','||'<img src=c:/our_website/co16.jpeg>');
    END LOOP;
    SELECT mp_name,
    mp_update_datetime,
    mp_area_code,
    mp_phone,
    mp_address,
    mp_fax
    INTO v_mp_name,
    v_mp_update_datetime,
    v_mp_areacode,
    v_phone,
    v_mp_address,
    v_mp_fax
    FROM Mist_Physician
    WHERE Mp_phys_id = P_Id;
    END;
    -- Now Close the file
    UTL_FILE.FCLOSE( V_FileHandle);
    EXCEPTION
    WHEN Utl_File.Invalid_Path THEN
    RAISE_APPLICATION_ERROR(-20001,'Error: Invalid Path');
    WHEN Utl_File.Invalid_Operation THEN
    RAISE_APPLICATION_ERROR(-20002,'Error: Invalid File Operation');
    IF Utl_File.IS_OPEN(V_FileHandle) = TRUE THEN
    Utl_File.FCLOSE(V_FileHandle);
    END IF;
    WHEN Utl_File.Invalid_Mode THEN
    RAISE_APPLICATION_ERROR(-20003,'Error: Invalid Mode');
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('ERROR: ' || SQLCODE || '-'||SQLERRM);
    END Cr_Movie_PRV_HTML;
    /**********************End Of Mist*********************/

    Syntax is::
    UTL_FILE.NEW_LINE(filename, nuber-of-lines)
    CREATE OR REPLACE PROCEDURE Cr_Movie_PRV_HTML(
    P_Filename IN varchar2,
    p_Id IN mist_physician.mp_phys_Id%TYPE
    AS
    CURSOR C_mist IS
    SELECT mp_name,
    mp_update_datetime,
    mp_area_code,
    mp_phone,
    mp_address,
    mp_fax
    FROM Mist_Physician
    WHERE Mp_phys_id = P_Id;
    v_mp_name mist_physician.mp_name%type;
    v_mp_update_datetime mist_physician.mp_update_datetime%type;
    v_mp_areacode mist_physician.mp_area_code%type;
    v_phone mist_physician.mp_phone%type;
    v_mp_address mist_physician.mp_address%type;
    v_mp_fax mist_physician.mp_fax%type;
    V_FileHandle UTL_FILE.FILE_TYPE; -- This will be used to store the filename
    BEGIN
    --Open The specified file to write into and get V_FileHandle.
    V_FileHandle := UTL_FILE.FOPEN('c:\mist_info', P_FileName, 'w');
    IF Utl_File.IS_OPEN(V_FileHandle) = FALSE THEN
    RAISE_APPLICATION_ERROR(-20000,'Error opening '||P_FileName||' for WRITE');
    END IF;
    utl_file.put_line(V_FileHandle,' ');
    -- Next we will query data from the Movie table. Only data that are relevant.
    -- Using PUT_LINE, write text with the field arguments out to the file
    BEGIN
    FOR Mist_Rec IN C_Mist LOOP
    --Let's build the header file that will be inside the file that will
    --identify why thus file is created.
    UTL_FILE.PUTF
    (file_handle, %s,'--------------------------');
    UTL_FILE.NEW_LINE(V_FileHandle, 1)
    UTL_FILE.PUTF (file_handle, '%s','Name'||':'||Mist_Rec.Mp_Name, )
    UTL_FILE.NEW_LINE(V_FileHandle, 1)
    .(Chang the below all u will get as u required)
    'Date'||' : '||Mist_Rec.mp_update_datetime,
    'Area Code'||' : '||Mist_Rec.mp_area_code,
    'Phone'||' : '||Mist_Rec.mp_phone,
    'Address'||' : '||Mist_Rec.mp_address,
    'Fax'||' : '||Mist_Rec.mp_fax,
    '# Generated on: '||to_char(sysdate, 'Mon DD,
    YYYY (Dy) HH:MI:SS AM')),
    '<img src=c:/our_website/co16.jpeg>'),
    -- UTL_FILE.PUT_LINE(V_FileHandle,'Name'||':'||Mist_Rec.Mp_Name||','||'<img
    --src=c:/our_website/co16.jpeg>');
    END LOOP;
    SELECT mp_name,
    mp_update_datetime,
    mp_area_code,
    mp_phone,
    mp_address,
    mp_fax
    INTO v_mp_name,
    v_mp_update_datetime,
    v_mp_areacode,
    v_phone,
    v_mp_address,
    v_mp_fax
    FROM Mist_Physician
    WHERE Mp_phys_id = P_Id;
    END;
    -- Now Close the file
    UTL_FILE.FCLOSE( V_FileHandle);
    EXCEPTION
    WHEN Utl_File.Invalid_Path THEN
    RAISE_APPLICATION_ERROR(-20001,'Error: Invalid Path');
    WHEN Utl_File.Invalid_Operation THEN
    RAISE_APPLICATION_ERROR(-20002,'Error: Invalid File Operation');
    IF Utl_File.IS_OPEN(V_FileHandle) = TRUE THEN
    Utl_File.FCLOSE(V_FileHandle);
    END IF;
    WHEN Utl_File.Invalid_Mode THEN
    RAISE_APPLICATION_ERROR(-20003,'Error: Invalid Mode');
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('ERROR: ' || SQLCODE || '-'||SQLERRM);
    END Cr_Movie_PRV_HTML;
    /**********************End Of Mist*********************/

  • Query for a Value Set

    Is there any way to get one record for each of orgs? I would like to use this query in a value set but I can put the word distinct in a value set SQL statement. Any Ideas?
    SELECT
    haou.NAME ORGANIZATION_NAME
    FROM
    hr.per_all_assignments_f paaf,
    hr_all_organization_units haou
    WHERE haou.Organization_id = paaf.Organization_id
    AND paaf.primary_flag = 'Y'
    AND paaf.assignment_type = 'E'
    AND sysdate BETWEEN paaf.effective_start_date AND paaf.effective_end_date
    order by 1

    Found it...
    select name from hr_all_organization_units b
    where organization_id in (select organization_id from per_all_assignments_f a
    where a.organization_id = b.organization_id )
    order by 1

  • Dynamic Pie Chart: Counting the number of instances for each value

    Hello my name is Tim and I am at a roadblock concerning a chart for a dashboard design.
    I have a list with two fields:
    Platform and Status. The list is customized in InfoPath. The
    Platform field is located on the form as a drop-down menu with 6 entries.
    Status is a choice field with 3 selection that is updated through the lifespan of the project (once item created, it is updated to "In process", once the project is closed, the field is updated to "closed."
    My hurdle is viewing these dynamically in a Pie Chart. I am  trying to display the number of project's "In process" for each Platform. So, if Platform A has 6 projects "In process" and Platform B has 3 projects "In process"
    how can this be displayed in a pie chart?
    At the moment, I figured there are two options: Chart View WebPart or importing an Excel  worksheet.
    Any ideas or solution on how to accomplish this?
    -Tim Dempsey

    Three options:
    1. Create a list that holds your statuses. Then in your original list, create a lookup to the status list. In your status list, make a lookup to the lookup. This creates a circular reference which, for whatever reason, returns a count. You can then connect
    a chart web part to this. Repeat for the other column.
    2. Go to your sharepoint list and export to spreadsheet. Save the file. This is a query file that you can use as a data connection. From that file, set it to auto-update and then create a chart from a pivot table. Then use Excel Services Web Part to display
    the file.
    3. The other option is to use Google Charts API. Connect to the list, run some jQuery and JavaScript and then export out a chart. Pretty cool tool.
    Andy Wessendorf SharePoint Developer II | Rackspace [email protected]

  • Tab Canvas : 1 data block 2 different query for each tab) Forms 10g

    Hello allllll,
    I have 2 blocks Master datail ,the master is non-db the tab canvas is for one data block:
    Problem 1: How 2 display same data block in each tab.?
    Problem 2: How when pressing excute Query button each tab display the data
    ----------------------specified by the Master block..?
    Regards,
    Abdetu..

    -- When-New-Form-instance
    IF :SYSTEM.Record_Status ='query' THEN
    go_block('PLN_STOCK_TAKING_HEADER');
    execute_query;
    go_block('PLN_STOCK_TAKING_DETAIL');
    execute_query;
    go_block('PLN_STOCK_TAKING_DETAIL2');
    execute_query;
    END IF;
    same behaviour,excute on tab2 not tab1,well i think it has something to do with the relation..!
    Regards,
    Abdetu..

  • Using an IF Statement in Numbers on Entire Column for Each Value that is True

    Hi,
    I am trying to create a formula to help calculate a chart chart.
    I need to gather the SUM of Column A for Each instance that Column B of the same row is =TRUE. I need to do it in the most general way possible as this formula will be gathering information from multiple tables and creating a sum.
    For Instance:
    TABLE 1
    Column A
    Column B
    5
    True
    3
    False
    4
    True
    1
    False
    TABLE 2
    Column A
    Column B
    5
    True
    3
    False
    4
    True
    1
    False
    The result I am looking for would be 18.
    Thanks for any input.

    JE,
    Here's an expression that you could use:
    =SUM(SUMIF(Table 1 :: B:B, TRUE, Table 1 :: A:A), SUMIF(Table 2 :: B:B, TRUE, Table 2 :: A:A), and so forth for additional tables)
    Jerry

  • Generate Report for each value of a certain column in a different pdf file

    Hi,
    I am generating a Group Above report in Oracle Reports Builder 10g.
    The scenario is that this report needs to be generated for several branches of a bank. The report needs to get generated in a different pdf file for each branch.
    The report, I have built, has a repeating frame based on the Branch group and all other reqd data are organised into repeating frames within this master frame.
    Currently the report is getting generated for all branches with the correct data but in the same pdf file.
    Please help.

    Hello,
    http://download-uk.oracle.com/docs/cd/B14099_17/bi.1012/b13895/orbr_dist.htm
    37 Bursting and Distributing a Report
    Oracle Reports enables you to deliver a single report to multiple destinations simultaneously. By taking advantage of this feature, you can create a single report, then send it in any format (for example, PDF or HTML) to multiple destinations.
    In this example, you will modify a simple report we have provided to burst each group to a separate report. You will then modify a sample distribution XML file to send an e-mail to each destination with an attachment based on the separate reports. You will also send multiple e-mails to the same e-mail address with a single attachment (the entire report).
    Regards

  • How to execute the query for a block based on the parameter

    Hi All,
    Good evening.
    i have requirement where i need to display the data in one block based on the selected items.
    the scenario is like this...there are 2 LOV's and one apply button and one external region on the form.
    so when u select the lov values and click on apply button the query should execute based on this 2 lov values.
    i am not getting how to achieve this..i am very new to oracle forms..
    Please Help..
    Thanks
    Bharat
    please help..it is urgent..
    thanks
    bharat
    Edited by: Bharat on Jan 31, 2012 5:19 AM

    Bharat wrote:
    Hi All,
    Good evening.
    i have requirement where i need to display the data in one block based on the selected items.
    the scenario is like this...there are 2 LOV's and one apply button and one external region on the form.
    so when u select the lov values and click on apply button the query should execute based on this 2 lov values.
    i am not getting how to achieve this..i am very new to oracle forms..Another way you can do this. Create a lov and don't assign it to any column just one return item (should be id).
    Now create a button may be your "apply button" write two trigger when-button-press and when-mouse-click.
    at When -Button-Press trigger, change the block state to 'ENTER-QUERY' and at when-mouse-click show the LOV and then write execute_query.
    Hope this will help you.
    If someone's response is helpful or correct, please mark it accordingly.

  • Need to execute Dynamic query for the report

    I was wondering if we can have the option of choosing at runtime from the report builder parameter so that if the end-user selects 'Yes' then the report will run one specific query and if he chooses 'No' then another particular query is invoked. What I mean to say that by choosing between Yes and No at runtime one should have the option of returning query results based on the same table but having different columns selected via the SELECT statement
    means we have two querires on our report & upon the chosen parameter we should execute only one of them ... wht should i do to apply tht ???

    As the previous post noted lexicals are a terrific way to accomplish dynamic queries in Oracle reports.
    Another way you could accomplish this would be to use a UNION, whereas the first select in the UNION represents one user option, then second query represents the second option.
    For example:
    SELECT customer_name name, customer_address address
    FROM customer_table
    WHERE :p_choice = 'Customer Info'
    UNION
    SELECT employee_name name, employee_address address
    FROM employee_table
    WHERE :p_choice = 'Employee Info'If when running the report, the user chooses 'Customer Info' the first query would return results, if the user chose 'Employee Info' then just information from the second query would return information.
    So there are different ways to accomplish what you are looking for, you just need to find which is going to work best for you.
    Hope this helps!

Maybe you are looking for