How to develop this report/Query that selects records with MAX Value

Hi,
My requirment is to develop a report to show all emp whose policy is going to expire ith in the user selected date intreval...
Emp_ID--App_Date-Policy_Strt_Date--Policy_End_Date--App_Status
101.01.2007---BlankBlank--
NEW   (New application for a Medical Insurance policy raised for employee)
101.01.2007---01.02.200730.05.2007--
COMPLETE (policy issued for emp with strt & end dates)
115.05.2007---01.02.200730.05.2007--
RENEWAL  (a application is raised to renew emp policy)
115.05.2007---01.06.200731.12.2007--
COMPLETE  (policy issued for emp with strt & end dates)
115.12.2007---01.06.200731.12.2007--
RENEWAL  (a application is raised to renew emp policy)
115.12.2007---01.01.200831.05.2008--
COMPLETE  (policy issued for emp with strt & end dates)
115.05.2008---01.01.200831.05.2008--
RENEWAL  (a application is raised to renew emp policy)
115.05.2008---01.06.200831.05.2009--
COMPLETE  (a application is raised to renew emp policy)
So EMP 1 got valid policy untill 31.05.2009.
When a user executes a query to show all employees whose policy expiry date intreval (01.05.2008 to 31.05.2008)
it shouldn't show Emp 1 as he got  valid policy untill 31.05.2009  but currently it is showing Emp 1....
How can i achieve this
Thanks

Hi
Thanks for the update
I created variable on Plc End end
If user enter show all emps whose policy is expiring in MAY (01.05.2008---31.05.2008) it is displaying EMp 1 as well but emp 1 has a policy which expires in 2009
Thanks

