Query by date for mulipitle rows

I need to select only the latest order_id for each customer irrespective of location and wherever the loc_type is M then we might have different orders on differenr dates .
CUST_ID     SID     ORDER_ID is the primary key .
CUST_ID     SID     ORDER_ID     LOC     DATE          LOC_TYPE
A0000     1000     AA11          IND     08/25/2012     M
A0000 1000     AA12          JPN     08/24/2012     M
B0000     0777     BB23          IND     08/24/2013     M
D0000     0345     DD11          IND     08/24/2012 -
the o/p should be like
CUST_ID     SID     ORDER_ID     LOC     DATE          LOC_TYPE
A0000     1000     AA11          IND     08/25/2012     M
B0000     0777     BB23          IND     08/24/2013     M
D0000     0345     DD11          IND     08/24/2012 -

Using dense_rank analytical function..
WITH tmp AS
        (SELECT 'A0000' CUST_ID,
                '1000' SID,
                'AA11' ORDER_ID,
                'IND' LOC,
                '08/25/2012' Dt,
                'M' LOC_TYPE
           FROM DUAL
         UNION ALL
         SELECT 'A0000',
                '1000',
                'AA12',
                'JPN',
                '08/24/2012',
                'M'
           FROM DUAL
         UNION ALL
         SELECT 'B0000',
                '0777',
                'BB23',
                'IND',
                '08/24/2013',
                'M'
           FROM DUAL
         UNION ALL
         SELECT 'D0000',
                '0345',
                'DD11',
                'IND',
                '08/24/2012',
           FROM DUAL),
     tmp1 AS
        (SELECT a.*,
                DENSE_RANK ()
                OVER (PARTITION BY cust_id
                      ORDER BY TO_DATE (dt, 'MM/DD/YYYY') DESC)
                   rnk
           FROM tmp a)
SELECT cust_id,
       sid,
       order_id,
       loc,
       dt,
       loc_type
  FROM tmp1
WHERE 1 = 1 AND rnk = 1;output :
CUST_ID SID ORDER_ID LOC DATE LOC_TYPE
A0000 1000 AA11 IND 08/25/2012 M
B0000 0777 BB23 IND 08/24/2013 M
D0000 0345 DD11 IND 08/24/2012 -Cheers,
Manik.

