CF Report Builder - multiple queries

I am a CF developer who has worked a fair bit with coding
reports manually. Have taken the plunge with report builder and
generally like what I see, BUT am quite disappointed with an
apparent lack of documentation or tutorials on complex reporting
techniques.
I need to do a report which ideally requires two queries, the
results of which the report's purpose is to compare.
The problem is, from what I can tell, a .CFR can only have
ONE query (which I find odd). Can anyone suggest a way of being
able to have more than one query result set passed into a .CFR.
I am starting to wonder that CF Report Builder might be great
for fairly basic, single data set reports, but no good for large
complex reports. I would be interested in hearing others opinions
on this.
Many Thanks in Advance.

Thanks tmschmitt. You are right in that I am (was) stuck on
passing in multiple queries. What I have managed to do is use the
Advanced option of the query builder to write my two seperate
queries, then combine them into one recordset by doing a Query on
the Queries. Not sure if this is the best way around it, but it
seems to be working fine. Problem now is that I need to manually
craete 500+ "Query Fields" (yuk).
I haven't really delved into the sub-reports yet, but have a
feeling they won't meet my current needs. Basically i have 253
columns of demographic data. I need one recordset (A) with this
data from one geographic location with a recordset from a different
location (B). I then need to lay out the data with each field from
B beside it's corresponding field from A. In short, it is a
comparitive report whereby the reader can compare a given value
(e.g. avg income) from one area with that from another. This would
be fairly straightforward in a scripted report, but with Report
Builder appears to be quite cumbersome and potentially unmanagable
as I need to handle each field explicitly (rather than looping over
recordsets and structures to generate the different sections of the
report).