Similar Messages

  • Query to get row with max values for distinct

    I have a table test with ID, ADID, MTMST columns.
    ID     ----ADID----     MTMST
    1     ----100----     24-MAR-12 08.17.09.000000 PM
    1     ----101----     24-MAR-12 08.18.15.000000 PM
    1     ----102----     24-MAR-12 08.18.56.000000 PM
    2     ----103----     24-MAR-12 08.19.21.000000 PM
    2     ----104----     24-MAR-12 08.19.36.000000 PM
    2     ----105----     24-MAR-12 08.19.46.000000 PM
    3     ----99----      22-MAR-12 09.48.22.000000 PM
    I need the rows with max ADID for each ID.
    I used the following query but it provided max ADID of the table but not the distinct ID
    select * from test where ADID in (select max(ADID) from test where id in (select distinct(id) from test where mtmst > sysdate -1))
    Result:*
    ID     ----ADID----     MTMST
    2     ----105----     24-MAR-12 08.19.46.000000 PM
    Expected result:*
    ID     ----ADID----     MTMST
    1     ----102----     24-MAR-12 08.18.56.000000 PM
    2     ----105----     24-MAR-12 08.19.46.000000 PM
    Thanks,
    Dheepan
    Edited by: Dheepan on Mar 24, 2012 9:53 AM

    select id, adid, mtmst from test where (id, adid) in (select id, max(adid) from test group by id) and MTMST>sysdate-1
    is the answer.

  • How to call the same query more than once with different selection criteria

    Hi,
    Please do anybody know how to solve this issue? I need to call one query with the fixed structure more than once with different selection criteria. For example. I have following data
    Sales organization XX
                         Income 2008  Income 2009
    Customer A       10                 20
    Customer B        30                  0
    Sales organization YY
                         Income 2008  Income 2009
    Customer A        20                5
    Customer B        50                10
    Now, I need this. At the selection screen of query, user fill variable  charakteristic "Sales organization" with interval  XX - YY, than I need to generate two separate results per sales organization, one for Sales Organization XX and the second for SO YYwhich will be displayed each on separate page, where result for SO YY will be dispayed under result for SO YY. Are there some options how to do it for example in Report Designer or WAD or with programming? In Report Designer is possible to use one query more than once, but I dont know how to force each query in RD to display result only for one Sales Organization, which will be defined in selection screen.
    Thank you very much
    J.

    Hello,
    thanks to all for cooperation. Finally we solved this issue with the following way..
    User fill appropriate SO on the selection screen, which is defined as range. This will resulte, that selected SO are listed in report below each othe (standard behavior). Required solution we achieved with the Report Designer, we set page break under each Result row of RD. This caused, that report is divided into required part per SO, which are stated each on separate page.
    J.

  • How to develop a report with current price &  the last price in the pre.yrs

    hi ,
    guys,
    my client want a report to list of material with respective vendor and to make a price comparison betn the current price & the last price in the privious year.
    can any one help how to develop the report, shall go for generic extrc.
    thanks in advace.
    ramnath

    CR CR 2011 / "Crystal reports For Visual Studio 2010", you are correct.
    Re. the database thinggy. You can connect to a database via ODBC, OLE DB or in some instances natively. Once a report is created you an change the datasource. A good sample app on how to do this is  csharp_win_dbengine / vb_win_dbengine. A link to the samples is here:
    Crystal Reports for .NET SDK Samples - Business Intelligence (BusinessObjects) - SCN Wiki
    More info on connecting to dbs and changing them is in the developer help files:
    SAP Crystal Reports .NET SDK Developer Guide
    SAP Crystal Reports .NET API Guide
    More info on CR APIs for .NET (applies to all versions of CR and VS):
    Crystal Reports for Visual Studio 2005 Walkthro... | SCN
    You can also use ADO .NET Datasets and in this way you handle the database connections in your app. A good sample is csharp_win_adodotnet (also available in VB) - same link as above.
    More info on datasets:
    Crystal Reports Guide To ADO.NET
    Crystal Reports for Visual Studio .NET - Walkthrough - Reporting Off ADO.NET Datasets
    For more complicated operations (e.g.; changing a report from ODBC to OLE DB, changing one table, etc., you will want to use the InProc RAS SDK that is also available in CRVS. Developer help files are here:
    Report Application Server .NET SDK Developer Guide
    Report Application Server .NET API Guide
    Sample apps are here:
    NET RAS SDK Samples - Business Intelligence (BusinessObjects) - SCN Wiki
    and here:
    Crystal Reports .NET In Process RAS (Unmanaged) SDK Sample Applications
    More info on RAS SDK:
    How to Use The RAS SDK .NET With In-Process RAS Server
    Lastly, do use the search box in the top right corner. I find simple search strings such as 'crystal net parameter' return best results (KBAs, Blogs, docs, wikis, discussions and more).
    - Ludek

  • How to develop a report

    Hi,
              How to Develope a report that displays a purchase requisition with details like MRP controller, release date and unit of measure.

    HI,
    Just create an internal table with fields PR number, MRP controller, Release date and UNit of measure.
    Now write a select statement as below.
    Select BANFN DISPO FRGDT MEINS from EBAN into table ITAB
               where.......
    Regards,
    Ram

  • How to execute this SQL Query in ABAP Program.

    Hi,
    I have a string which is the SQL Query.
    How to execute this sql Query (SQL_STR) in ABAP Program.
    Code:-
    DATA: SQL_STR type string.
    SQL_STR = 'select * from spfli.'.
    Thanks in Advance,
    Vinay

    Hi Vinay
    Here is a sample to dynamically generate a subroutine-pool having your SQL and calling it.
    REPORT dynamic_sql_example .
    DATA: BEGIN OF gt_itab OCCURS 1 ,
    line(80) TYPE c ,
    END OF gt_itab .
    DATA gt_restab TYPE .... .
    DATA gv_name(30) TYPE c .
    DATA gv_err(120) TYPE c .
    START-OF-SELECTION .
    gt_itab-line = 'REPORT generated_sql .' .
    APPEND gt_itab .
    gt_itab-line = 'FORM exec_sql CHANGING et_table . ' .
    APPEND gt_itab .
    gt_itab-line = SQL_STR .
    APPEND gt_itab .
    gt_itab-line = 'ENDFORM.' .
    APPEND gt_itab .
    GENERATE SUBROUTINE POOL gt_itab NAME gv_name MESSAGE gv_err .
    PERFORM exec_sql IN PROGRAM (gv_name) CHANGING gt_restab
    IF FOUND .
    WRITE:/ gv_err .
    LOOP AT gt_result .
    WRITE:/ .... .
    ENDLOOP .
    *--Serdar

  • Generic report query that will work against common table ..

    Context
    We have a custom audit log scheme that inserts all table changes into a backing table via triggers. For example, an insert into table ORDER would cause a insert into ORDER_AUD.
    Problem
    We want to build a generic report query that will work against any audit table.
    While constructing a report query for a class that uses inheritance, we see TopLink? add an extra where-clause.
    We are required to set the ReferenceClass? for the query, however, the tables we are querying are not mapped to TopLink?. We just want to map the query results to objects of the Reference Class.
    The extra where-clause specifies the table of the Reference Class, but since that table is not in the From clause, the query doesn't work.
    The ReportQuery? in Question
    public DatabaseQuery loadAuditHistory(Class cls, String audTableName ) {
    String emanAuditTableName = "eman_audit";
    ExpressionBuilder expressionBuilder = new ExpressionBuilder();
    Expression exp = expressionBuilder.getTable(audTableName)
    .getField("instance_id")
    .equal(expressionBuilder.getParameter("instanceId"))
    .and(expressionBuilder.getTable(audTableName).getField("audit_id")
    .equal(expressionBuilder.getTable(emanAuditTableName).getField("audit_id")));
    ReportQuery query = new ReportQuery(expressionBuilder);
    query.setReferenceClass(cls);
    query.setSelectionCriteria(exp);
    query.addArgument("instanceId");
    query.addAttribute("Changed By", expressionBuilder.getTable(emanAuditTableName).getField("audit_user"));
    query.addAttribute("Host", expressionBuilder.getTable(emanAuditTableName).getField("audit_host"));
    query.addAttribute("UTC Timestamp", expressionBuilder.getTable(emanAuditTableName).getField("audit_utc_timestamp"));
    query.addAttribute("Action", expressionBuilder.getTable(audTableName).getField("table_action_code"));
    Descriptor orderDescriptor = session.getDescriptor(cls);
    Vector mappings = orderDescriptor.getMappings();
    for (Iterator iter = mappings.iterator(); iter.hasNext();) {
    Object element = (Object) iter.next();
    if (element instanceof DirectToFieldMapping) {
    DirectToFieldMapping mapping = (DirectToFieldMapping)element;
    DatabaseField field = mapping.getField();
    String tableName = field.getTableName();
    String fieldName = field.getName();
    query.addAttribute(fieldName, expressionBuilder.getTable(audTableName).getField(fieldName));
    Expression version = expressionBuilder.getTable(audTableName).getField("version_id");
    query.addOrdering(version.descending());
    query.setName(GET_AUDIT_HISTORY);
    return query;
    Code Generated by the ReportQuery?
    SELECT t0.audit_user, t0.audit_host, t0.audit_utc_timestamp,
    t1.table_action_code, t1.INSTANCE_ID, t1.STATUS,
    t1.REQUESTER, t1.DESCRIPTION, t1.RECIPIENT
    FROM eman_audit t0, example_order_aud t1
    WHERE (((t1.instance_id = 60432)
    AND (t1.audit_id = t0.audit_id))
    AND (EXAMPLE_ORDER.CLASS_NAME = 'eman.infra.toplink.example.project.model.Order'))
    ORDER BY t1.version_id DESC
    Descriptor used to Map Oder.class
    public Descriptor buildOrderItemDescriptor() {
    Descriptor descriptor = new Descriptor();
    descriptor.setJavaClass(eman.infra.toplink.example.project.model.OrderItem.class);
    descriptor.addTableName("ORDERITEM");
    descriptor.addPrimaryKeyFieldName("ORDERITEM.INSTANCE_ID");
    // Inheritance properties.
    descriptor.getInheritancePolicy().setClassIndicatorFieldName("ORDERITEM.CLASS_NAME");
    descriptor.getInheritancePolicy().useClassNameAsIndicator();
    // Descriptor properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteSoftCacheWeakIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("ORDERITEM.INSTANCE_ID");
    descriptor.setSequenceNumberName("CIM_ID");
    VersionLockingPolicy lockingPolicy = new VersionLockingPolicy();
    lockingPolicy.setWriteLockFieldName("ORDERITEM.VERSION_ID");
    descriptor.setOptimisticLockingPolicy(lockingPolicy);
    descriptor.setAlias("OrderItem");
    // Query manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    //Named Queries
    // Event manager.
    // Mappings.
    DirectToFieldMapping instanceIdMapping = new DirectToFieldMapping();
    instanceIdMapping.setAttributeName("instanceId");
    instanceIdMapping.setFieldName("ORDERITEM.INSTANCE_ID");
    descriptor.addMapping(instanceIdMapping);
    DirectToFieldMapping ItemNumberMapping = new DirectToFieldMapping();
    ItemNumberMapping.setAttributeName("ItemNumber");
    ItemNumberMapping.setFieldName("ORDERITEM.ITEM_NUMBER");
    descriptor.addMapping(ItemNumberMapping);
    DirectToFieldMapping QuantityMapping = new DirectToFieldMapping();
    QuantityMapping.setAttributeName("Quantity");
    QuantityMapping.setFieldName("ORDERITEM.QUANTITY");
    descriptor.addMapping(QuantityMapping);
    OneToOneMapping orderMapping = new OneToOneMapping();
    orderMapping.setAttributeName("order");
    orderMapping.setReferenceClass(eman.infra.toplink.example.project.model.Order.class);
    orderMapping.setRelationshipPartnerAttributeName("orderItems");
    orderMapping.dontUseIndirection();
    orderMapping.addForeignKeyFieldName("ORDERITEM.ORDER_ID", "EXAMPLE_ORDER.INSTANCE_ID");
    descriptor.addMapping(orderMapping);
    return descriptor;

    I'm am very confused as to what you are trying to do, are you trying to query Order objects from the ORDER_AUD historical table instead of the table that the class is mapped to?
    TopLink 10.1.3 (DP3) has built in support for historization, you may wish to investigate this support to allow historical querying of your audit tables.
    In general you cannot use a ReportQuery to do this, a ReportQuery is for querying data from objects based on an object-level criteria. I think that you want to query objects, but just using different SQL than the descriptors are mapped to.
    You could do this through a custom SQL read query,
    i.e.
    ReadAllQuery query = new ReadAllQuery(Order.class);
    query.setSQLString("Select * from ORDER_AUD where INSTANCE_ID = #id");
    query.addArgument("id");
    Vector argumentValues = new Vector(1);
    argumentValues.add(id);
    List objects = (List) session.executeQuery(query, argumentValues);
    As long as the field names in the audit and the original table matched this would work. However if this is a historical table, then I would guess that there might be multiple objects with the same id, so querying these historical objects could confuse the TopLink cache. You could set dontMaintainCache() on the query to avoid this.
    In general you would probably be much better off having two sessions, one with the descriptors mapped to the normal tables, and one with the descriptors mapped to the audit tables. Then you would be able to query both using regular object-level queries.

  • How to Develope a report.

    Hi,
         How to develop a report on inventory and goods movements.

    HI,
    Use the table
    1. MA07 for inventory details ; and
    2. MAM_25_GOODSMOVEMENT_LIST for goods movement list
    select the data as per your functional specs put into an internal table and display it in the output list.
    How you display it and the selections you make in selection-screen is designed as per the tech specs.
    please provide the tech specs,i will design the program for you.
    regards,
    pankaj

  • How to develop a report for display unused materials

    how to develop a report for display unused materials? where can i find them?

    Hi Phani,
    I didnt get what u acually mean by unsued material. These are some sample materail types which u can find in table 'Mara'  field 'Mtart'.
    ABF  Waste                   
    AEM  Samples                 
    BLG  BLG Empties  External   
    BLGA BLGAEmpties  Fixed assets
    CH00 CH Contract Handling    
    COMP Prod. alloc., purchased 
    CONT KANBAN Container        
    COUP Coupons                 
    DIEN Service                 
    DOCU documentary batch       
    ERSA Spare parts             
    FERT Finished product(fert)  
    FGTR Drinks                  
    FHMI Prod. resources/tools   
    FOOD Foods (excl. perishables)
    FRIP Perishables             
    GR01 material type 01        
    GR02 material type 02        
    HALB Semi-finished product   
    HAWA Trading goods           
    HERS Manufacturer parts      
    HIBE Operating supplies      
    IBAU Maintenance assembly    
    INTR Intra material          
    KMAT Configurable material   
    LEER Empties                 
    LEIH Returnable packaging    
    LGUT Empties (retail)        
    MODE Apparel (seasonal)      
    NLAG Non-stock material      
    NOF1 Nonfoods                
    PIPE Pipeline material       
    PLAN Trading goods (planned) 
    etc.
    ex:
    select * from mara where mtart = 'ABF'.
    Regards,
    Kiran B

  • Can someone please tell me on how to modify this code so that I dont have to enter the file name at all?

    Hello
    can someone please tell me how to modify this code so that I dont have to enter the file path at all? When i give the same file path constants to both the read and write VIs I'm getting an error message.
    Attachments:
    read and write.vi ‏11 KB

    Yup use the low level File I/O opening the reference once, and closing it once.  
    As for the path selection you have an unwired input which is the path to use.  Programatically set that and you won't be prompted to select a path.  Usually this is done with a path constant to a folder, then using the Build Path, to set the file name in that folder.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • How to save XL Reporter query

    Hi all,
    Can any one tell me how to save XL Reporter query in SBO.
    regards,
    kumar

    Hello Kumar,
    In the Report Organiser save or move the Report Definition to one of the
    grey folder (e.g. Financials). In order to immediately access the report
    though the 'Modules > Reports' menu, you additionally need to choose
    the option 'File > Update Business One Main Menu'.
    Please let me know if I misunderstood your question.
    Regards,
    Wilma Wang
    SAP Business One Forums Team

  • I need a query that selects the amount of records for each day in a table.

    I need a query that selects the amount of records for each
    day in a table.
    Eg the result would be:
    date 1 14
    date 2 3
    etc
    Any ideas?

    sorted:
    SELECT count([commentID]),convert(varchar, dateAdded, 112)
    FROM COMMENTSgroup by convert(varchar, dateAdded,
    112)

  • How to avoid data repetation when using select statements with innerjoin

    how to avoid data repetation when using select statements with innerjoin.
    thanks in advance,
    satheesh

    you can use a query like this...
      SELECT DISTINCT
             frg~prc_group1                  "Product Group 1
             frg~prc_group2                  "Product Group 2
             frg~prc_group3                  "Product Group 3
             frg~prc_group4                  "Product Group 4
             frg~prc_group5                  "Product Group 5
             prc~product_id                  "Product ID
             txt~short_text                  "Product Description
    UP TO 10 ROWS
    INTO TABLE l_i_data
    FROM
    Joining CRMM_PR_SALESG and
    COMM_PR_FRG_ROD
    crmm_pr_salesg AS frg
    INNER JOIN comm_pr_frg_rod AS prd
    ON frgfrg_guid = prdfragment_guid
    Joining COMM_PRODUCT and
    COMM_PR_FRG_ROD
    INNER JOIN comm_product AS prc
    ON prdproduct_guid = prcproduct_guid
    Joining COMM_PRSHTEXT and
    COMM_PR_FRG_ROD
    INNER JOIN comm_prshtext AS txt
    ON prdproduct_guid = txtproduct_guid
    WHERE frg~prc_group1 IN r_zprc_group1
       AND frg~prc_group2 IN r_zprc_group2
       AND frg~prc_group3 IN r_zprc_group3
       AND frg~prc_group4 IN r_zprc_group4
       AND frg~prc_group5 IN r_zprc_group5.
    reward it it helps
    Edited by: Apan Kumar Motilal on Jun 24, 2008 1:57 PM

  • TS1702 How can I rotate a video that I made with my iPod to the correct orientation?

    How can I rotate a video that I took with my iPod to the correct orientation?  My video is sideways and I can't find a way to make it show correctly.

    See if any of the previous discussions listed on the right side of this page under the heading More Like This help.
    Also you can Google for computer apps that will change the origination of videos.

  • How to use Crystal Reports XI release 2 Preview with Lotus Notes  Scripts ?

    <br />Hi all,<br /><br /> How to use Crystal Reports XI release 2 Preview with Lotus Notes 7 Scripts ?<br /><br /> <br /><br />Thank&#39;s  <br />

    Hi,
    we are using Lotus Notes and Crystal Reports for preview and printing reports from our Lotus Notes Applications. We use the RDC object model. For previewing the reports we export them in an pdf-file and then start the PDF Reader to show the Preview. This works fine.
    But with Crystal Reports > 11 the RDC Object Model is no longer supportet, so we look for another way to preview and print our reports.
    I try to preview a report build with crystal report XI release 2 in my thick client (Lotus Notes) using java reporting component JRC, this report uses an native xml file as datasource. If the datasource is saved with the report everything works fine, but otherwise I have the following error:
    JRCAgent1 detected an exception: javax.xml.namespace.QName: method getPrefix()Ljava/lang/String; not found
    I also tried the .jars from Crystal4Eclipse. Doesn't work. When I use Eclipse to view the report everything works fine. The class QName exitsts in the jaxrpc.jar and in the xbean.jar, but only in the xbean.jar a Methode getPrefix exists.
    This is what we tried:
    Works fine with RDC. Doesn't work with JRC until now.
    Did this help you ?
    Perhaps you con help me with the JRC, because I'm a java newbee so any ideas could be helpful.
    Oliver
    <p><a href="http://www.cominform.de">www.cominform.de</a></p>

Maybe you are looking for

  • Open URL Link in new browser window

    Can someone please help me? I've tried to use code as if I were using Dreamweaver without any luck(i.e. blank target). Is there a way to make the url in the PDF open a new browser windows once clicked? Hopefully this is an easy fix! Thanks in advance

  • Issue with Native installer in MAC

    I packaged my application as a dmg file(native installer). But when I tried to install on a mac (Lion OS) it shows that the application is already installed which is not true. When I searched the location of the installed application, it points to th

  • O/s update sizes...for those who'd like to keep count

    i got my both my playbook & ipad2 on the same april 19th day shipped to me. since then the playbook has had shall we say loosely half a dozen o/s updates each 300MB+. and today, voila, i finally had my first ipad o/s update and its 600MB+ & not over-

  • Finding templates not installed in default location, then making them work

    I recently installed Leopard, upgraded it to 10.5.5, then installed a brand new upgrade to Final Cut Studio 2 (and therefore FCP6). I put all the media, templates, etc on an external drive, as the installer prompts you to do if you wish. Fired up FCP

  • FCP won't update to latest version iteration, 5.1.2

    While running software update on my iMac dual core, I noted the automatic download of Final Cut Pro 5.1.2 plus a Motion update. Great... however, on my G5 dual processor, my FCP version is 5.0.4. I run the software update each week, including today,