Similar Messages

  • Query picking data for the running request

    Hi Guyz,
    Am working on BW 3.5,
    We run a query on a Multicube on daily basis, the scenario here is when we ran a query during one of the infocube load which was not activated and not ready for reporting (Request for reporting available symbol is missing), even then the query picked data for the request which was still running.
    Cheers!
    Ravi
    Edited by: Ravi Srinivas on Aug 18, 2009 1:20 PM

    Good to know that your doubts are cleared...
    For more information browse through SDN and have a look at these notes:
    Note 411725 - Questions regarding transactional InfoCubes
    Note 1063466 - Transactional request is not set to qualok
    Hope it helps...
    Regards,
    Ashish

  • Error in receiving tableview data for selected row

    Hi Collegues ,
    We plan to realize an application for the maintanance of  planning data . In the first step we created a value help page by using a tableview with iterator class ( 1 of the 3 methods of the Interface was filled with logic ) . We don't use any controller for that application  .
    A global internal table with the relevant help value data ( fgrvalues ) is used for the tableview and the call is :
    TYPE I .
    +CLASS CL_HTMLB_MANAGER DEFINITION LOAD.
    CLEAR ONCLICKEVENT.
    IF EVENT_ID = CL_HTMLB_MANAGER=>EVENT_ID.
        EVENT_DATA = CL_HTMLB_MANAGER=>GET_EVENT( REQUEST ).
        IF ( EVENT_DATA IS NOT INITIAL ) AND
                ( EVENT_DATA->EVENT_TYPE = 'click' ) .
                ONCLICKEVENT = EVENT_DATA->SERVER_EVENT .
        ENDIF.
    ENDIF.+
    CASE ONCLICKEVENT.
    WHEN 'take' .
       TABLE ?= CL_HTMLB_MANAGER=>GET_DATA( REQUEST = REQUEST
       NAME = 'tableView'
       ID = 'fgr1_vhelp' ) .
       TABLE_EVENT = TABLE->DATA.
       IF TABLE_EVENT->SELECTEDROWINDEX IS NOT INITIAL.
          ROWSELECTION = TABLE_EVENT->SELECTEDROWINDEX.  
    -> ROWSELECTION - Content is now the index of the selected tableview row
    We always get the selected row in TABLE_EVENT->SELECTEDROWINDEX and the table TABLE_EVENT->ALLCOLUMNNAMES filled ( column ZX_FGR1 is the 2nd column ) 
    but we never got the tableview data for that tableview row no matter what we tried . We tried it with a tableview-event fired on 'rowselection' by user line-selection . We have deactivated the iterator or changed the BPS design value . With the same result - nothing was given back .
    We found that the System-Call Return value of :
    +system-call ict
    did
    ihttp_scid_get_form_field
    parameters
    m_c_msg " > c handle
    name " > form field name                value " < form field value
                    m_last_error. " < return code+
    in the method IF_HTTP_ENTITY~GET_FORM_FIELD is empty .  M_LAST_ERROR occurs with value '20' .
      + ASSIGN ROWSELECTION TO .
    COLUMN_VALUE = TABLE_EVENT->GET_CELL_VALUE( ROW_INDEX =
    COLUMN_INDEX = '2' ). -> Column Value is empty !!+
       +CALL METHOD TABLE_EVENT->GET_CELL_VALUE
          EXPORTING
            ROW_INDEX = TABLE_EVENT->SELECTEDROWINDEX
            COLUMN_INDEX = '2'
          RECEIVING
            VALUE = COLUMN_VALUE -> Column Value is empty !!+
       +CALL METHOD TABLE_EVENT->GET_SIMPLE_DATA ....
             -> Column Value is empty !!+ *----
    What could be the reason for that problem ? In generally it must be possible somehow to read the tableview data for one or all rows of the mentioned tableview .
    We hope that someone can help and are very thankful for a hint or solution . If you need more details please let us know .
    Please Remark: It's no solution for us to read the data by using the created internal table fgrvalues and the selectedrowindex cause in a later step we plan to update an ODS table with the manual modified planning data of an editable tableview .
    Thanks a lot in advance
    Dirk Läufer

    Hi collegues ,
    It's done .
    After we've got a very helpful little hint from Brian :
    The <htmlb:tableView> renders a table to the browser. It does not keep a copy of the table. The browser will also never return the table. Never. What it can return are inputfields for each cell. But then only if each cell is custom rendered as an inputfield.
    we could certainly solve the problem .
    We set the field we want to get back from table view on not editable inputfield via the tableview-iterator method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START :
    DATA: LCL_TABLE       TYPE REF TO CL_BSP_BEE_TABLE   ,
          LCL_INPUTFIELD2 TYPE REF TO CL_HTMLB_INPUTFIELD .
    CASE P_COLUMN_KEY .
    WHEN 'ZX_FGR1'.
    *    Field Firm Group
         CREATE OBJECT LCL_INPUTFIELD2.
         LCL_INPUTFIELD2->ID        = P_CELL_ID.
         LCL_INPUTFIELD2->WIDTH     = '100%'.
         LCL_INPUTFIELD2->MAXLENGTH = 4.
         LCL_INPUTFIELD2->TYPE      = 'STRING'.
         LCL_INPUTFIELD2->DESIGN    = 'STANDARD'.
         LCL_INPUTFIELD2->DISABLED  = 'TRUE'.
         LCL_INPUTFIELD2->VALUE =
             GET_COLUMN_VALUE( COLUMN_NAME = 'ZX_FGR1').
         P_REPLACEMENT_BEE     = LCL_INPUTFIELD2 .
    Now the method in OnInputPorcessing:
    TRY.
          CALL METHOD CL_HTMLB_MANAGER=>GET_SIMPLE_DATA
              EXPORTING
                REQUEST       = RUNTIME->SERVER->REQUEST
                ID            = 'fgr1_vhelp'
                ROW_IDX       = TABLE_EVENT->SELECTEDROWINDEX
                COL_NAME      = 'ZX_FGR1'
              CHANGING
                DATA          = FGRVALUES_LINE-ZX_FGR1 .
             IF NOT FGRVALUES_LINE-ZX_FGR1  IS INITIAL.
    *                 selektierte Firmengruppe übernehmen
                      ZX_FGR1     = FGRVALUES_LINE-ZX_FGR1   .
                      CALL METHOD NAVIGATION->SET_PARAMETER
                            EXPORTING NAME  = 'ZX_FGR1'
                                      VALUE = ZX_FGR1.
             ENDIF.
          CATCH CX_SY_CONVERSION_ERROR .
       ENDTRY.
    works properly as it should be ...
    An enormous Thanksgiving to you , Brian !!!!

  • Need a report column to hold data for one row only

    Hey Guys,
    I have a report which has a column that links to another page in my APEX application.
    There is a requirement where only one of the rows in this report needs to have a link so I need the column to show the page link for one row and one row only.
    The report will have about 5 rows at a time so is there a way to just make this link appear for the one row(it will be the top row) in the column attirbute in APEX? or can this be done in the SQL for the report?
    Any help is much appreciated
    Thanks
    -Mark

    Hi
    The only way (I believe) to do this is within the SQL. Then you just wrap the column in a CASE statement and if it meets your criteria then build up the link and if not then display normally.
    Something like this...
    SELECT ename,
           CASE WHEN empno = 7839
           THEN '<a href="f?p='||:APP_ID||':4:'||:APP_SESSION||'::NO::P4_TARGET_ITEM:'||empno||'" >'||empno||'</a>'
           ELSE TO_CHAR(empno)
           END empno
    FROM empCheers
    Ben

  • Cfinclude query: return result for specific row

    I've been trying to crack this all day and I feel like if I
    just had a nudge in the right direction I might be successful.
    I have a query that returns the records for some textbooks
    that are at a specific school. I've normalized the textbook
    database so that the primary, secondary and tertiary subject
    categories are represented by the primary key of that category in
    its own table. As the query loops through the records, I want it to
    return the (varchar) subject category that goes with that
    (numerical) key in the table.
    Since Coldfusion won't allow nested cfoutput, I've tried
    using cfinclude to grab the specific name for the subject category
    that goes with the current textbook - but what I've got so far
    returns all the subjects for the school id in each row - they're
    the right subjects! but I don't want all of them, just the right
    one with the right book/record. Can anyone suggest what I need to
    do? I'm attaching the code for the main page and for one of the
    cfincludes (they're identical except for "primary", "secondary" and
    "tertiary").
    I realize I must be leaving something out but I can't figure
    out what. Thanks much in advance.

    Marianne,
    Glad I could help. To meet your requirement it seems like you
    would add one field to my schema in the Subjects table:
    parentSubjectId number (FK)
    That would simply be a recursive reference to another
    subject's ID to which it falls under. Maybe that doesn't make sense
    so here's some example data:
    subjectId, subjectName, parentSubjectId
    1, "Language Arts", null
    2, "Reading", 1
    3, "Phonics", 2
    4, "Other Subject with no parent", null
    So you can see we have built ourselves a nice hierarchy,
    where subjects which fall under other subjects can reference them.
    When you go to allow subjects to be chosen you can then query after
    each drop-down selection by refreshing the page (or via AJAX) to
    get its subjects. In this case we could also possibly do away with
    the "Ranking" field in our linking table since our hierarchy is
    captured in the relationships we now have, but for the sake of
    making our lives easy, let's keep it.
    Like let's say we select "Language arts" with a subjectId of
    1, we can get its child subjects like:
    <cfquery name="getChildSubjects"
    datasource="#Request.dsn#">
    SELECT s.subjectId, s.subjectName
    FROM subjects s
    WHERE s.parentSubjectId = <cfqueryparam
    cfsqltype="cf_sql_integer" value="#URL.subjectId#" />
    ORDER BY s.subjectName
    </cfquery>
    Obviously, modifications would need to be made to fit your
    schema, variable names, etc. but that's the general principles.
    As for how to associate textbooks to subjects you will
    actually be inserting one record into the linking table for each
    subject selected. So let's say you have a book "XSS for dummies."
    To insert the book you would add a single record in your
    textbook table, maybe something like:
    INSERT INTO textbook (
    textbookId,
    textbookName,
    <!--- Other fields go here, etc... --->
    ) VALUES (
    1,
    'XSS for dummies',
    <!--- Other fields go here, etc... --->
    Now, the user has selected three subjects: Computer Science
    (ID: 5), Internet and Web Topics (ID: 11), and Security (ID:98). We
    will thus insert three records into our linking table like:
    INSERT INTO textbookSubjects (
    textbookId,
    subjectId,
    ranking
    ) VALUES (
    1,
    5,
    'Primary'
    INSERT INTO textbookSubjects (
    textbookId,
    subjectId,
    ranking
    ) VALUES (
    1,
    11,
    'Secondary'
    INSERT INTO textbookSubjects (
    textbookId,
    subjectId,
    ranking
    ) VALUES (
    1,
    98,
    'Tertiary'
    So now when we query to get all our textbooks and related
    subjects, we have something like this:
    SELECT t.textbookId, t.textbookName, s.subjectId,
    s.subjectName, ts.ranking
    FROM textbook t
    LEFT JOIN textbookSubjects ts
    ON t.textbookId = ts.textbookId
    LEFT JOIN subject s
    ON t.subjectId = s.subjectId
    ORDER BY t.textbookName
    An example dataset might look like:
    textbookId, textbookName, subjectId, subjectName, ranking
    1, "XSS for Dummies", 5, "Computer Science", "Primary"
    1, "XSS for Dummies", 11, "Internet and Web Topics",
    "Secondary"
    1, "XSS for Dummies", 98, "Security", "Tertiary"
    2, "Some Other Book With No Subjects", null, null, null
    Now if we iterate over this dataset, you will end up
    outputting the textbook 3 times, which is probably not what you
    wanted. So to control this we can do something like:
    <cfoutput query="myBooks" group="textbookId">
    <tr>
    <td>#myBooks.textbookName#</td>
    <!--- Show all the subjects --->
    <td>
    <!--- These cfoutput tags with no group will give you all
    the values for the current group --->
    <cfoutput>
    #myBooks.subjectName#<br />
    </cfoutput>
    </td>
    </tr>
    </cfoutput>
    These examples are obviously brief but I hope they get the
    point across and help you accomplish what you're trying to
    do.

  • How do you query activity data for accounts?

    I need to extract account activity data. When I try to use the Activity WSDL it doesn't seem to provide any account information even though I do see fields like AccountId, AccountName. They are blank. Also it looks like there is way to do a activity query using the Account WSDL. Does anyone have an example of this?
    We are using Release 18 with V2 WSDL.
    Thank you,
    Dan
    Edited by: dansshin on Oct 14, 2010 2:33 PM

    I'm not sure what you mean by XML string but I'm trying to extract to CSV file using this code. It provides activity data but looks like account information fields are blank.
    Thank you,
    Dan
    private static void ExtractGrowerAccountActivity(String sessionID, String csvFileName)
    try
    // Download the opportunity wsdl from the Admin section of the CRM application
    // Add web reference to the wsdl
    // Create the instance of the account entity
    Activity myAcctAct = new Activity();
    myAcctAct.Url = ConfigurationManager.AppSettings["OnDemandURL"] + "/Services/Integration;jsessionid=" + sessionID;
    // Set the query
    // To find the record with account type as grower
    Activity_WS.queryType myAcctName = new Activity_WS.queryType();
    myAcctName.Value = "";
    // Create query instance and set the appropriate parameters
    Activity_WS.ActivityQuery myAcctActQuery = new Activity_WS.ActivityQuery();
    myAcctActQuery.AccountId = new Activity_WS.queryType();
    myAcctActQuery.AccountName = myAcctName;
    myAcctActQuery.AccountExternalSystemId = new Activity_WS.queryType();
    myAcctActQuery.Id = new Activity_WS.queryType();
    myAcctActQuery.Activity = new Activity_WS.queryType();
    myAcctActQuery.CreatedByFullName = new Activity_WS.queryType();
    myAcctActQuery.CreatedDate = new Activity_WS.queryType();
    myAcctActQuery.DueDate = new Activity_WS.queryType();
    myAcctActQuery.Completed = new Activity_WS.queryType();
    myAcctActQuery.CompletedDatetime = new Activity_WS.queryType();
    myAcctActQuery.Subject = new Activity_WS.queryType();
    myAcctActQuery.Type = new Activity_WS.queryType();
    // Set ListOfAccountQuery
    Activity_WS.ListOfActivityQuery lstOfAcctActQuery = new Activity_WS.ListOfActivityQuery();
    lstOfAcctActQuery.Activity = myAcctActQuery;
    // Number of records to fetch
    lstOfAcctActQuery.pagesize = "100";
    // set ActivityQueryPage_Input
    ActivityQueryPage_Input myActInput = new ActivityQueryPage_Input();
    myActInput.ListOfActivity = lstOfAcctActQuery;
    // Get the output
    ActivityQueryPage_Output myOutput = myAcctAct.ActivityQueryPage(myActInput);
    // Get ListOfAccountData
    Activity_WS.ListOfActivityData myAcctActData = myOutput.ListOfActivity;
    Activity_WS.ActivityData[] acctActData = myAcctActData.Activity;
    // Write to output file
    if (acctActData.Length > 0)
    using (var sw = new StreamWriter(csvFileName))
    // Write header
    sw.WriteLine("AccountID, AccountName, AccountType, ExternalID, ActivityID, ActivityType, CreatedBy, CreatedDate, DueDate, IsCompleted, CompletedDate, Subject, Type");
    for (int i = 0; i < acctActData.Length; i++)
    // Write detail
    sw.WriteLine(string.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}",
    acctActData.AccountId,
    acctActData[i].AccountName,
    "Account Type",
    acctActData[i].AccountExternalSystemId,
    acctActData[i].Id,
    acctActData[i].Activity,
    acctActData[i].CreatedByFullName,
    acctActData[i].CreatedDate,
    acctActData[i].DueDate,
    acctActData[i].Completed == true ? "Y" : "N",
    acctActData[i].CompletedDatetime,
    acctActData[i].Subject,
    acctActData[i].Type));
    // Write to log
    log.Message = string.Format("INFO: {0} Grower account activity record(s) extracted.", acctActData.Length);
    log.Categories.Add(Category.General);
    log.Priority = Priority.Normal;
    writer.Write(log);
    catch (Exception ex)
    log.Message = string.Format("ERROR: " + ex.ToString());
    log.Categories.Add(Category.Error);
    log.Priority = Priority.High;
    writer.Write(log);

  • Bex query-KEY date for time dependent objects

    Hi
    I have one infoobject called 0customer that has one time dependent attribute .called status. I would know how the system works in the following senario for the a given key date(which in bex properties).
    question 1)
    customer todate          fromdate    status
    1            20071231     20070101     Y
    1            20081231     20080101      N
    1            20091231     20081101      X
    can the data in the infoobject be overlapped? is the 3 rd record is  valid in the above example - as months(11&12of2008)  overlapping with second record? ? pls advise
    question 2)
    customer todate          fromdate    status
    1            20071231     20070101     Y
    1            20081231     20080101      N
    1            20091231     20090101      X
    If the keydate is 20080201 which record will it return?would it return the record that has status 'N'?
    what does the keydate is compared against? is it with from date or todate or between fromdate and todate? does the query return only one customer record for a given customer when it runs in the query?
    Please advise.
    Thanks
    Vennela

    1) Normally you cannot activate the data with this constellation. If you have inconsistent master data you can repair with transaction RSRV.
    2) The system returns N for key data 20080201.
    Best regards
    Dirk
    Edited by: Dirk Herzog on Nov 19, 2008 1:16 PM

  • VIDEO_TS meta data for Front Row?

    Front Row in Leopard supports playing VIDEO_TS folders. You can also add cover art by saving a file as preview.jpg in the parent directory. The folder structure would be like the following.
    /Users/fred/Movies/The Day the Earth Stood Still/VIDEO_TS/
    /Users/fred/Movies/The Day the Earth Stood Still/preview.jpg
    /Users/fred/Movies/Cloverfield/VIDEO_TS/
    /Users/fred/Movies/Cloverfield/preview.jpg
    /Users/fred/Movies/Attack of the Killer Tomatoes/VIDEO_TS/
    /Users/fred/Movies/Attack of the Killer Tomatoes/preview.jpg
    This works great, however I was wondering if there is any equivalent method for adding meta-data to VIDEO_TS folders. Obviously you cannot do the normal process of storing it as MPEG4 tags in an MPEG4 video file via iTunes. If it was possible I would presume the most logical method would be to store an XML file in each folder something like this.
    /Users/fred/Movies/The Day the Earth Stood Still/VIDEO_TS/
    /Users/fred/Movies/The Day the Earth Stood Still/preview.jpg
    /Users/fred/Movies/The Day the Earth Stood Still/metadata.xml
    /Users/fred/Movies/Cloverfield/VIDEO_TS/
    /Users/fred/Movies/Cloverfield/preview.jpg
    /Users/fred/Movies/Cloverfield/metadata.xml
    /Users/fred/Movies/Attack of the Killer Tomatoes/VIDEO_TS/
    /Users/fred/Movies/Attack of the Killer Tomatoes/preview.jpg
    /Users/fred/Movies/Attack of the Killer Tomatoes/metadata.xml
    I suspect that unfortunately this is not currently possible but does anyone know for certain?

    Unfortunately it looks like currently there is no way to do it and Apple have been sorely neglecting Front Row (it has fallen well behind even the Apple TV which is far from state of the art). As Snow Leopard is concentrating on performance enhancements rather than new features, I do not hold out hope for any significant change for well over a year.
    Note: Apple TV is not necessarily a bad product, indeed I bought one for my parents, it is merely like Front Row extremely limited, too limited for many people which is why it sales are (allegedly) so poor. I think the comment raised by more than one pundit that it fails to replace a box under your TV is an extremely important one. It does not replace your DVD player (there are still comparatively few movies on the iTunes store - assuming you are in a country which has any at all), the movies are too expensive compared to DVDs and do not offer either as good quality or as many features. It also fails to replace a video recorder or these days a DVR since it has no TV capabilities. As such it has to be treated as an additional box if at all, and as an additional box it increases the spaghetti factor and thus fails the WAF (Wife Acceptance Factor) even if it is by far the easiest to use product.
    I have therefore switched to using Plex which is a Mac version of XBMC. Plex allows you to use VIDEO_TS folders just like Front Row (indeed the same folders can be used in both), but it does have a built-in 'library' which stores meta-data and artwork for these VIDEO_TS folders and any other videos you might have. It uses plugins called 'scrapers' to search sites like http://www.imdb.com for metadata about the movies, I have even written a 'scraper' to search Amazon for those few DVDs not listed on IMDB.
    See http://www.plexapp.com
    Since Plex does an excellent job handling VIDEO_TS (i.e. DVDs) it can 'replace' a box - the DVD player and also means the kiddies do not destroy your fragile discs.
    PS. Horror of horrors, even Microsoft Media Center is 'better' than Front Row. This is practically the only category Microsoft has actually genuinely earned first place in rather than cheating/bribing/stealing/buying its way to.

  • Query XML data for blanks

    Hi 
    I am try to see if there are any blanks in a node of a table that has xml data in one of the columns. The query I use is returning zero results. Any suggestions?
    Select COUNT(*)from ENTITY
    Where CONVERT(XML, Ent_root_xml, 0 ).value('(//UD_PQ_FLAG/node())[1]', 'VARCHAR(50)')= ' '

    This is a little tricky. When you don't use /text(), looking for space is the right thing. But when you use /text() you should look for NULL:
    DECLARE @x TABLE (id int NOT NULL, x xml NOT NULL)
    INSERT @x (id, x)
       VALUES (1, '<ROOT><Node>This node is intentionally not left blank.</Node></ROOT>'),
              (2, '<ROOT><Node></Node></ROOT>')
    SELECT id
    FROM   @x
    CROSS  APPLY x.nodes('/ROOT') AS T(x)
    WHERE  T.x.value('(Node/text())[1]', 'varchar(23)') IS NULL
    SELECT id
    FROM   @x
    CROSS  APPLY x.nodes('/ROOT') AS T(x)
    WHERE  T.x.value('Node[1]', 'varchar(23)') = ' '
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to query the data for required service calls

    Hi Experts,
    I have one requirement in oracle
    I have one table with columns actvy_code, actvy_seq_id, date.
    Data is as follows                    400008    1234431     12/01/2013
                                                 400010    1234431     12/02/2013
                                                 400020    1234431     12/03/2013
                                                 400008    1234431     12/01/2013
                                                 400005    1234431     12/02/2013 etc...!!!
    actvy_id is also containing 5M7, 5M8, 6M6, 4M4, 4M5 some are existed in same date and other codes present with different date.
    Here I want to extract data based on the actvy_code column, say for example in scope I have some actvy_codes like 4M8, 4M5, 5M8 etc..
    when you do select * from table where actvy_code in (4M8, 4M5, 5M8) gives the out put as needed.
    But I want to know whether these codes are present with same date or not. How to do this.
    Please do me this favor..
    regards,
    Sahadeva.

    one thing i forgot to add.
    we shouldnt use ascii values for the special characters.
    means we shouldnt use ascii values for restricting the sspecial characters.
    pls get me the reply as soon as possible
    thanq

  • Problems trying to SUM after returning date on first row in all rows

    Hi,
    I'm having problems with a calculation in a table report.
    We've built a Discoverer report that looks at long term absence of an employee. The long-term absence period must be worked out based on a 2-year rolling period from the start date of the employee's most recent sickness. For example, if i'm off sick and have been since 01-Mar-2009 the report will look at all absences i've had since 01-Mar-2007 and sum the days.
    I have built a calculation that always returns the latest absence start date for every row of absence a person has had. This has been achieved by using a LEAD Function and ROW_NUMBER, see below:
    LEAD(Absence Start Date,ROW_NUMBER() OVER(PARTITION BY Employee Number  ORDER BY  Absence Start Date DESC)-1) OVER(PARTITION BY Employee Number  ORDER BY  Absence Start Date DESC)
    The problem I have is that I cannot SUM the Absence Days of the person and bring in one row per person in the report. I think the cause is the use of the ROW_NUMBER. It ends up returning a Row for every absence the person has had.
    Is there any way I can achieve returning the latest absence start date of a person against all absence rows (in order to use a condition to restrict the report to all absences that started after 2 years prior to that date) that they've had and sum up the absence days so that only one row per person is returned? I cannot use row generators and cannot register PL/SQL functions. I would need to get IT to help me which is min 3 month turnaround, so I'm trying to resolve this quickly.
    Hope you can help.
    Many Thanks,
    Lloyd

    Hi Michael,
    Thanks a lot for this. The calculation you provided fixes the issue. However, The partition part of it seems to cause another.
    In order to calculate total absence days the following calculation is used:
    SUM(CASE WHEN NVL2("Absence (Employee) - Historic"."Date End",( CASE WHEN Absence Finish >= Absence Start THEN "Absence (Employee) - Historic".Absence Days END ),CASE WHEN "Absence (Employee) - Historic".Date Start < Period Start Date THEN WORKING_DAYS_BETWEEN(Period Start Date,Absence Finish) WHEN Absence Finish >= Absence Start THEN WORKING_DAYS_BETWEEN(Absence Start,Absence Finish) END) = 0 THEN DAYS_BETWEEN(Absence Start,Absence Finish) ELSE NVL2("Absence (Employee) - Historic"."Date End",( CASE WHEN Absence Finish >= Absence Start THEN "Absence (Employee) - Historic".Absence Days END ),CASE WHEN Absence Finish >= Absence Start THEN WORKING_DAYS_BETWEEN(Absence Start,Absence Finish) END) END) OVER(PARTITION BY "Person Assignment Information (Person) - Historic".Employee Number ORDER BY "Person Assignment Information (Person) - Historic".Employee Number )
    Here is a little Key:
    Absence Start
    GREATEST("Absence (Employee) - Historic".Date Start,ADD_MONTHS(TRUNC(SYSDATE),-24))
    Absence Finish
    LEAST(NVL("Absence (Employee) - Historic".Date End,TRUNC(SYSDATE)),TRUNC(SYSDATE))
    Period Start Date
    ADD_MONTHS(MAX("Absence (Employee) - Historic".Date Start) OVER(PARTITION BY "Absence (Employee) - Historic".Employee Number ORDER BY "Absence (Employee) - Historic".Date Start DESC ),-24)
    The item Absence Days is the number of days input against the absence by the user. This is only correct for end-dated absences. For people who have open-ended absence or those whose absence start before the period start date (Michael's date) we must work the days out. A function called WORKING_DAYS_BETWEEN achieves this. There is also another function called DAYS_BETWEEN which is all days between two days (weekends included).
    The item Date Start is the absence Start Date, Date End is the Absence End date.
    The whole lot is then summed by Employee number partition.
    The report has lots of indicators that using mathemical equations based ont Total Absence Days. In order to use Total Absence Days in another mathematical calc I have to create a duplicate calculation except without the partition (Total_Absence_Days in this case). If don't and simply insert the name of the calc into another calculation I get this error when running the report.
    Image: !http://www.aerographicsuk.com/Invalid%20Identifier.jpg!
    When creating another mathematical calc I then have to do the Sum partition around it. This makes the report run really slow because i'm typing lots of large formulae every time i build a calc that refers to Total Absence Days.
    Is there a way I can create the total absence days calculation with out causing this error? I have thought about breaking it up into several calculations but am wondering if i'll get the same error message.
    Below is an example of a calculation that tries to use Total Absence Days:
    GREATEST("Full Pay Entitlement (Days)"-SUM(Total_Absence_Days) OVER(PARTITION BY "Absence (Employee) - Historic".Employee Number ORDER BY "Absence (Employee) - Historic".Employee Number ),0)
    Kranthi, I can only paste in the Oracle SQL, which isn't real SQL. There are lots of other calcs though, so they'll probably be a lot there. Please let me know if you'd like to see it.
    Many Thanks for your help with this,
    Lloyd

  • Can't query sql data

    I'm connecting fine to a SQL DB. Used the "help" sample in LS 8.0 help to enter an ID that should query the data for a specific data set. Using "click" and "FormCalc", I get an error. This is my code:
    //Change the commandType from TABLE to TEXT. TEXT
    //is the equivalent of SQL Property
    $sourceSet.DataConnection.#command.query.commandType = numeric
    //Set the Select Node. Select in this case will be
    //whatever SQL Property you want
    $sourceSet.DataConnection.#command.query.select.nodes.item(0).value = Concat(Select*from licenses Where userid = , ListBox1.rawValue,)
    //Reopen the Data connection
    $sourceSet.DataConnection.open()
    I've tried the Javascript version of this, and I get no error, but nothing at all happens.
    Help??

    - Help | About | Version:
    Java(TM) Platform     1.6.0_14
    Oracle IDE     3.1.07.42
    Versioning Support     3.1.07.42
    - Help | About | Properties:
    java.home     C:\Program Files\Java\jdk1.6.0_14\jre
    jdbc.driver.home     /C:/ORACLE/product/10.2.0/client_1/
    jdbc.library     /C:/ORACLE/product/10.2.0/client_1/jdbc/lib/ojdbc6.jar
    - running <sqldevelope>\sqldeveloper\bin\sqldeveloper.exe:
    popup blank console but no msg. in it.
    Thanks for the tips! Yesterday I configured apache tomcat and copied ojdbc into it's
    library, maybe copy wrong folder at that time. I just removed ojdbc6 and keep ojdbc14
    in oracle jdbc library. After it, now the sql developer can start successfully!
    Many thanks!

  • Can I use Concatenate function for multiple rows?

    I have a lead list that contains 5000 leads. The format of this list contains address data that is saved in separate columns (ie: address, address 2, city, state, zip). I need this data in 1 column. I tried to use the concatenate function to combine the data for 1 row and it worked perfectly. I tried to do this for multiple rows and the function is greyed out. Is there a work around or way that I can combine this data for all 5000 rows without doing it 1 by one?

    Look at this table;
    In B9, the formula is;
    =B2&" "&C2&" "&D2&" "&E2&" "&B3&" "&C3&" "&D3&" "&E3
    Yvan KOENIG (VALLAURIS, France) dimanche 18 octobre 2009 20:51:47

  • Calculated fields based on data in multiple rows

    Hi,
    I am using SOA Suite 11.1.1.4 for BAM.
    Can someone please help explain to me if and how we can use calculated fields in BAM data objects where the calculations are not only based on the data for that row, but on multiple rows ?
    Like for example, this case can easily be constructed -->
    TestDataObject Layout
    Column1 integer
    Column2 integer
    Column3 calculated = Column1 + Column2
    But if I want to create something like this -->
    TestDataObject Layout
    Column1 integer
    Column2 integer
    Column3 calculated = max(Column1) + avg(Column2)
    Is it possible to do the above ?
    Is it possible to check multiple rows of the other columns while calculating a value ?
    Thanks & Regards,
    Karan.
    Edited by: user8890668 on Mar 9, 2011 3:58 AM

    Hi, Karan.
    Do you know you can do that in reports with calculated fields?
    I guess it is not possible using calculating functions offered in data objects to do that.
    If you, or anybody, discover how do that, please tell us. I would like to know that.
    Luciano Gomes
    user8890668 wrote:
    Hi,
    I am using SOA Suite 11.1.1.4 for BAM.
    Can someone please help explain to me if and how we can use calculated fields in BAM data objects where the calculations are not only based on the data for that row, but on multiple rows ?
    Like for example, this case can easily be constructed -->
    TestDataObject Layout
    Column1 integer
    Column2 integer
    Column3 calculated = Column1 + Column2
    But if I want to create something like this -->
    TestDataObject Layout
    Column1 integer
    Column2 integer
    Column3 calculated = max(Column1) + avg(Column2)
    Is it possible to do the above ?
    Is it possible to check multiple rows of the other columns while calculating a value ?
    Thanks & Regards,
    Karan.
    Edited by: user8890668 on Mar 9, 2011 3:58 AM

  • How can I do for a row of a query be data provider for a variable?

    Hi friends, I have a problem !
    How can I do for a row of a query be data provider for a variable?
    I need that a value of variable be stored when the user select a row in a query. At the BPS we can do this configuring the variable selector in WIB, and in a WAB how I can do this ?
    Best regards,
    Gustavo Liberado

    In this case when I press the key to call other forms I need to wait for the response in the secondary form and then process the result.That is exactly what a "modal JDialog" (or JOptionPane) are used for.
    Try it. Create a short demo program. All you need is a JFrame with a single button to show the modal dialog. All you modal dialog needs is a single button to close the dialog. After you show the modal dialog add a System.out.println(...) statement in your code and you will see that it is not executed until the dialog is closed.
    Then once you understand the basics you add the code to your real program.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

Maybe you are looking for

  • What do I need to do before giving an old iPhone to someone else?

    I recently upgraded my IPhone from the 3GS to 5.  I have a friend that is interested in using my old phone as an IPod only.  I am assuming I have to remove the sim card so it won't function as a phone.  Is that correct?  Then erase all my content and

  • HT4559 I message not working

    My iMessage is not working. My messages do not show up on my iPad.

  • Deleting a record in an internal table

    hi,   loop at itab,    ..... if a particular record alone matches a condition then that particular record alone has to be deleted. endloop. only the particular record which matches the  condition inside the loop should be deleted. remaining records s

  • Are 17" Non-Unibody MacBook Pro display assemblies interchangeable?

    Hi all, I have a 17" MacBook Pro (A1229) and the steel frame inside the display is bent, so it doesn't open and close reliably. However, I found a 17" display assembly for model A1151 on eBay. Can I use the older display with my newer model?

  • LSMW /RFBIBL00 CO-PA trouble

    Hello All, I try to load P&L account into FI-GL using LSMW and RFBIBL00. For some accounts, I have to load CO-PA charcteristics values. I did it into the mapping and relation structure, but the system doesn't write it. When I do the transaction FB01,