Similar Messages

  • Report with Multiple queries too slow in BI Publisher 11g

    Hi, I have a report in 11g where i need to create multiple queries to show them in report. I tried to combine everything in one query, but i found that the query is too huge and hard to understand and maintain. I created 3 data sets and linked them together. In SQL dev, the main query is returning about 315 records and first detail query returns less than 100 records and second detail query is returning one record which is BLOB. Each query returns data within a couple of seconds from SQL Developer. The entire report from BI Publisher should be just 21 page PDF output. Did anyone face performance issues while running reports with multiple queries in 11g? I ran reports that have single query which returned 10K pages PDF and never had an issue while everthing is in one query. This is the first time Iam attempting to create multiple queries. Can someone help me understand what i might be doing wrong or missing here. Thank you.

    Isn't there a way for you to do this via a Package/Procedure versus having multiple queries?
    Per the BI Publisher guide,
    Following are recommended guidelines for building data models:
    Reduce the number of data sets or queries in your data model as much as possible. In general, the fewer data sets and queries you have, the faster your data model will run. While multiquery data models are often easier to understand, single-query data models tend to execute more quickly. It is important to understand that in parent-child queries, for every parent, the child query is executed.
    You should only use multiquery data models in the following scenarios:
    To perform functions that the query type, such as a SQL query, does not support directly.
    To support complex views (for example, distributed queries or GROUP BY queries).
    To simulate a view when you do not have or want to use a view.
    Thanks,
    Bipuser

  • Bursting a report with multiple queries

    Hi,
    I need to set-up bursting in BIP for a report with multiple queries. The output format is pdf and delivery is through e-mail. Since the queries need to be linked, I'm trying to do this using data template. I've set-up split and burst based on a field (store_id) from the first query which is used as a bind variable in the subsequent queries. So I'd ideally want the report to be split based on store_id. The report works fine if I use a parameter for store_id and view the output by store_id. When I try to schedule the report for bursting, it generates and e-mails the reports but only the last report appears to have correct data output while the others have only the output from the first query (and all other queries appear to return nothing in the report).
    Any suggestions on what could be the issue here? Thanks!
    Here is the data template for the report:
    <dataTemplate name="Report" description="Report" dataSourceRef="ReportDB">
    <dataQuery>
    <sqlStatement name="STORE_VENDOR">
    <![CDATA[SELECT STORE.STORE_ID Q1_STORE_ID, VENDOR.VENDOR_ID Q1_VENDOR_ID, VENDOR.VENDOR_DESC Q1_VENDOR_DESC, PERSON.NAME Q1_NAME
                   FROM STORE, SERVICE_TICKET, VENDOR, ROLE, ROLE_TYPE, PERSON, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
                   WHERE (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
                   AND (SERVICE_TICKET.SOURCE_ID = VENDOR.SOURCE_ID AND SERVICE_TICKET.VENDOR_ID = VENDOR.VENDOR_ID)
                   AND (STORE.SOURCE_ID = ROLE.SOURCE_ID AND STORE.STORE_ID = ROLE.STORE_ID)
                   AND (ROLE.SOURCE_ID = ROLE_TYPE.SOURCE_ID AND ROLE.ROLE_TYPE_ID = ROLE_TYPE.TYPE_ID AND ROLE_TYPE.TYPE_DESC = 'PIC')
                   AND (ROLE.SOURCE_ID = PERSON.SOURCE_ID AND ROLE.PERSON_ID = PERSON.PERSON_ID)
                   AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
                   AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
                   AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4'
                   GROUP BY STORE.STORE_ID, VENDOR.VENDOR_ID, VENDOR.VENDOR_DESC, PERSON.NAME
                   ORDER BY STORE.STORE_ID]]>
    </sqlStatement>
    <sqlStatement name="WO">
    <![CDATA[SELECT STORE.STORE_ID Q3_STORE_ID, 'Nightly Cleaning' Q3_NIGHTLY_CLEANING, 'Nightly Cleaning' Q3_DESCRIPTION, SERVICE_TICKET.TICKET_ID Q3_TICKET_ID, TO_CHAR(SERVICE_TICKET.END_DATE, 'MM/DD/YYYY') Q3_END_DATE, 'Excellent' Q3_QUALITY_RATING_1, 'Satisfactory' Q3_QUALITY_RATING_2, 'Unsatisfactory' Q3_QUALITY_RATING_3
                   FROM SERVICE_TICKET, STORE, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
                   WHERE (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
                   AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
                   AND STORE.STORE_ID = :Q1_STORE_ID
                   AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
                   AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4']]>
    </sqlStatement>
    <sqlStatement name="SERVC_TYPE_1">
    <![CDATA[SELECT STORE.STORE_ID Q4_STORE_ID, ZONE.ZONE_DESC Q4_ZONE_DESC, SERVICE_TICKET_LINE.SERVICE_COST Q4_SERVICE_COST, SERVICE_TICKET_LINE.TICKET_ID Q4_TICKET_ID, TO_CHAR(SERVICE_TICKET_LINE.WO_END_DATE, 'MM/DD/YYYY') Q4_WO_END_DATE, 'Excellent' Q4_QUALITY_RATING_1, 'Satisfactory' Q4_QUALITY_RATING_2, 'Unsatisfactory' Q4_QUALITY_RATING_3
                   FROM SERVICE_TICKET_LINE, SERVICE_TICKET, STORE, SERVICE_TYPE, ZONE, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
                   WHERE (SERVICE_TICKET.SOURCE_ID = SERVICE_TICKET_LINE.SOURCE_ID AND SERVICE_TICKET.TICKET_ID = SERVICE_TICKET_LINE.TICKET_ID)
                   AND (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
                   AND (SERVICE_TICKET_LINE.SOURCE_ID = SERVICE_TYPE.SOURCE_ID AND SERVICE_TICKET_LINE.SERVICE_TYPE_ID = SERVICE_TYPE.TYPE_ID)
                   AND (SERVICE_TICKET_LINE.SOURCE_ID = ZONE.SOURCE_ID AND SERVICE_TICKET_LINE.ZONE_ID = ZONE.ZONE_ID)
                   AND SERVICE_TYPE.TYPE_DESC = 'ABC'
                   AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
                   AND STORE.STORE_ID = :Q1_STORE_ID
                   AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
                   AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4'
                   ORDER BY SERVICE_TICKET_LINE.SOURCE_ID, SERVICE_TICKET_LINE.TICKET_ID, SERVICE_TICKET_LINE.LINE_ID]]>
    </sqlStatement>
    <sqlStatement name="SERVC_TYPE_2">
    <![CDATA[SELECT STORE.STORE_ID Q5_STORE_ID, ZONE.ZONE_DESC Q5_ZONE_DESC, SERVICE_TICKET_LINE.SERVICE_COST Q5_SERVICE_COST, SERVICE_TICKET_LINE.TICKET_ID Q5_TICKET_ID, TO_CHAR(SERVICE_TICKET_LINE.WO_END_DATE, 'MM/DD/YYYY') Q5_WO_END_DATE, 'Excellent' Q5_QUALITY_RATING_1, 'Satisfactory' Q5_QUALITY_RATING_2, 'Unsatisfactory' Q5_QUALITY_RATING_3
                   FROM SERVICE_TICKET_LINE, SERVICE_TICKET, STORE, SERVICE_TYPE, ZONE, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
                   WHERE (SERVICE_TICKET.SOURCE_ID = SERVICE_TICKET_LINE.SOURCE_ID AND SERVICE_TICKET.TICKET_ID = SERVICE_TICKET_LINE.TICKET_ID)
                   AND (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
                   AND (SERVICE_TICKET_LINE.SOURCE_ID = SERVICE_TYPE.SOURCE_ID AND SERVICE_TICKET_LINE.SERVICE_TYPE_ID = SERVICE_TYPE.TYPE_ID)
                   AND (SERVICE_TICKET_LINE.SOURCE_ID = ZONE.SOURCE_ID AND SERVICE_TICKET_LINE.ZONE_ID = ZONE.ZONE_ID)
                   AND SERVICE_TYPE.TYPE_DESC = 'XYZ'
                   AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
                   AND STORE.STORE_ID = :Q1_STORE_ID
                   AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
                   AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4'
                   ORDER BY SERVICE_TICKET_LINE.SOURCE_ID, SERVICE_TICKET_LINE.TICKET_ID, SERVICE_TICKET_LINE.LINE_ID]]>
    </sqlStatement>
    <sqlStatement name="SERVC_TYPE_3">
    <![CDATA[SELECT STORE.STORE_ID Q6_STORE_ID, ZONE.ZONE_DESC Q6_ZONE_DESC, 'Excellent' Q6_QUALITY_RATING_1, 'Satisfactory' Q6_QUALITY_RATING_2, 'Unsatisfactory' Q6_QUALITY_RATING_3, 'One' Q6_QTY_MISSING_1, 'Two' Q6_QTY_MISSING_2, '3 or More' Q6_QTY_MISSING_3
                   FROM SERVICE_TICKET_LINE, SERVICE_TICKET, STORE, SERVICE_TYPE, ZONE, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
                   WHERE (SERVICE_TICKET.SOURCE_ID = SERVICE_TICKET_LINE.SOURCE_ID AND SERVICE_TICKET.TICKET_ID = SERVICE_TICKET_LINE.TICKET_ID)
                   AND (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
                   AND (SERVICE_TICKET_LINE.SOURCE_ID = SERVICE_TYPE.SOURCE_ID AND SERVICE_TICKET_LINE.SERVICE_TYPE_ID = SERVICE_TYPE.TYPE_ID)
                   AND (SERVICE_TICKET_LINE.SOURCE_ID = ZONE.SOURCE_ID AND SERVICE_TICKET_LINE.ZONE_ID = ZONE.ZONE_ID)
                   AND SERVICE_TYPE.TYPE_DESC = 'PQR'
                   AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
                   AND STORE.STORE_ID = :Q1_STORE_ID
                   AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
                   AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4'
                   ORDER BY SERVICE_TYPE.TYPE_ID]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
         <group name="G_STORE_VENDOR" source="STORE_VENDOR">
              <element name="Q1_STORE_ID" value="Q1_STORE_ID"/>
              <element name="Q1_VENDOR_ID" value="Q1_VENDOR_ID"/>
              <element name="Q1_VENDOR_DESC" value="Q1_VENDOR_DESC"/>
              <element name="Q1_NAME" value="Q1_NAME"/>
         </group>     
         <group name="G_WO" source="WO">
              <element name="Q3_NIGHTLY_CLEANING" value="Q3_NIGHTLY_CLEANING"/>
              <element name="Q3_DESCRIPTION" value="Q3_DESCRIPTION"/>
              <element name="Q3_TICKET_ID" value="Q3_TICKET_ID"/>
              <element name="Q3_END_DATE" value="Q3_END_DATE"/>
              <element name="Q3_QUALITY_RATING_1" value="Q3_QUALITY_RATING_1"/>
              <element name="Q3_QUALITY_RATING_2" value="Q3_QUALITY_RATING_2"/>
              <element name="Q3_QUALITY_RATING_3" value="Q3_QUALITY_RATING_3"/>
         </group>     
         <group name="G_SERVC_TYPE_1" source="SERVC_TYPE_1">
              <element name="Q4_ZONE_DESC" value="Q4_ZONE_DESC"/>
              <element name="Q4_SERVICE_COST" value="Q4_SERVICE_COST"/>
              <element name="Q4_TICKET_ID" value="Q4_TICKET_ID"/>
              <element name="Q4_WO_END_DATE" value="Q4_WO_END_DATE"/>
              <element name="Q4_QUALITY_RATING_1" value="Q4_QUALITY_RATING_1"/>
              <element name="Q4_QUALITY_RATING_2" value="Q4_QUALITY_RATING_2"/>
              <element name="Q4_QUALITY_RATING_3" value="Q4_QUALITY_RATING_3"/>
         </group>     
         <group name="G_SERVC_TYPE_2" source="SERVC_TYPE_2">
              <element name="Q5_ZONE_DESC" value="Q5_ZONE_DESC"/>
              <element name="Q5_SERVICE_COST" value="Q5_SERVICE_COST"/>
              <element name="Q5_TICKET_ID" value="Q5_TICKET_ID"/>
              <element name="Q5_WO_END_DATE" value="Q5_WO_END_DATE"/>
              <element name="Q5_QUALITY_RATING_1" value="Q5_QUALITY_RATING_1"/>
              <element name="Q5_QUALITY_RATING_2" value="Q5_QUALITY_RATING_2"/>
              <element name="Q5_QUALITY_RATING_3" value="Q5_QUALITY_RATING_3"/>
         </group>     
         <group name="G_SERVC_TYPE_3" source="SERVC_TYPE_3">
              <element name="Q6_ZONE_DESC" value="Q6_ZONE_DESC"/>
              <element name="Q6_QUALITY_RATING_1" value="Q6_QUALITY_RATING_1"/>
              <element name="Q6_QUALITY_RATING_2" value="Q6_QUALITY_RATING_2"/>
              <element name="Q6_QUALITY_RATING_3" value="Q6_QUALITY_RATING_3"/>
              <element name="Q6_QTY_MISSING_1" value="Q6_QTY_MISSING_1"/>
              <element name="Q6_QTY_MISSING_2" value="Q6_QTY_MISSING_2"/>
              <element name="Q6_QTY_MISSING_3" value="Q6_QTY_MISSING_3"/>
         </group>
    </dataStructure>
    </dataTemplate>

    Hello user6428199,
    When you use ":Q1_STORE_ID" in your queries, BI Publisher looks for a report parameter named Q1_STORE_ID. Change all your report queries to get data for all the store_id's available. As you are bursting the report using the store_id as the bursting key, BI Publisher will split the report based on the stored_id and delivers content based on it. No matter how many queries you may have, BI Publisher will loop through all the store_id's available and all the queries will return data for that particular id in a report.
    Thanks,
    Machaan

  • Single report with multiple queries OR multiple reports with single query

    Hello Experts,
    I have a confusion regarding Live Office connection for many days. I asked many people but did not get a concrete answer. I am re-posting this question here and expecting an answer this time.
    The product versions that I am using are as follows:
    FrontEnd:
      BOE XI 3.1 SP4 FP 4.1
      Xcelsius Enterprise 2008 SP4
    Backend:
      SAP BW 7.0 EHP1
    I have created a dashboard which is getting data from a webi report using LO connections.
    The webi report has five report parts which are populated by five different queries.
    Now my question is, when the five LO connections are refreshed, is the webi report refreshed five times or just once?
    If the report is refreshed five times, then I guess it is better to have five different webi reports containing single report part, because in that way we can prevent same query being executed multiple times.
    SO what is the best practice- to have a single report having multiple queries - OR - to create multiple webi reports with single query?
    Thanks and Regards,
    PASG

    HI
    I think Best Practice is Multiple reports with single query
    Any way If LO connections refresh 5 time the query will refresh 5 timesRegards
    Venkat

  • A single OBIEE report firing Multiple Queries

    HI All,
    I tried the search option and did not find any questions which gives me what I am looking for. If I missed it and the question is already asked, please redirect me to the thread.
    I had a report which had a data issues. When i checked the log, I was shocked to see it firing 10 different queries. Could you guys please tell me exactly when OBIEE decides to split a single query and fire multiple ones?
    Here's some info on the report:
    1. All the columns are from the same subject area.
    2. All the physical tables are in the same database in the physical layer.
    3. All the tables are from the same physical catalog even.
    4. Majority of the columns are from the same fact. The fact table however has multiple LTS(Over 30) involving both fragmentation and content filters.
    Could you guys please let me know  why multiple queries are fired in the above case as well as generally by OBIEE?
    Thanks,
    Abhiram.

    It is recommended not to edit DB features. If you need to change them you might need to take help of oracle support.
    Else you might induce more erratic behavior.
    Not in agreement here. Depending on how that data sources beneath OBIEE are physically set up and parametrized you may be forced to change this in order to assure performance for example. Not all your BI-analyzed sources will be purpose-built for analytics and hence follow usual modellization rules or approaches. Oracle put the features in the DB objects for exactly that reason. And obviously you don't go and change the features "just like that".
    since fact measures are from multiple LTS, every time you bring a measure from different LTS it is treated as another star. So what OBIEE does is it queries each star separately using alias and then stitch them logically. Thats the reason for fragmented queries and a singel long sql in the end with stitches the other sql results in the end.
    True, but the OP was talking about "firing 10 different queries". Which is a bit vague but sounds more like distinct select statements rather than stich-joined WITHs...that's why I directed him towards the features which can actually change this dramatically. Problem is, that the OP hasn't made that exact point clear yet.

  • Matrix report with Multiple queries

    I have created one cross product group containing 4 subgroups under a single query. Now I have another one query seperately to be joined with the matrix query. Also I have one formula column and summary column with this the cross product group. The logic is if formula condition is true the it should take the 2nd query value in the place holder column otherwise it should take the first query value. is it possible?
    If any one knows about this update me ASAP to [email protected]

    Isn't there a way for you to do this via a Package/Procedure versus having multiple queries?
    Per the BI Publisher guide,
    Following are recommended guidelines for building data models:
    Reduce the number of data sets or queries in your data model as much as possible. In general, the fewer data sets and queries you have, the faster your data model will run. While multiquery data models are often easier to understand, single-query data models tend to execute more quickly. It is important to understand that in parent-child queries, for every parent, the child query is executed.
    You should only use multiquery data models in the following scenarios:
    To perform functions that the query type, such as a SQL query, does not support directly.
    To support complex views (for example, distributed queries or GROUP BY queries).
    To simulate a view when you do not have or want to use a view.
    Thanks,
    Bipuser

  • Creating report with multiple queries in clear quest

    Hi,
    I am new to reports and currently working with creating reports that connect to clear quest(CQ).
    I have successfully created several reports, that connect to the CQ, but they all have data from only one query.
    Now I am trying to create a slightly complex report where I need to fetch data from multiple queries. All these queries use 2 parameter to filter their data. I have dynamic cascading parameters to get them. When just connecting they all work ok. I used the link tab to link them to two fields of one query, to make sure that they all filter to fields from same query.
    The problem is when I drop the fields from the various queries on the form, the data is fetched multiple times.
    I also played with links to make them outer links but in that case I get error and unable to run the report completely.
    Any ideas on how to work with multiple queries and provide same parameters to all of the queries?
    Thanks in advance.
    -PAP

    - How do I make sure that the relationship is not one to many?
    You don't. That's the nature of the data. For example a single person can order multiple items. A simple one to many relationship.
    - In the link tab, I can only point to queries, is there a way I can point the fields to report params?
    You should be seeing tables... I think you're having a tough time with the basic terminology.
    - How does these Enforce Joins (4 options) work.
    There is rarely if ever any reason to switch from the default "not enforced". Leave it alone. The only one you'll touch 90% of the time is the Join Type.
    PAP,
    Based on the questions you're asking, it sounds like you are missing some major database fundamentals. My suggestion would be to step away from CR for the time being and read a little bit about relational databases (what makes them relational) and database normalization. This will also give you an idea about the various join types and when to use one over the other.
    You can know every feature and function in CR, but until you have at least a basic knowledge of how data relates, you'll never pull in the data you need.
    Jason

  • Report Builder SQL Queries - Convert CN to clear text

    I am trying to customize a query in Report Builder to message values as they are delivered, and running into value expression errors.
    My query returns data from the AD Computer Object "managedBy" field. The problem is that this field returns data in the format of:
    CN=Security Group Name,OU=blah,OU=blah,DC=stuff,DC=com etc
    I am trying to get it to return just the "Security Group" value which is much more useful. I found this great article which almost works for me: https://social.technet.microsoft.com/forums/systemcenter/en-US/6610d238-72f2-4e75-a0cc-e1383dd8e94b/ad-system-discovery-convert-cn-to-clear-text
    However, once I try to save the report in Report Builder I get:
    System.Web.Services.Protocols.SoapException: The Value expression for the text box ‘managedBy0’ refers to the field ‘managedBy0’.  Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified
    dataset scope. Letters in the names of fields must use the correct case.
    This is the original SQL query:
    select  all SMS_R_System.Name0,SMS_R_System.managedBy0,SMS_R_System.description0,SMS_G_System_OPERATING_SYSTEM.Caption00,SMS_R_System.Resource_Domain_OR_Workgr0,SMS_R_System.whenCreated0,SMS_R_System.Last_Logon_Timestamp0 from vSMS_R_System AS SMS_R_System
    INNER JOIN Operating_System_DATA AS SMS_G_System_OPERATING_SYSTEM ON SMS_G_System_OPERATING_SYSTEM.MachineID = SMS_R_System.ItemKey  INNER JOIN _RES_COLL_CAS000A9 AS SMS_CM_RES_COLL_CAS000A9 ON SMS_CM_RES_COLL_CAS000A9.MachineID = SMS_R_System.ItemKey
    My edited query:
    select  all SMS_R_System.Name0,REPLACE(SUBSTRING(SMS_R_System.managedBy0,4,CHARINDEX(',OU',SMS_R_System.managedBy0,3)-4),'\,',','),SMS_R_System.description0,SMS_G_System_OPERATING_SYSTEM.Caption00,SMS_R_System.Resource_Domain_OR_Workgr0,SMS_R_System.whenCreated0,SMS_R_System.Last_Logon_Timestamp0
    from vSMS_R_System AS SMS_R_System INNER JOIN Operating_System_DATA AS SMS_G_System_OPERATING_SYSTEM ON SMS_G_System_OPERATING_SYSTEM.MachineID = SMS_R_System.ItemKey  INNER JOIN _RES_COLL_CAS000A9 AS SMS_CM_RES_COLL_CAS000A9 ON SMS_CM_RES_COLL_CAS000A9.MachineID
    = SMS_R_System.ItemKey
    Thoughts?

    Hey,
    Since you manipulate the original value of
    ManagedBy0 in your SELECT, the column name will change to
    (No column name). I did a test on my side and look what I get.
    Error : "The Value expression for the text box ‘managedBy0’ refers to the field ‘managedBy0’."
    He search for a variable
    ManagedBy0 in your query but don't find any because there's no name assigned.
    Try to run this query. Add
    AS ManagedBy0 after your REPLACE. 
    select all
    SMS_R_System.Name0,
    REPLACE(SUBSTRING(SMS_R_System.managedBy0,4,CHARINDEX(',OU',SMS_R_System.managedBy0,3)-4),'\,',',') AS ManagedBy0,
    SMS_R_System.description0,
    SMS_G_System_OPERATING_SYSTEM.Caption00,
    SMS_R_System.Resource_Domain_OR_Workgr0,
    SMS_R_System.whenCreated0,
    SMS_R_System.Last_Logon_Timestamp0 from vSMS_R_System AS SMS_R_System INNER JOIN Operating_System_DATA AS SMS_G_System_OPERATING_SYSTEM ON SMS_G_System_OPERATING_SYSTEM.MachineID = SMS_R_System.ItemKey INNER JOIN _RES_COLL_CAS000A9 AS SMS_CM_RES_COLL_CAS000A9 ON SMS_CM_RES_COLL_CAS000A9.MachineID = SMS_R_System.ItemKey
    Let me know.
    Nick Pilon | Blog : System Center Dudes

  • Hints on building a report with multiple queries

    Hi all,
    I know this is not the best forum to address this question, but i know
    a lot of people here are using XML publisher with jdev to produce reports.
    any help is appreciated.
    Im a begginner with XML publisher and i am facing a problem!
    I had no troubles with reports containing one query but when i need more than
    one query inside my report I really dont know how to manage the whole thing
    I would love to know if someone could guide to some steps or to web site explaining
    the method to follow.
    I am using word to build my templates ---- if you could help towards this direction or
    tell what to use instead I would greatly appreciate
    Best Regards,
    Carl

    repost anyone?..

  • Group by Left Report for Multiple Queries

    Afternoon folks,
    I have been pretty much writing my queries in Oracle Reports by having one long query (which includes multiple sub-queries) and then displaying the results (Mainly Counts and MEDIAN values).
    This has resulted in one very long query (difficult to manage and understand), not to mention slower performance. I would like to change that my making smaller queries and use data links to join the groups.
    Here is my Report request in hand. I need to build a Report that will be grouped by a Reporting Year and stratified by Age Groups and then Report various Counts of Students that are
    coming from various data sources (Tables). As of now, I have the Counts coming from at least 3 different data sources. So as you can imagine, my 3 sub queries have added to one
    very long query. Anymore requirements to the Report and it can lead to a big mess.
    Column '# of Students Enrolled' is coming from ENROLLMENT_TB table
    Columns '# of Students who took Math' and 'Marks > 60' are coming from COURSE_MATH table.
    Birth Date information is in the STUDENT_TB table (Since the Report needs to be stratified by Age Groups)
    Report Layout
    Reporting Year    Age Group         # of Students Enrolled   # of Students who took Math       Marks > 60   Median Score
    ========================================================================================================================
    2010              1960 - 1969                          999                           999              999            999                 
                      1970 - 1979                          999                           999              999            999                 
                      1980 - 1989                          999                           999              999            999                 
                      1990+                                999                           999              999            999                 
    2011              1960 - 1969                          999                           999              999            999                 
                      1970 - 1979                          999                           999              999            999                 
                      1980 - 1989                          999                           999              999            999                 
                      1990+                                999                           999              999            999                 
    2012              1960 - 1969                          999                           999              999            999                 
                      1970 - 1979                          999                           999              999            999                 
                      1980 - 1989                          999                           999              999            999                 
                      1990+                                999                           999              999            999                  Currently, I have 3 sub-queries
    Sub Query #1: # of Students Enrolled from ENROLLMENT_TB.
    Sub Query #2: # of the Enrolled Students who took Math from COURSE_MATH_TB
    Sub Query #3: # of the Enrolled Students who took Math from COURSE_MATH_TB and got Marks > 60. Median Score of this sampling.
    My thought would be to have them into Groups and then create a Report a s a Group Left to achieve the results. Any help or suggestions would be more than welcome.
    I have begun working on this Report but it is still taking quite long (Like 4 minutes) when the individual Queries (Q_COURSE_MATH and Q_COURSE_MATCH_60) are only taking 20 seconds each.
    My guess is the Grouping based on the age group is resulting in slower performance but I could be wrong.
    Also, the Query runs between pages and takes a long time to run. So, when I actually ran the Report, only the first page was formatted and then subsequent pages follow.
    Looking at the data model, is there something conceptually wrong?
    I have also not included the Query for Enrollment Counts to keep the Report simple.
    Data Links:
    Q_REPORTING_YEAR and Q_COURSE_MATH (Join condition: reporting_year and age_range_order_id)
    Q_REPORTING_YEAR and Q_COURSE_MATH_60 (Join condition: reporting_year and age_range_order_id)
    Data Layout:
    Q_REPORTING_YEAR
    select yrs.reporting_year,
           age_range.age_range_label,
           age_range.age_range_order_id
    from
      select to_char(Add_Months(To_Date ('01-JAN-2009', 'DD-MON-YYYY'), 12 * LEVEL), 'YYYY')   reporting_year
      from    DUAL
      CONNECT BY LEVEL < 4
    ) yrs,
      select decode( rownum, 10, '1990+', to_char(1900+ (rownum-1)*10)||'-'|| to_char(1900+ (rownum)*10-1))   age_range_label,
                 to_char(1900+ (rownum - 1)*10)                                                               age_start,
                 to_char(decode(rownum, 10, to_char(sysdate, 'yyyy'), 1900+ (rownum)*10-1))                   age_stop,
                 rownum                                                                                       age_range_order_id
      from    dual
      connect by rownum < 11
    ) age_range
    order by yrs.reporting_year, age_range.age_range_order_id
    Q_COURSE_MATH
    select reporting_year              cm_reporting_year,
           age_range_label             cm_age_range_label,
           age_range_order_id          cm_age_range_order_id,
           COUNT(distinct(student_id)) cm_student_count
    from
      select distinct cm.student_id                     student_id,
             to_char(cm.course_date, 'YYYY')           reporting_year,
             age_range.age_range_label        age_range_label,
             age_range.age_range_order_id   age_range_order_id
      from   course_math    cm,
             student_tb s,
               select decode( rownum, 10, '1990+', to_char(1900+ (rownum-1)*10)||'-'|| to_char(1900+ (rownum)*10-1))   age_range_label,
                          to_char(1900+ (rownum - 1)*10)                                                               age_start,
                          to_char(decode(rownum, 10, to_char(sysdate, 'yyyy'), 1900+ (rownum)*10-1))                   age_stop,
                          rownum                                                                                       age_range_order_id
               from    dual
               connect by rownum < 11
              ) age_range
        where  cm.student_id = s.student_id
        and exists ( select 'x' from sampling_student_vw w
                         where  w.student_id = cm.student_id )
        and     to_char(s.birth_date, 'YYYY') between age_range.age_start and age_range.age_stop
    ) q
    GROUP BY q.reporting_year, q.age_range_label, q.age_range_order_id
    Q_COURSE_MATH_60
    select reporting_year              cm_reporting_year,
           age_range_label             cm_age_range_label,
           age_range_order_id          cm_age_range_order_id,
           COUNT(distinct(student_id)) cm_student_count,
           MEDIAN(marks)                cm_median_60
    from
      select distinct cm.student_id                     student_id,
             to_char(cm.course_date, 'YYYY')           reporting_year,
             cm.marks                                  marks,
             age_range.age_range_label        age_range_label,
             age_range.age_range_order_id   age_range_order_id
      from   course_math    cm,
             student_tb s,
               select decode( rownum, 10, '1990+', to_char(1900+ (rownum-1)*10)||'-'|| to_char(1900+ (rownum)*10-1))   age_range_label,
                          to_char(1900+ (rownum - 1)*10)                                                               age_start,
                          to_char(decode(rownum, 10, to_char(sysdate, 'yyyy'), 1900+ (rownum)*10-1))                   age_stop,
                          rownum                                                                                       age_range_order_id
               from    dual
               connect by rownum < 11
              ) age_range
        where  cm.student_id = s.student_id
        and      cm.marks >= 60
        and exists ( select 'x' from sampling_student_vw w
                         where  w.student_id = cm.student_id )
        and     to_char(s.birth_date, 'YYYY') between age_range.age_start and age_range.age_stop
    ) q
    GROUP BY q.reporting_year, q.age_range_label, q.age_range_order_id

    Hi Arsalan,
    "Group by" is not a valid calculation option for calculated fields in the database object, nor is it for the calculation fields in your report.
    I believe that what you are trying to achieve is to have a SUM of all the sales done, grouped by Brand. This is typically something you configure while building your report(in Active Studio).
    If you for example would only want to show 2 out of 5 Brands in your report I suggest you use a filter(which is configured while building your report as well).
    For all calculation and operation options in calculated fields you can go to the Help section of BAM and search for "Calculation Operators and Expressions".
    I hope I helped you solve your problem.
    Kind regards,
    Martijn van der Kamp

  • How to mass print a report with multiple queries?

    Dear All,
    i want to precalclate a report (which includes 4 queries) to pdf for printing. Because i have to print it for all profitcenter (~200), i want to use the filter navigation.
    Because this isn't possible for reports, i inserted my report using a report item to a web template.
    When i call the web template direct, everything works fine, but if i precalculate the web template using the bex broadcaster, only one query is parameterized. The second one seems to use the global variant (the sum of all profitcenter).
    Any Idea? Do i have to change an export web template and add some data provider? I am not absolutely sure which is the right export template for an report in a web template...
    Thanks in advance,
    Thomas

    Hey all,
    nobody an idea of a possible approach.
    Greetz,
    Thomas

  • Oracle Ad-hoc report with multiple queries creating issues

    Hi Guys,
    I have been having multiple issues (one after the other) in trying to generate a report for Business user. Let me start with my test cases and yes, this time I have made sure by testing and dirtying my hands that the test cases work properly and commit into the database (I will be more than happy to provide screen shots of the same).
    Test Case:
    Tables:RETURNS & RETURN_LINE_ITEMS
    CREATE TABLE RETURNS
      ID                    NUMBER(12),
      PROG_PROGRAM_CD       VARCHAR2(2 BYTE),
      ACCT_ID               NUMBER(12),
      ACPE_ID               NUMBER(12),
      JENT_ID               NUMBER(12),
      PREV_RTRN_ID          NUMBER(12),
      ENTP_ABN              NUMBER(9),
      ACCT_OCCURNC_NBR      NUMBER(4),
      SOURCE_TYPE           VARCHAR2(30 BYTE)       DEFAULT 'BLANK',
      RECEIVE_DATE          DATE,
      AMEND_IND             VARCHAR2(1 BYTE)        DEFAULT 'N',
      CMPLT_IND             VARCHAR2(1 BYTE)        DEFAULT 'N',
      PENALTY_OR_IND        VARCHAR2(1 BYTE)        DEFAULT 'N',
      RETURN_STATUS         VARCHAR2(12 BYTE),
      STATUS_DATE           DATE,
      STATUS_USERID         VARCHAR2(8 BYTE),
      PERIOD_START_DATE     DATE,
      PERIOD_END_DATE       DATE,
      NOTICE_STATUS         VARCHAR2(12 BYTE),
      NOTICE_STATUS_DATE    DATE,
      NOTE_TEXT             VARCHAR2(2000 BYTE),
      PENALTY_OR_BY         VARCHAR2(8 BYTE),
      PENALTY_OR_TMST       DATE,
      FILING_ID             NUMBER(12),
      CASE_ID               VARCHAR2(49 BYTE),
      DOC_CONTRL_NBR        NUMBER(29),
      LOCTR_NBR             NUMBER(10),
      STATUTE_BARRED_DATE   DATE,
      MEDIA_TYPE            VARCHAR2(30 BYTE),
      DISPSTN_TYPE          VARCHAR2(30 BYTE),
      AMEND_TYPE            VARCHAR2(30 BYTE),
      CALC_MODE             VARCHAR2(30 BYTE),
      PROCESS_PASS_CNT      NUMBER(1),
      CONVRTD_IND           VARCHAR2(1 BYTE)        DEFAULT 'N',
      LOSS_PERIOD_END_DATE  DATE,
      MF_SYNC_CD            VARCHAR2(1 BYTE)
    CREATE TABLE RETURN_LINE_ITEMS
      ID                       NUMBER(12),
      RTSC_ID                  NUMBER(12),
      RTRN_ID                  NUMBER(12),
      SCLI_ID                  NUMBER(12),
      LITM_ID                  NUMBER(12),
      ENTP_ABN                 NUMBER(9),
      PROG_PROGRAM_CD          VARCHAR2(2 BYTE),
      ACCT_OCCURNC_NBR         NUMBER(4),
      ACPE_END_DATE            DATE,
      SCHED_NBR                VARCHAR2(3 BYTE),
      SCHD_VERSION_YR          NUMBER(4)            DEFAULT 0,
      SCHD_VERSION_NBR         NUMBER(3),
      RTSC_OCCUR_NBR           NUMBER(3),
      LITM_LINE_ITEM_NBR       VARCHAR2(3 BYTE),
      SLIN_LINE_ITEM_ID        NUMBER(12),
      OCCUR_NBR                NUMBER(3)            DEFAULT 1,
      PREV_VAL_MOD_IND         VARCHAR2(1 BYTE)     DEFAULT 'N',
      VIABLE_IND               VARCHAR2(1 BYTE)     DEFAULT 'N',
      ACTIVE_IND               VARCHAR2(1 BYTE)     DEFAULT 'Y',
      ACTION_CD                VARCHAR2(1 BYTE),
      PREV_VAL_AMT             NUMBER(15,2),
      REVISE_VAL_AMT           NUMBER(15,2),
      PREV_VAL_TEXT            VARCHAR2(100 BYTE),
      REVISE_VAL_TEXT          VARCHAR2(100 BYTE),
      DISPLAY_SEQ_NBR          NUMBER(3),
      SYS_VAL_AMT              NUMBER(15,2),
      LITM_INNER_PASS_SEQ_NBR  NUMBER(3)
    Inserting data into RETURNS table
    INSERT INTO RETURNS (
    ID                  ,
    PROG_PROGRAM_CD      ,
    ACCT_ID              ,
    ACPE_ID              ,
    JENT_ID              ,
    PREV_RTRN_ID         ,
    ENTP_ABN             ,
    ACCT_OCCURNC_NBR     ,
    SOURCE_TYPE          ,
    RECEIVE_DATE         ,
    AMEND_IND            ,
    CMPLT_IND            ,
    PENALTY_OR_IND       ,
    RETURN_STATUS        ,
    STATUS_DATE          ,
    STATUS_USERID        ,
    PERIOD_START_DATE    ,
    PERIOD_END_DATE      ,
    NOTICE_STATUS        ,
    NOTICE_STATUS_DATE   ,
    NOTE_TEXT            ,
    PENALTY_OR_BY        ,
    PENALTY_OR_TMST      ,
    FILING_ID            ,
    CASE_ID              ,
    DOC_CONTRL_NBR       ,
    LOCTR_NBR            ,
    STATUTE_BARRED_DATE  ,
    MEDIA_TYPE           ,
    DISPSTN_TYPE         ,
    AMEND_TYPE           ,
    CALC_MODE            ,
    PROCESS_PASS_CNT     ,
    CONVRTD_IND          ,
    LOSS_PERIOD_END_DATE ,
    MF_SYNC_CD)          
    VALUES(
    3715944,
    '01',
    139048,
    3587419,
    9518324,
    NULL,
    401377197,
    1,
    'TAXPAYER',
    TO_DATE('4/7/2009','mm/dd/yyyy'),
    'N',
    'Y',
    'N',
    'ASSESSED',
    TO_DATE('4/30/2009','mm/dd/yyyy'),
    'TRAPROD2',
    TO_DATE('2/1/2008','mm/dd/yyyy'),
    TO_DATE('1/31/2009', 'mm/dd/yyyy'),
    'PRINTED',
    TO_DATE('4/30/2009'     , 'mm/dd/yyyy'),
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    6045574495,
    NULL,
    'RSI',
    'NOTICE',
    NULL,
    NULL,
    NULL,
    'N',
    NULL,
    NULL);
    NSERT INTO RETURNS (
    ID                  ,
    PROG_PROGRAM_CD      ,
    ACCT_ID              ,
    ACPE_ID              ,
    JENT_ID              ,
    PREV_RTRN_ID         ,
    ENTP_ABN             ,
    ACCT_OCCURNC_NBR     ,
    SOURCE_TYPE          ,
    RECEIVE_DATE         ,
    AMEND_IND            ,
    CMPLT_IND            ,
    PENALTY_OR_IND       ,
    RETURN_STATUS        ,
    STATUS_DATE          ,
    STATUS_USERID        ,
    PERIOD_START_DATE    ,
    PERIOD_END_DATE      ,
    NOTICE_STATUS        ,
    NOTICE_STATUS_DATE   ,
    NOTE_TEXT            ,
    PENALTY_OR_BY        ,
    PENALTY_OR_TMST      ,
    FILING_ID            ,
    CASE_ID              ,
    DOC_CONTRL_NBR       ,
    LOCTR_NBR            ,
    STATUTE_BARRED_DATE  ,
    MEDIA_TYPE           ,
    DISPSTN_TYPE         ,
    AMEND_TYPE           ,
    CALC_MODE            ,
    PROCESS_PASS_CNT     ,
    CONVRTD_IND          ,
    LOSS_PERIOD_END_DATE ,
    MF_SYNC_CD)          
    VALUES(
    4117092,
    '01',
    57794,
    3864551,
    10566221,
    NULL,
    400571410,
    1,
    'TAXPAYER',
    TO_DATE('6/30/2010', 'mm/dd/yyyy'),
    'N',
    'Y',
    'N',
    'ASSESSED',
    TO_DATE('7/27/2010','mm/dd/yyyy'),
    'TRAPROD2',
    TO_DATE('1/1/2009','mm/dd/yyyy'),
    TO_DATE('12/31/2009','mm/dd/yyyy'),
    'PRINTED',
    TO_DATE('7/27/2010','mm/dd/yyyy'),
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    6053117120,
    NULL,
    'RSI',
    'NOTICE',
    NULL,
    NULL,
    NULL,
    'N',
    NULL,
    NULL);
    INSERT INTO RETURNS (
    ID                  ,
    PROG_PROGRAM_CD      ,
    ACCT_ID              ,
    ACPE_ID              ,
    JENT_ID              ,
    PREV_RTRN_ID         ,
    ENTP_ABN             ,
    ACCT_OCCURNC_NBR     ,
    SOURCE_TYPE          ,
    RECEIVE_DATE         ,
    AMEND_IND            ,
    CMPLT_IND            ,
    PENALTY_OR_IND       ,
    RETURN_STATUS        ,
    STATUS_DATE          ,
    STATUS_USERID        ,
    PERIOD_START_DATE    ,
    PERIOD_END_DATE      ,
    NOTICE_STATUS        ,
    NOTICE_STATUS_DATE   ,
    NOTE_TEXT            ,
    PENALTY_OR_BY        ,
    PENALTY_OR_TMST      ,
    FILING_ID            ,
    CASE_ID              ,
    DOC_CONTRL_NBR       ,
    LOCTR_NBR            ,
    STATUTE_BARRED_DATE  ,
    MEDIA_TYPE           ,
    DISPSTN_TYPE         ,
    AMEND_TYPE           ,
    CALC_MODE            ,
    PROCESS_PASS_CNT     ,
    CONVRTD_IND          ,
    LOSS_PERIOD_END_DATE ,
    MF_SYNC_CD)          
    VALUES(
    4382179,
    '01',
    498210,
    3957251,
    11264174,
    3727534,
    405079963,
    1,
    'TAXPAYER',
    TO_DATE('4/26/2011', 'mm/dd/yyyy'),
    'Y',
    'Y',
    'N',
    'ASSESSED',
    TO_DATE('5/12/2011','mm/dd/yyyy'),
    'LOPATS',
    TO_DATE('2/1/2008', 'mm/dd/yyyy'),
    TO_DATE('1/31/2009','mm/dd/yyyy'),
    'PRINTED',
    TO_DATE('5/12/2011','mm/dd/yyyy'),
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    6058767341,
    TO_DATE('4/30/2015','mm/dd/yyyy'),
    'RSI',
    'NOTICE',
    'LOSS CARRY BACK (SIMPLE)',
    'LOSS CARRY BACK',
    NULL,
    'N',
    TO_DATE('1/31/2011', 'mm/dd/yyyy'),
    NULL
    Now inserting data into 2nd table i.e. RETURN_LINE_ITEMS
    RTRN_ID means RETURN ID
    This is for RTRN_ID =3715944
    INSERT INTO RETURN_LINE_ITEMS (
    ID                      ,
    RTSC_ID                 ,
    RTRN_ID                 ,
    SCLI_ID                 ,
    LITM_ID                 ,
    ENTP_ABN                ,
    PROG_PROGRAM_CD         ,
    ACCT_OCCURNC_NBR        ,
    ACPE_END_DATE           ,
    SCHED_NBR               ,
    SCHD_VERSION_YR         ,
    SCHD_VERSION_NBR        ,
    RTSC_OCCUR_NBR          ,
    LITM_LINE_ITEM_NBR      ,
    SLIN_LINE_ITEM_ID       ,
    OCCUR_NBR               ,
    PREV_VAL_MOD_IND        ,
    VIABLE_IND              ,
    ACTIVE_IND              ,
    ACTION_CD               ,
    PREV_VAL_AMT            ,
    REVISE_VAL_AMT          ,
    PREV_VAL_TEXT           ,
    REVISE_VAL_TEXT         ,
    DISPLAY_SEQ_NBR         ,
    SYS_VAL_AMT             ,
    LITM_INNER_PASS_SEQ_NBR  
    VALUES(
    277707088,
    8022477,
    3715944,
    NULL,
    1585,
    401377197,
    '01',
    1,
    TO_DATE('1/31/2009', 'mm/dd/yyyy'),
    '000',
    1998,
    1,
    1,
    '029',
    23,
    1,
    'N',
    'Y',
    'Y',
    NULL,
    1,
    1,
    NULL,
    NULL,
    115,
    1 ,
    1);
    INSERT INTO RETURN_LINE_ITEMS (
    ID                      ,
    RTSC_ID                 ,
    RTRN_ID                 ,
    SCLI_ID                 ,
    LITM_ID                 ,
    ENTP_ABN                ,
    PROG_PROGRAM_CD         ,
    ACCT_OCCURNC_NBR        ,
    ACPE_END_DATE           ,
    SCHED_NBR               ,
    SCHD_VERSION_YR         ,
    SCHD_VERSION_NBR        ,
    RTSC_OCCUR_NBR          ,
    LITM_LINE_ITEM_NBR      ,
    SLIN_LINE_ITEM_ID       ,
    OCCUR_NBR               ,
    PREV_VAL_MOD_IND        ,
    VIABLE_IND              ,
    ACTIVE_IND              ,
    ACTION_CD               ,
    PREV_VAL_AMT            ,
    REVISE_VAL_AMT          ,
    PREV_VAL_TEXT           ,
    REVISE_VAL_TEXT         ,
    DISPLAY_SEQ_NBR         ,
    SYS_VAL_AMT             ,
    LITM_INNER_PASS_SEQ_NBR  
    VALUES
    277707106,
    8022477,
    3715944,
    NULL,
    1603,
    401377197,
    '01',
    1,
    TO_DATE('1/31/2009', 'mm/dd/yyyy'),
    '000',
    1998,
    1,
    1,
    '062',
    40,
    1,
    'N',
    'Y',
    'Y',
    NULL,
    1069336,
    1069336,
    NULL,
    NULL,
    200,
    1069336,
    130
    INSERT INTO RETURN_LINE_ITEMS (
    ID                      ,
    RTSC_ID                 ,
    RTRN_ID                 ,
    SCLI_ID                 ,
    LITM_ID                 ,
    ENTP_ABN                ,
    PROG_PROGRAM_CD         ,
    ACCT_OCCURNC_NBR        ,
    ACPE_END_DATE           ,
    SCHED_NBR               ,
    SCHD_VERSION_YR         ,
    SCHD_VERSION_NBR        ,
    RTSC_OCCUR_NBR          ,
    LITM_LINE_ITEM_NBR      ,
    SLIN_LINE_ITEM_ID       ,
    OCCUR_NBR               ,
    PREV_VAL_MOD_IND        ,
    VIABLE_IND              ,
    ACTIVE_IND              ,
    ACTION_CD               ,
    PREV_VAL_AMT            ,
    REVISE_VAL_AMT          ,
    PREV_VAL_TEXT           ,
    REVISE_VAL_TEXT         ,
    DISPLAY_SEQ_NBR         ,
    SYS_VAL_AMT             ,
    LITM_INNER_PASS_SEQ_NBR  
    VALUES
    (277707109,
    8022477,
    3715944,
    NULL,
    1539,
    401377197,
    '01',
    1,
    TO_DATE('1/31/2009','mm/dd/yyyy'),
    '000',
    1998,
    1,
    1,
    '066',
    43,
    1,
    'N',
    'Y',
    'Y',
    NULL,
    NULL,
    1000,
    'NULL',
    'NULL',
    215,
    1069336,
    200);Now for RTRN_ID = 4117092
    INSERT INTO RETURN_LINE_ITEMS (
    ID                      ,
    RTSC_ID                 ,
    RTRN_ID                 ,
    SCLI_ID                 ,
    LITM_ID                 ,
    ENTP_ABN                ,
    PROG_PROGRAM_CD         ,
    ACCT_OCCURNC_NBR        ,
    ACPE_END_DATE           ,
    SCHED_NBR               ,
    SCHD_VERSION_YR         ,
    SCHD_VERSION_NBR        ,
    RTSC_OCCUR_NBR          ,
    LITM_LINE_ITEM_NBR      ,
    SLIN_LINE_ITEM_ID       ,
    OCCUR_NBR               ,
    PREV_VAL_MOD_IND        ,
    VIABLE_IND              ,
    ACTIVE_IND              ,
    ACTION_CD               ,
    PREV_VAL_AMT            ,
    REVISE_VAL_AMT          ,
    PREV_VAL_TEXT           ,
    REVISE_VAL_TEXT         ,
    DISPLAY_SEQ_NBR         ,
    SYS_VAL_AMT             ,
    LITM_INNER_PASS_SEQ_NBR  
    VALUES(
    319820214,
    9028477,
    4117092,
    NULL,
    1585,
    400571410,
    '01',
    1,
    TO_DATE('12/31/2009','mm/dd/yyyy'),
    '000',
    1998,
    1,
    1,
    '029',
    23,
    1,
    'N',
    'Y',
    'Y',
    NULL,
    3,
    3,
    NULL,
    NULL,
    115,
    3,
    1
    INSERT INTO RETURN_LINE_ITEMS (
    ID                      ,
    RTSC_ID                 ,
    RTRN_ID                 ,
    SCLI_ID                 ,
    LITM_ID                 ,
    ENTP_ABN                ,
    PROG_PROGRAM_CD         ,
    ACCT_OCCURNC_NBR        ,
    ACPE_END_DATE           ,
    SCHED_NBR               ,
    SCHD_VERSION_YR         ,
    SCHD_VERSION_NBR        ,
    RTSC_OCCUR_NBR          ,
    LITM_LINE_ITEM_NBR      ,
    SLIN_LINE_ITEM_ID       ,
    OCCUR_NBR               ,
    PREV_VAL_MOD_IND        ,
    VIABLE_IND              ,
    ACTIVE_IND              ,
    ACTION_CD               ,
    PREV_VAL_AMT            ,
    REVISE_VAL_AMT          ,
    PREV_VAL_TEXT           ,
    REVISE_VAL_TEXT         ,
    DISPLAY_SEQ_NBR         ,
    SYS_VAL_AMT             ,
    LITM_INNER_PASS_SEQ_NBR  
    VALUES(
    319820233,
    9028477,
    4117092,
    NULL,
    1603,
    400571410,
    '01',
    1,
    TO_DATE('12/31/2009','mm/dd/yyyy'),
    '000',
    1998,
    1,
    1,
    '062',
    40,
    1,
    'N',
    'Y',
    'Y',
    NULL,
    790068,
    790068,
    NULL,
    NULL,
    200,
    790068,
    130
    INSERT INTO RETURN_LINE_ITEMS (
    ID                      ,
    RTSC_ID                 ,
    RTRN_ID                 ,
    SCLI_ID                 ,
    LITM_ID                 ,
    ENTP_ABN                ,
    PROG_PROGRAM_CD         ,
    ACCT_OCCURNC_NBR        ,
    ACPE_END_DATE           ,
    SCHED_NBR               ,
    SCHD_VERSION_YR         ,
    SCHD_VERSION_NBR        ,
    RTSC_OCCUR_NBR          ,
    LITM_LINE_ITEM_NBR      ,
    SLIN_LINE_ITEM_ID       ,
    OCCUR_NBR               ,
    PREV_VAL_MOD_IND        ,
    VIABLE_IND              ,
    ACTIVE_IND              ,
    ACTION_CD               ,
    PREV_VAL_AMT            ,
    REVISE_VAL_AMT          ,
    PREV_VAL_TEXT           ,
    REVISE_VAL_TEXT         ,
    DISPLAY_SEQ_NBR         ,
    SYS_VAL_AMT             ,
    LITM_INNER_PASS_SEQ_NBR  
    VALUES
    319820236,
    9028477,
    4117092,
    NULL,
    1539,
    400571410,
    '01',
    1,
    TO_DATE('12/31/2009','mm/dd/yyyy'),
    '000',
    1998,
    1,
    1,
    '066',
    43,
    1,
    'N',
    'Y',
    'Y',
    NULL,
    NULL,
    790,
    NULL,
    NULL,
    215,
    790068,
    200
    Now finally for RTRN_ID = 4382179
    INSERT INTO RETURN_LINE_ITEMS (
    ID                      ,
    RTSC_ID                 ,
    RTRN_ID                 ,
    SCLI_ID                 ,
    LITM_ID                 ,
    ENTP_ABN                ,
    PROG_PROGRAM_CD         ,
    ACCT_OCCURNC_NBR        ,
    ACPE_END_DATE           ,
    SCHED_NBR               ,
    SCHD_VERSION_YR         ,
    SCHD_VERSION_NBR        ,
    RTSC_OCCUR_NBR          ,
    LITM_LINE_ITEM_NBR      ,
    SLIN_LINE_ITEM_ID       ,
    OCCUR_NBR               ,
    PREV_VAL_MOD_IND        ,
    VIABLE_IND              ,
    ACTIVE_IND              ,
    ACTION_CD               ,
    PREV_VAL_AMT            ,
    REVISE_VAL_AMT          ,
    PREV_VAL_TEXT           ,
    REVISE_VAL_TEXT         ,
    DISPLAY_SEQ_NBR         ,
    SYS_VAL_AMT             ,
    LITM_INNER_PASS_SEQ_NBR  
    VALUES
    348462584,
    9694297,
    4382179,
    NULL,
    1585,
    405079963,
    '01',
    1,
    TO_DATE(1/31/2009, 'mm/dd/yyyy'),
    '000'
    1998,
    1,
    1,
    '029',
    23,
    1,
    'N',
    'Y',
    'Y',
    NULL,
    1,
    1,
    NULL,
    NULL,
    115,
    NULL,
    1
    INSERT INTO RETURN_LINE_ITEMS (
    ID                      ,
    RTSC_ID                 ,
    RTRN_ID                 ,
    SCLI_ID                 ,
    LITM_ID                 ,
    ENTP_ABN                ,
    PROG_PROGRAM_CD         ,
    ACCT_OCCURNC_NBR        ,
    ACPE_END_DATE           ,
    SCHED_NBR               ,
    SCHD_VERSION_YR         ,
    SCHD_VERSION_NBR        ,
    RTSC_OCCUR_NBR          ,
    LITM_LINE_ITEM_NBR      ,
    SLIN_LINE_ITEM_ID       ,
    OCCUR_NBR               ,
    PREV_VAL_MOD_IND        ,
    VIABLE_IND              ,
    ACTIVE_IND              ,
    ACTION_CD               ,
    PREV_VAL_AMT            ,
    REVISE_VAL_AMT          ,
    PREV_VAL_TEXT           ,
    REVISE_VAL_TEXT         ,
    DISPLAY_SEQ_NBR         ,
    SYS_VAL_AMT             ,
    LITM_INNER_PASS_SEQ_NBR  
    VALUES
    348462602,
    9694297,
    4382179,
    NULL,
    1603,
    405079963,
    '01',
    1,
    TO_DATE('1/31/2009','mm/dd/yyyy'),
    '000',
    1998,
    1,
    1,
    '062',
    40,
    1,
    'N',
    'Y',
    'Y',
    NULL,
    672738,
    643304,
    NULL,
    NULL,
    200,
    NULL,
    130
    INSERT INTO RETURN_LINE_ITEMS (
    ID                      ,
    RTSC_ID                 ,
    RTRN_ID                 ,
    SCLI_ID                 ,
    LITM_ID                 ,
    ENTP_ABN                ,
    PROG_PROGRAM_CD         ,
    ACCT_OCCURNC_NBR        ,
    ACPE_END_DATE           ,
    SCHED_NBR               ,
    SCHD_VERSION_YR         ,
    SCHD_VERSION_NBR        ,
    RTSC_OCCUR_NBR          ,
    LITM_LINE_ITEM_NBR      ,
    SLIN_LINE_ITEM_ID       ,
    OCCUR_NBR               ,
    PREV_VAL_MOD_IND        ,
    VIABLE_IND              ,
    ACTIVE_IND              ,
    ACTION_CD               ,
    PREV_VAL_AMT            ,
    REVISE_VAL_AMT          ,
    PREV_VAL_TEXT           ,
    REVISE_VAL_TEXT         ,
    DISPLAY_SEQ_NBR         ,
    SYS_VAL_AMT             ,
    LITM_INNER_PASS_SEQ_NBR  
    VALUES
    348462605,
    9694297,
    4382179,
    NULL,
    1539,
    405079963,
    01,
    1,
    TO_DATE('1/31/2009','mm/dd/yyyy'),
    '000',
    1998,
    1,
    1,
    '066',
    43,
    1,
    'N',
    'Y',
    'Y',
    NULL,
    672738,
    643304,
    NULL,
    NULL,
    215,
    643304,
    200
    );OK. Now once this data is all inserted, comes the real problem and that is:
    a) based on the following requirements
    Requirements: Adhoc Report for Audit on CIT Income Allocation
    1. Select from the RETURNS table:
    • Id > 3600000 and
    • Prog_program_cd = '01' and
    • Return_status in ('ASSESSED', 'DU") and
    • Tax year ending in 2009 (i.e. year portion of the Period_end_date is in 2009)
    2. Retrieve the following fields from the RETURNS table :
    • Id
    • Entp_abn
    • Acct_id
    • Prog_program_cd
    • Period_start_date
    • Period_end_date
    • Amend_ind
    • Return_status
    • Status_date
    • Loctr_nbr
    3. If there are multiple entries from the same account and tax year, only retain the latest record: From the records selected in step 2, if there are multiple records with the same Acct_Id and Period_end_date, only retain the record with the most recent Status_date (i.e. MAX value on the date).
    4. Using the results from step 3, link to the applicable RETURN_LINE_ITEMS table where:
    • RETURNS.Id = RETURN_LINE_ITEMS.Rtrn_Id
    5. From the selected return on RETURN_LINE_ITEMS table, retrieve records where (value on Sch 000 Line 062 > 500,000) and (value on Sch 000 Line 066 < value on Sch 000 Line 062) :
    • Sched_nbr = '000', and Litm_line_item_nbr = '062', and Active_ind = 'Y', get Revise_val_amt as 'ab_taxable_income'
    • Sched_nbr = '000', and Litm_line_item_nbr = '066', and Active_ind = 'Y', get Revise_val_amt as 'amt_taxable_in_ab'
    • Retain the return only if (ab_taxable_income > 500,000) and (amt_taxable_in_ab < ab_taxable_income)
    I utilized the following query and I am getting 4 rows (line item numbers 062 and 066 where in ab_taxable_income > 500,000) and (amt_taxable_in_ab < ab_taxable_income) and this is correct
    SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd, r1.period_start_date, r1.period_end_Date, r1.amend_ind, r1.return_status, r1.status_date, r1.loctr_nbr,
    rtlnms.sched_nbr, rtlnms.litm_line_item_nbr,
    decode(rtlnms.litm_line_item_nbr, '062',  RTLNMS.REVISE_VAL_AMT)AB_TAXABLE_INCOME,
    decode(rtlnms.litm_line_item_nbr, '066',  RTLNMS.REVISE_VAL_AMT)AMT_TAXABLE_IN_AB
    from returns r1, return_line_items rtlnms
    where
    r1.id = rtlnms.rtrn_id and
    r1.prog_program_cd = rtlnms.prog_program_cd and
    r1.entp_abn = rtlnms.entp_abn and
    r1.id > 3600000 AND r1.prog_program_cd = '01' AND r1.return_status in ('ASSESSED', 'DU')
    and r1.period_end_Date between to_date('01-01-2009','DD-mm-YYYY') and to_date ('31-12-2009', 'DD-mm-YYYY')
    and r1.status_date = (select max (status_date) from returns r2 where r2. acct_id= r1.acct_id and r2.period_end_date = r1.period_end_date)
    and rtlnms.sched_nbr = '000'
    and rtlnms.active_ind = 'Y'
    and r1.id in (4117092,3715944,4382179,3691435)
    and RTLNMS.LITM_LINE_ITEM_NBR IN('062')
    AND nvl(decode(litm_line_item_nbr, '062',  REVISE_VAL_AMT),0) > 500000
    and NVL(RTLNMS.REVISE_VAL_AMT,0) >( select NVL(RTLNMS2.REVISE_VAL_AMT,0)
                                                           FROM RETURN_LINE_ITEMS RTLNMS2 
                                                           WHERE RTLNMS2.RTRN_ID=RTLNMS.RTRN_ID
                                                           AND  RTLNMS2.LITM_LINE_ITEM_NBR = '066'
                                                           AND SCHED_NBR='000'
    UNION
    SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd, r1.period_start_date, r1.period_end_Date, r1.amend_ind, r1.return_status, r1.status_date, r1.loctr_nbr,
    rtlnms.sched_nbr, rtlnms.litm_line_item_nbr,
    decode(rtlnms.litm_line_item_nbr, '062',  RTLNMS.REVISE_VAL_AMT)AB_TAXABLE_INCOME,
    decode(rtlnms.litm_line_item_nbr, '066',  RTLNMS.REVISE_VAL_AMT)AMT_TAXABLE_IN_AB
    from returns r1, return_line_items rtlnms
    where r1.id = rtlnms.rtrn_id
    AND r1.prog_program_cd = rtlnms.prog_program_cd
    AND r1.entp_abn = rtlnms.entp_abn
    AND r1.id > 3600000 AND r1.prog_program_cd = '01'
    AND r1.return_status in ('ASSESSED', 'DU')
    and r1.period_end_Date between to_date('01-01-2009','DD-mm-YYYY') and to_date ('31-12-2009', 'DD-mm-YYYY')
    and r1.status_date = (select max (status_date) from returns r2 where r2. acct_id= r1.acct_id and r2.period_end_date = r1.period_end_date)
    and rtlnms.sched_nbr = '000'
    and rtlnms.active_ind = 'Y'
    and r1.id in (4117092,3715944,4382179,3691435)
    and RTLNMS.LITM_LINE_ITEM_NBR IN('066')
    and NVL(RTLNMS.REVISE_VAL_AMT,0) <( select NVL(RTLNMS2.REVISE_VAL_AMT,0)
                                                           FROM RETURN_LINE_ITEMS RTLNMS2 
                                                           WHERE RTLNMS2.RTRN_ID=RTLNMS.RTRN_ID
                                                           AND  RTLNMS2.LITM_LINE_ITEM_NBR = '062'
                                                           and  NVL(RTLNMS2.REVISE_VAL_AMT,0)>500000
                                                           AND SCHED_NBR='000'
    order by IDHowever there is another condition after "5c" i.e. after Retain the return only if (ab_taxable_income > 500,000) and (amt_taxable_in_ab < ab_taxable_income)
    and that is:
    For those returns meeting the criteria in step 5, also retrieve the following from RETURN_LINE_ITEMS table and that is:
    sched_nbr = '000' and Litm_line_item_nbr = '029' and ACTIVE_IND ='Y', get Revise_val_amt as "corp_type"
    and in order to go about this, I utilised the following query:
    SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd, r1.period_start_date, r1.period_end_Date, r1.amend_ind, r1.return_status, r1.status_date, r1.loctr_nbr,
    rtlnms.sched_nbr, rtlnms.litm_line_item_nbr,
    decode(rtlnms.litm_line_item_nbr, '062',  RTLNMS.REVISE_VAL_AMT)AB_TAXABLE_INCOME,
    decode(rtlnms.litm_line_item_nbr, '066',  RTLNMS.REVISE_VAL_AMT)AMT_TAXABLE_IN_AB,
    decode(rtlnms.litm_line_item_nbr, '029',  RTLNMS.REVISE_VAL_AMT)CORP_INCOME
    from returns r1, return_line_items rtlnms
    where
    r1.id = rtlnms.rtrn_id and
    r1.prog_program_cd = rtlnms.prog_program_cd and
    r1.entp_abn = rtlnms.entp_abn and
    r1.id > 3600000 AND r1.prog_program_cd = '01' AND r1.return_status in ('ASSESSED', 'DU')
    and r1.period_end_Date between to_date('01-01-2009','DD-mm-YYYY') and to_date ('31-12-2009', 'DD-mm-YYYY')
    and r1.status_date = (select max (status_date) from returns r2 where r2. acct_id= r1.acct_id and r2.period_end_date = r1.period_end_date)
    and rtlnms.sched_nbr = '000'
    and rtlnms.active_ind = 'Y'
    and r1.id in (4117092,3715944,4382179,3691435)
    and RTLNMS.LITM_LINE_ITEM_NBR IN('062')
    AND nvl(decode(litm_line_item_nbr, '062',  REVISE_VAL_AMT),0) > 500000
    and NVL(RTLNMS.REVISE_VAL_AMT,0) >( select NVL(RTLNMS2.REVISE_VAL_AMT,0)
                                                           FROM RETURN_LINE_ITEMS RTLNMS2 
                                                           WHERE RTLNMS2.RTRN_ID=RTLNMS.RTRN_ID
                                                           AND  RTLNMS2.LITM_LINE_ITEM_NBR IN( '066')
                                                           AND SCHED_NBR='000'
    UNION
    SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd, r1.period_start_date, r1.period_end_Date, r1.amend_ind, r1.return_status, r1.status_date, r1.loctr_nbr,
    rtlnms.sched_nbr, rtlnms.litm_line_item_nbr,
    decode(rtlnms.litm_line_item_nbr, '062',  RTLNMS.REVISE_VAL_AMT)AB_TAXABLE_INCOME,
    decode(rtlnms.litm_line_item_nbr, '066',  RTLNMS.REVISE_VAL_AMT)AMT_TAXABLE_IN_AB,
    decode(rtlnms.litm_line_item_nbr, '029',  RTLNMS.REVISE_VAL_AMT)CORP_INCOME
    from returns r1, return_line_items rtlnms
    where r1.id = rtlnms.rtrn_id
    AND r1.prog_program_cd = rtlnms.prog_program_cd
    AND r1.entp_abn = rtlnms.entp_abn
    AND r1.id > 3600000 AND r1.prog_program_cd = '01'
    AND r1.return_status in ('ASSESSED', 'DU')
    and r1.period_end_Date between to_date('01-01-2009','DD-mm-YYYY') and to_date ('31-12-2009', 'DD-mm-YYYY')
    and r1.status_date = (select max (status_date) from returns r2 where r2. acct_id= r1.acct_id and r2.period_end_date = r1.period_end_date)
    and rtlnms.sched_nbr = '000'
    and rtlnms.active_ind = 'Y'
    and r1.id in (4117092,3715944,4382179,3691435)
    and RTLNMS.LITM_LINE_ITEM_NBR IN('066','029')
    and NVL(RTLNMS.REVISE_VAL_AMT,0) <  ( select NVL(RTLNMS2.REVISE_VAL_AMT,0)
                                                           FROM RETURN_LINE_ITEMS RTLNMS2 
                                                           WHERE RTLNMS2.RTRN_ID=RTLNMS.RTRN_ID
                                                           AND  RTLNMS2.LITM_LINE_ITEM_NBR='062'
                                                           and  NVL(RTLNMS2.REVISE_VAL_AMT,0)>500000
                                                             AND SCHED_NBR='000'
    order by ID                                                          
    My output is: 7 rows i.e.
    3 rows of return id = 3715944,
    3 rows of return id = 4117092
    and 1 row of return id = 4382179
    It should only retrieve rows for 3715944 and 4117092; not for row =4382179 and this is because based on question in 5 "c", rows retrieved were for return ids' = 3715944 and 4117092
    I know where the problem is:
    As soon as it retrieves rows for returns 3715944 and 4117092 (because REVISE_VAL_AMT is greater than 500,000), it also finds another record with return id = 4382179 with greater than 500,000 and it blindly brings that as well.
    Is there a way around to ensure that I my results are compared only against the return id's retrieved from 5 "c" = 3715944 and 4117092
    Believe me I have tried every option that I could think of to remove return id = 4382179 but somehow could not.
    Dear Gurus @ OTN, please help me.
    Thanks,
    Sandeep

    Thanks for your words of wisdom guys. Appreciate it.
    Anyways what ever I asked, I was able to get solution for it by using an inline query and it's as follows:
    SELECT id, entp_abn, acct_id, prog_program_cd, period_start_date,                 
             period_end_date, amend_ind, return_status, status_date, loctr_nbr,           
             ab_taxable_income, amt_taxable_in_ab                                         
    FROM   (SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd,                
                  r1.period_start_date, r1.period_end_date, r1.amend_ind,                    
                  r1.return_status, r1.status_date, r1.loctr_nbr,                            
                  SUM                                                                        
                    (DECODE                                                                  
                   (rtlnms.litm_line_item_nbr,                                                  
                    '062', rtlnms.revise_val_amt)) ab_taxable_income,                           
                  SUM                                                                        
                    (DECODE                                                                  
                   (rtlnms.litm_line_item_nbr,                                                  
                    '066', rtlnms.revise_val_amt)) amt_taxable_in_ab                            
              FROM   returns r1, return_line_items rtlnms                                 
              WHERE  r1.id = rtlnms.rtrn_id                                               
              AND    r1.id > 3600000                                                      
              AND    r1.prog_program_cd = '01'                                            
              AND    r1.return_status IN ('ASSESSED', 'DU')                               
              AND    r1.period_end_date BETWEEN                                           
                  TO_DATE ('01-01-2009', 'DD-MM-YYYY') AND                                   
                  TO_DATE ('31-12-2009', 'DD-MM-YYYY')                                       
              AND    rtlnms.sched_nbr = '000'                                             
              AND    rtlnms.active_ind = 'Y'                                              
              AND    r1.status_date =                                                     
                  (SELECT MAX (status_date)                                                  
                   FROM   returns r2                                                         
                   WHERE  r2. acct_id= r1.acct_id                                            
                   AND    r2.period_end_date = r1.period_end_date)                           
              GROUP  BY r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd,               
                     r1.period_start_date, r1.period_end_date, r1.amend_ind,                 
                     r1.return_status, r1.status_date, r1.loctr_nbr)                         
    WHERE  ab_taxable_income > 500000                                                 
    AND    amt_taxable_in_ab < ab_taxable_income                                      
    ORDER  BY id                                                                      
    *OUTPUT*
            ID   ENTP_ABN    ACCT_ID PR PERIOD_ST PERIOD_EN A RETURN_STATU STATUS_DA  LOCTR_NBR AB_TAXABLE_INCOME AMT_TAXABLE_IN_AB
       3715944  401377197     139048 01 01-FEB-08 31-JAN-09 N ASSESSED     30-APR-09 6045574495           1069336              1000
       4117092  400571410      57794 01 01-JAN-09 31-DEC-09 N ASSESSED     27-JUL-10 6053117120            790068               790
    2 rows selected.Anyways I am stuck in another issue and that is:
    Based on what I have received above - I have been given a new requirement and that is:
    retrieve the corresponding Schedule 002 data (if exist) from the RETURN_LINE_ITEMS table:
    *•     Sched_nbr = ‘002’, and Litm_line_item_nbr = ‘001’, and Active_ind = ‘Y’, get Revise_val_amt as ‘special_allocation’*
    *•     Sched_nbr = ‘002’, and Litm_line_item_nbr = ‘002’, and Active_ind = ‘Y’, get Revise_val_amt as ‘ab_salaries_wages’*
    So in order to do this, I committed 5 additional rows with schedule number 002 and they are as follows:
    INSERT INTO RETURN_LINE_ITEMS (                
    ID                      ,                      
    RTSC_ID                 ,                      
    RTRN_ID                 ,                      
    SCLI_ID                 ,                      
    LITM_ID                 ,                      
    ENTP_ABN                ,                      
    PROG_PROGRAM_CD         ,                      
    ACCT_OCCURNC_NBR        ,                      
    ACPE_END_DATE           ,                      
    SCHED_NBR               ,                      
    SCHD_VERSION_YR         ,                      
    SCHD_VERSION_NBR        ,                      
    RTSC_OCCUR_NBR          ,                      
    LITM_LINE_ITEM_NBR      ,                      
    SLIN_LINE_ITEM_ID       ,                      
    OCCUR_NBR               ,                      
    PREV_VAL_MOD_IND        ,                      
    VIABLE_IND              ,                      
    ACTIVE_IND              ,                      
    ACTION_CD               ,                      
    PREV_VAL_AMT            ,                      
    REVISE_VAL_AMT          ,                      
    PREV_VAL_TEXT           ,                      
    REVISE_VAL_TEXT         ,                      
    DISPLAY_SEQ_NBR         ,                      
    SYS_VAL_AMT             ,                      
    LITM_INNER_PASS_SEQ_NBR                        
    VALUES                                         
    626121,                                        
    118320,                                        
    3715944,                                       
    NULL,                                          
    2322,                                          
    401377197,                                     
    '01',                                          
    1,                                             
    TO_DATE('1/31/2009', 'mm/dd/yyyy'),            
    '002',                                         
    1981,                                          
    1,                                             
    1,                                             
    '001',                                         
    78,                                            
    1,                                             
    'N',                                           
    'Y',                                           
    'Y',                                           
    NULL,                                          
    NULL,                                          
    NULL,                                          
    NULL,                                          
    NULL,                                          
    5,                                             
    NULL,                                          
    40                                             
    INSERT INTO RETURN_LINE_ITEMS (                
    ID                      ,                      
    RTSC_ID                 ,                      
    RTRN_ID                 ,                      
    SCLI_ID                 ,                      
    LITM_ID                 ,                      
    ENTP_ABN                ,                      
    PROG_PROGRAM_CD         ,                      
    ACCT_OCCURNC_NBR        ,                      
    ACPE_END_DATE           ,                      
    SCHED_NBR               ,                      
    SCHD_VERSION_YR         ,                      
    SCHD_VERSION_NBR        ,                      
    RTSC_OCCUR_NBR          ,                      
    LITM_LINE_ITEM_NBR      ,                      
    SLIN_LINE_ITEM_ID       ,                      
    OCCUR_NBR               ,                      
    PREV_VAL_MOD_IND        ,                      
    VIABLE_IND              ,                      
    ACTIVE_IND              ,                      
    ACTION_CD               ,                      
    PREV_VAL_AMT            ,                      
    REVISE_VAL_AMT          ,                      
    PREV_VAL_TEXT           ,                      
    REVISE_VAL_TEXT         ,                      
    DISPLAY_SEQ_NBR         ,                      
    SYS_VAL_AMT             ,                      
    LITM_INNER_PASS_SEQ_NBR                        
    VALUES                                         
    626121,                                        
    118320,                                        
    3715944,                                       
    NULL,                                          
    2322,                                          
    401377197,                                     
    '01',                                          
    1,                                             
    TO_DATE('1/31/2009', 'mm/dd/yyyy'),            
    '002',                                         
    1981,                                          
    1,                                             
    1,                                             
    '002',                                         
    78,                                            
    1,                                             
    'N',                                           
    'Y',                                           
    'Y',                                           
    NULL,                                          
    NULL,                                          
    NULL,                                          
    NULL,                                          
    NULL,                                          
    5,                                             
    NULL,                                          
    40                                             
    INSERT INTO RETURN_LINE_ITEMS (                
    ID                      ,                      
    RTSC_ID                 ,                      
    RTRN_ID                 ,                      
    SCLI_ID                 ,                      
    LITM_ID                 ,                      
    ENTP_ABN                ,                      
    PROG_PROGRAM_CD         ,                      
    ACCT_OCCURNC_NBR        ,                      
    ACPE_END_DATE           ,                      
    SCHED_NBR               ,                      
    SCHD_VERSION_YR         ,                      
    SCHD_VERSION_NBR        ,                      
    RTSC_OCCUR_NBR          ,                      
    LITM_LINE_ITEM_NBR      ,                      
    SLIN_LINE_ITEM_ID       ,                      
    OCCUR_NBR               ,                      
    PREV_VAL_MOD_IND        ,                      
    VIABLE_IND              ,                      
    ACTIVE_IND              ,                      
    ACTION_CD               ,                      
    PREV_VAL_AMT            ,                      
    REVISE_VAL_AMT          ,                      
    PREV_VAL_TEXT           ,                      
    REVISE_VAL_TEXT         ,                      
    DISPLAY_SEQ_NBR         ,                      
    SYS_VAL_AMT             ,                      
    LITM_INNER_PASS_SEQ_NBR                        
    VALUES                                         
    626121,                                        
    118320,                                        
    3715944,                                       
    NULL,                                          
    2322,                                          
    401377197,                                     
    '01',                                          
    1,                                             
    TO_DATE('1/31/2009', 'mm/dd/yyyy'),            
    '002',                                         
    1981,                                          
    1,                                             
    1,                                             
    '004',                                         
    78,                                            
    1,                                             
    'N',                                           
    'Y',                                           
    'Y',                                           
    NULL,                                          
    NULL,                                          
    NULL,                                          
    NULL,                                          
    NULL,                                          
    5,                                             
    NULL,                                          
    40                                             
    INSERT INTO RETURN_LINE_ITEMS (                
    ID                      ,                      
    RTSC_ID                 ,                      
    RTRN_ID                 ,                      
    SCLI_ID                 ,                      
    LITM_ID                 ,                      
    ENTP_ABN                ,                      
    PROG_PROGRAM_CD         ,                      
    ACCT_OCCURNC_NBR        ,                      
    ACPE_END_DATE           ,                      
    SCHED_NBR               ,                      
    SCHD_VERSION_YR         ,                      
    SCHD_VERSION_NBR        ,                      
    RTSC_OCCUR_NBR          ,                      
    LITM_LINE_ITEM_NBR      ,                      
    SLIN_LINE_ITEM_ID       ,                      
    OCCUR_NBR               ,                      
    PREV_VAL_MOD_IND        ,                      
    VIABLE_IND              ,                      
    ACTIVE_IND              ,                      
    ACTION_CD               ,                      
    PREV_VAL_AMT            ,                      
    REVISE_VAL_AMT          ,                      
    PREV_VAL_TEXT           ,                      
    REVISE_VAL_TEXT         ,                      
    DISPLAY_SEQ_NBR         ,                      
    SYS_VAL_AMT             ,                      
    LITM_INNER_PASS_SEQ_NBR                        
    VALUES                                         
    626121,                                        
    118320,                                        
    3715944,                                       
    NULL,                                          
    2322,                                          
    401377197,                                     
    '01',                                          
    1,                                             
    TO_DATE('1/31/2009', 'mm/dd/yyyy'),            
    '002',                                         
    1981,                                          
    1,                                             
    1,                                             
    '006',                                         
    78,                                            
    1,                                             
    'N',                                           
    'Y',                                           
    'Y',                                           
    NULL,                                          
    NULL,                                          
    NULL,                                          
    NULL,                                          
    NULL,                                          
    5,                                             
    NULL,                                          
    40                                             
    INSERT INTO RETURN_LINE_ITEMS (                
    ID                      ,                      
    RTSC_ID                 ,                      
    RTRN_ID                 ,                      
    SCLI_ID                 ,                      
    LITM_ID                 ,                      
    ENTP_ABN                ,                      
    PROG_PROGRAM_CD         ,                      
    ACCT_OCCURNC_NBR        ,                      
    ACPE_END_DATE           ,                      
    SCHED_NBR               ,                      
    SCHD_VERSION_YR         ,                      
    SCHD_VERSION_NBR        ,                      
    RTSC_OCCUR_NBR          ,                      
    LITM_LINE_ITEM_NBR      ,                      
    SLIN_LINE_ITEM_ID       ,                      
    OCCUR_NBR               ,                      
    PREV_VAL_MOD_IND        ,                      
    VIABLE_IND              ,                      
    ACTIVE_IND              ,                      
    ACTION_CD               ,                      
    PREV_VAL_AMT            ,                      
    REVISE_VAL_AMT          ,                      
    PREV_VAL_TEXT           ,                      
    REVISE_VAL_TEXT         ,                      
    DISPLAY_SEQ_NBR         ,                      
    SYS_VAL_AMT             ,                      
    LITM_INNER_PASS_SEQ_NBR                        
    VALUES                                         
    626121,                                        
    118320,                                        
    3715944,                                       
    NULL,                                          
    2322,                                          
    401377197,                                     
    '01',                                          
    1,                                             
    TO_DATE('1/31/2009', 'mm/dd/yyyy'),            
    '002',                                         
    1981,                                          
    1,                                             
    1,                                             
    '008',                                         
    78,                                            
    1,                                             
    'N',                                           
    'Y',                                           
    'Y',                                           
    NULL,                                          
    NULL,                                          
    NULL,                                          
    NULL,                                          
    NULL,                                          
    5,                                             
    NULL,                                          
    40                                             
    );                                              So based on the requirement I ran the following query in the hope that I should see 8 records but unfortunately I saw none, Can any one help again please??? The query is as follows:
    SELECT id, entp_abn, acct_id, prog_program_cd, period_start_date,      
              period_end_date, amend_ind, return_status, status_date, loctr_nbr,         
              ab_taxable_income, amt_taxable_in_ab,
              CORP_INCOME, AB_ALLOC_FACTOR, AB_TAX_PAYABLE,
              special_allocation, ab_salaries_wages
      FROM   (SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd,              
                  r1.period_start_date, r1.period_end_date, r1.amend_ind,                  
                  r1.return_status, r1.status_date, r1.loctr_nbr,            
                  SUM                                                                      
                    (DECODE                                                                
                  (rtlnms.litm_line_item_nbr,                                                
                   '062', rtlnms.revise_val_amt)) ab_taxable_income,                         
                  SUM                                                                      
                    (DECODE                                                                
                  (rtlnms.litm_line_item_nbr,                                                
                   '066', rtlnms.revise_val_amt)) amt_taxable_in_ab,
                     SUM                                                                      
                    (DECODE                                                                
                  (rtlnms.litm_line_item_nbr,                                                
                   '029', rtlnms.revise_val_amt)) CORP_INCOME,
                   SUM                                                                      
                    (DECODE                                                                
                  (rtlnms.litm_line_item_nbr,                                                
                   '065', rtlnms.revise_val_amt)) AB_ALLOC_FACTOR,
                   SUM                                                                      
                    (DECODE                                                                
                  (rtlnms.litm_line_item_nbr,                                                
                   '080', rtlnms.revise_val_amt)) AB_TAX_PAYABLE,
                   SUM                                                                      
                    (DECODE                                                                
                  (rtlnms.litm_line_item_nbr,                                                
                   '001', rtlnms.revise_val_amt)) SPECIAL_ALLOCATION,
                   SUM                                                                      
                    (DECODE                                                                
                  (rtlnms.litm_line_item_nbr,                                                
                   '002', rtlnms.revise_val_amt)) AB_SALARIES_WAGES
                  FROM   returns r1, return_line_items rtlnms                               
               WHERE  r1.id = rtlnms.rtrn_id                                                     
               AND    r1.id > 3600000                                                    
               AND    r1.prog_program_cd = '01'                                          
               AND    r1.return_status IN ('ASSESSED', 'DU')                             
               AND    r1.period_end_date BETWEEN                                         
                  TO_DATE ('01-01-2009', 'DD-MM-YYYY') AND                                 
                  TO_DATE ('31-12-2009', 'DD-MM-YYYY')                                     
               AND    rtlnms.sched_nbr = '000' 
               AND(rtlnms.sched_nbr = '002' and rtlnms.litm_line_item_nbr in ('001','002','004','006','008') )                                        
               AND    rtlnms.active_ind = 'Y' 
               AND    r1.status_date =                                                   
                  (SELECT MAX (status_date)                                                
                   FROM   returns r2                                                       
                   WHERE  r2. acct_id= r1.acct_id                                          
                   AND    r2.period_end_date = r1.period_end_date)          
               GROUP  BY r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd,             
                     r1.period_start_date, r1.period_end_date, r1.amend_ind,               
                     r1.return_status, r1.status_date, r1.loctr_nbr, rtlnms.sched_nbr)
      WHERE  ab_taxable_income > 500000                                               
      AND    amt_taxable_in_ab < ab_taxable_income 
    strangely it's not retrieving any row where as it should have retrieved one row atleast and that is all records pertaining to return_id (return id ) = 3715944
    Can any of the Gurus' please help me out? As said I am really having a bad day on this. Many thanks to any one who can help me see the light today :-)

  • Report with multiple queries

    Hi All,
    I need to develop a report with 5 big queries.. and i need to union these queries based on the parameters passed but we cannot use if condition in the report sql qurey.Also tried to use lexical parameter in the after paraform trigger but it didn't accept lexical parameter as tablename in the query..
    for ex: select * from &w1 is not working.......... (say w1 is lexical parameter)
    please help
    thanx in advance.

    select * from &w1Infact, you can do so, but you have to make sure, that w1 has a valid table-name as default-value. Also, the column-name have to match in all the tables, or you have to alias. And lastly, i strongly suggest not to use SELECT *, but list all the desired columns separately.

  • Oracle10g - Report Builder REFCURSOR queries

    Hello,
    The below link has all the steps to create a report with Ref Cusror queries http://download-east.oracle.com/docs/cd/A97335_02/busint.102/a73172/bawor_re.htm
    My question is in "Program Unit Editor" instead of creating a FUNCTION which returns a single REFCURSOR, is it possible to use a PROCEDURE which has 3 OUT REFCURSORS?
    Thanks

    Hey,
    Since you manipulate the original value of
    ManagedBy0 in your SELECT, the column name will change to
    (No column name). I did a test on my side and look what I get.
    Error : "The Value expression for the text box ‘managedBy0’ refers to the field ‘managedBy0’."
    He search for a variable
    ManagedBy0 in your query but don't find any because there's no name assigned.
    Try to run this query. Add
    AS ManagedBy0 after your REPLACE. 
    select all
    SMS_R_System.Name0,
    REPLACE(SUBSTRING(SMS_R_System.managedBy0,4,CHARINDEX(',OU',SMS_R_System.managedBy0,3)-4),'\,',',') AS ManagedBy0,
    SMS_R_System.description0,
    SMS_G_System_OPERATING_SYSTEM.Caption00,
    SMS_R_System.Resource_Domain_OR_Workgr0,
    SMS_R_System.whenCreated0,
    SMS_R_System.Last_Logon_Timestamp0 from vSMS_R_System AS SMS_R_System INNER JOIN Operating_System_DATA AS SMS_G_System_OPERATING_SYSTEM ON SMS_G_System_OPERATING_SYSTEM.MachineID = SMS_R_System.ItemKey INNER JOIN _RES_COLL_CAS000A9 AS SMS_CM_RES_COLL_CAS000A9 ON SMS_CM_RES_COLL_CAS000A9.MachineID = SMS_R_System.ItemKey
    Let me know.
    Nick Pilon | Blog : System Center Dudes

  • Multiple queries in reports with XSL-FO and without BI Publisher

    Hello,
    I'm trying to find out how to create a complex report in APEX for printing. The report contains multiple queries in different layout, images and static text.
    I don't have the possibility to use BI Publisher and I'm not an XSL-FO expert. However I'm trying to find out if it's possible at all not using BI Publisher.
    I'm having the impression that multiple report queries and layouts in APEX can only be used in combination with BI Publisher. I'd be glad if someone could give me an example of how to do multiple queries and layout in a single report only using XSL-FO.
    Thanks in advance,
    Jan Willem

    Hello,
    I'm trying to find out how to create a complex report in APEX for printing. The report contains multiple queries in different layout, images and static text.
    I don't have the possibility to use BI Publisher and I'm not an XSL-FO expert. However I'm trying to find out if it's possible at all not using BI Publisher.
    I'm having the impression that multiple report queries and layouts in APEX can only be used in combination with BI Publisher. I'd be glad if someone could give me an example of how to do multiple queries and layout in a single report only using XSL-FO.
    Thanks in advance,
    Jan Willem

Maybe you are looking for