How to get the seq_num's in descending order of latest begin_date's

Hi
I have this query which gives me an ouput as follows :-
select id,code,begin_date,status_code,seq_num from ABC where id = '0001'
0001 040 20-NOV-97 39 1
0001 040 26-DEC-96 10 2
0001 040 10-APR-96 34 3
0001 040 27-JAN-91 02 4
0001 040 01-NOV-77 01 5
0001 040 22-OCT-77 28 6
But ,
i want the seq_num to be in descending order of latest begin_date for every unique id ? How can i do that
instead of 1 ..it should be 6 since 20-NOV-97 is the latest date for id = 0001 .
pls help ..
Thanks in advance ...

Something like this ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
PL/SQL Release 11.1.0.6.0 - Production
CORE    11.1.0.6.0      Production
TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
Elapsed: 00:00:00.15
satyaki>
satyaki>
satyaki>with abc
  2  as
  3   (
  4     select '0001' id, '040' code, to_date('20-NOV-97','DD-MON-YY') begin_date, '39' status_code, 1 seq_num from dual
  5     union all
  6     select '0001', '040', to_date('26-DEC-96','DD-MON-YY'), '10', 2 from dual
  7     union all
  8     select '0001', '040', to_date('10-APR-96','DD-MON-YY'), '34', 3 from dual
  9     union all
10     select '0001', '040', to_date('27-JAN-91','DD-MON-YY'), '02', 4 from dual
11     union all
12     select '0001', '040', to_date('01-NOV-77','DD-MON-YY'), '01', 5 from dual
13     union all
14     select '0001', '040', to_date('22-OCT-77','DD-MON-YY'), '28', 6 from dual
15   )
16  select id,
17         code,
18         begin_date,
19         status_code,
20         row_number() over(partition by id,code order by begin_date asc)  seq_num
21  from ABC
22  where id = '0001'
23  order by begin_date desc;
ID   COD BEGIN_DAT ST    SEQ_NUM
0001 040 20-NOV-97 39          6
0001 040 26-DEC-96 10          5
0001 040 10-APR-96 34          4
0001 040 27-JAN-91 02          3
0001 040 01-NOV-77 01          2
0001 040 22-OCT-77 28          1
6 rows selected.
Elapsed: 00:00:00.01
satyaki>
satyaki>
satyaki>Regards.
Satyaki De.

Similar Messages

  • How to get the KEY VALUE of sales order

    Hello friends,
                          iam adding a sales order through DI-SERVER to the SAP db.after adding iam getting a key value (i,e Doc no)..i want it to display it in my frontend....can u please tell me how to display the return key value of my sales order
    regards,
    shangai.

    Dear Shangai,
    To retrieve the last Doc/Object added through DI API (DI Server is based on DI API) there is a method called "GetNewObjectCode" which can be used to retrieve the last DocCode which was added into the B1.
    Please try the function for more help please look at the help files RefDI.chm which is installed with the SDK installation for B1.
    Regards
    Arshdeep

  • How to get the finished date of production order

    hi guys
    now i want to get the finished date of production date.  when i search in the table afko , i found the field GLTRI is '0000.00.00'.
    BUT IN the production order display view , the confirm date is '2007.1.1'. so how can i get the confirm date with the production order number? thanks.

    For costing report, you have to read the following tables: based on material Qty/value/ Machine rate and machine posting date , machine rate ( T-code kp26)  and also types of material Raw, finished and semi finished ..
    AFRU ,AFPO,AFKO,AFVV,AFVC,CAUFV FOR PRODUCTION ORDER.
    For material calculation MARA, MSEG and MKPF as well as MAKT...
    Hope this’ll help you .
    Thanks

  • How to get the cost center of production order

    hi guys
    please tell me how i can get the cost center of the production order. 
    thanks.

    You need AUFK-KOSTL ?
    Pole

  • How to get the changed data of an order?

    Hi,
    I'm trying to use BADI ORDER_SAVE to check if the user has changed the status and based on some conditions, I want to avoid saving the order. My problem is that with function moule CRM_READ_ORDER I can only read the "old" (current) information from database, but not the changes in the screen that the user is going to save ...
    How can I get this data?

    Hi,
    You can get the current document data with FM:CRM_ORDER_READ on BAdI:ORDER_SAVE. This FM reads not only DB data but also current data.
    FM:CRM_ORDER_READ reads the document data as follow order.
    1.Buffer data
    2.DB dta
    You can see it on LCRM_ORDERADM_H_DBF03(form orderadm_h_read_with_guid) called by CRM_ORDER_READ.
    If you try to create the order and see the data via CRM_ORDER_READ before saving the order, you can see the data,aren't you? It's the evidence CRM_ORDER_READ reads new buffer data not only DB data.
    Regards,
    Masayuki

  • How to get the list of all process order which are settled?

    Hello Friends,
    Is there any  standard report available to get the list of all settled  Process Order or  Production order?
    Thanking all of you in advance.
    Regards,
    Jitendra

    Hi,
    You can the below standardreports for knowing the list of Settled Process Orders :
    1. Use Tcode : COOIS and in the selection fields provide the Process Order Type, Plant and System Status As " SETT" and execute the same . System will list all the Process Orders which were settled so far.
    2. Use Tcode : CO26 with selection fields as above.
    Hope this will suffice your reqt.
    Regards
    radhak mk

  • How to get the Attachment ID for Service order in CRM

    Hi Guys,
    I need to delete the attachments in Service order; can I use the FM CRM_ICSS_DEL_ATTACH_OF_OBJECT?
    This FM required in Attachment ID as input, could you please any one help me.
    Thanks,
    Gourisankar.

    I have never used this function module before, but looking at the coding, I don't think this will serve your purpose.
    I think it might be better to use method(s) from class CL_CRM_DOCUMENTS.
    Via the GET_INFO method you can retrieve the documents you need and using the DELETE method should delete these object. I did use the GET_INFO method etc. but we haven't deleted any objects. But according to the name of the method, it should DELETE the documents.

  • How to get the Customer detials in Purchase order Ship To Address

    Hi Friends,
    While doing the back-to-back order, when raising the PO, I want populate the Customer Name, Contatct Person and Address in Ship To address box. Can anyone please suggest a good query which can do that. I looking to create a formatted search based pon that.
    Regards
    Shiva

    Shiva,
    You can start with this:
    SELECT T0.CardName, T1.Name, T0.Address2
    FROM ORDR T0 INNER JOIN OCPR T1 ON T0.CntctCode = T1.CntctCode
    WHERE T0.DocEntry = $[POR1.BaseEntry] AND T0.ObjType = $[POR1.BaseType]
    Please bear in mind, it is a FS based on the rows so will run only on row level.
    Regards,
    Nat

  • How to get the path when i select a directory or a file in a JTree

    How to get the path when i select a directory or a file in a JTree

    import java.lang.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.awt.HeadlessException;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Iterator;
    * @author Frederic FOURGEOT
    * @version 1.0
    public class JTreeFolder extends JPanel {
    protected DefaultMutableTreeNode racine;
    JTree tree;
    protected JScrollPane scrollpane;
    final static int MAX_LEVEL = 1; // niveau max de descente "direct" dans l'arborescence
    * Sous-classe FSNode
    * @author Frederic FOURGEOT
    * @version 1.0
    private class FSNode extends DefaultMutableTreeNode {
    File file; // contient le fichier li� au noeud
    * Constructeur non visible
    private FSNode() {
    super();
    * Constructeur par initialisation
    * @param userObject Object
    FSNode(Object userObject) {
    super(userObject);
    * Constructeur par initialisation
    * @param userObject Object
    * @param newFile File
    FSNode(Object userObject, File newFile) {
    super(userObject);
    file = newFile;
    * Definit le fichier lie au noeud
    * @param newFile File
    public void setFile(File newFile) {
    file = newFile;
    * Renvoi le fichier lie au noeud
    * @return File
    public File getFile() {
    return file;
    public JTree getJTree(){
         return tree ;
    * Constructeur
    * @throws HeadlessException
    public JTreeFolder() throws HeadlessException {
    File[] drive;
    tree = new JTree();
    // cr�ation du noeud sup�rieur
    racine = new DefaultMutableTreeNode("Poste de travail");
    // cr�ation d'un noeud pour chaque lecteur
    drive = File.listRoots();
    for (int i = 0 ; i < drive.length ; i++) {
    FSNode node = new FSNode(drive, drive[i]);
    addFolder(drive[i], node); // on descend dans l'arborescence du lecteur jusqu'� MAX_LEVEL
    racine.add(node);
    // Gestion d'evenement sur JTree (on �coute les evenements TreeExpansion)
    tree.addTreeExpansionListener(new TreeExpansionListener() {
    public void treeExpanded(TreeExpansionEvent e) {
    // lorsqu'un noeud est ouvert
    // on descend dans l'arborescence du noeud jusqu'� MAX_LEVEL
    TreePath path = e.getPath();
    FSNode node = (FSNode)path.getLastPathComponent();
    addFolder(node);
    ((DefaultTreeModel)tree.getModel()).reload(node); // on recharche uniquement le noeud
    public void treeCollapsed(TreeExpansionEvent e) {
    // lorsqu'un noeud est referm�
    //RIEN
    // alimentation du JTree
    DefaultTreeModel model = new DefaultTreeModel(racine);
    tree.setModel(model);
         setLayout(null);
    // ajout du JTree au formulaire
    tree.setBounds(0, 0, 240, 290);
    scrollpane = new JScrollPane(tree);
         add(scrollpane);
         scrollpane.setBounds(0, 0, 240, 290);
    * Recuperation des sous-elements d'un repertoire
    * @param driveOrDir
    * @param node
    public void addFolder(File driveOrDir, DefaultMutableTreeNode node) {
    setCursor(new Cursor(3)); // WAIT_CURSOR est DEPRECATED
    addFolder(driveOrDir, node, 0);
    setCursor(new Cursor(0)); // DEFAULT_CURSOR est DEPRECATED
    * Recuperation des sous-elements d'un repertoire
    * (avec niveau pour r�cursivit� et arr�t sur MAX_LEVEL)
    * @param driveOrDir File
    * @param node DefaultMutableTreeNode
    * @param level int
    private void addFolder(File driveOrDir, DefaultMutableTreeNode node, int level) {
    File[] fileList;
    fileList = driveOrDir.listFiles();
    if (fileList != null) {
    sortFiles(fileList); // on tri les elements
    // on ne cherche pas plus loin que le niveau maximal d�finit
    if (level > MAX_LEVEL - 1) {return;}
    // pour chaque �l�ment
    try {
    for (int i = 0; i < fileList.length; i++) {
    // en fonction du type d'�l�ment
    if (fileList[i].isDirectory()) {
    // si c'est un r�pertoire on cr�� un nouveau noeud
    FSNode dir = new FSNode(fileList[i].getName(), fileList[i]);
    node.add(dir);
    // on recherche les �l�ments (r�cursivit�)
    addFolder(fileList[i], dir, ++level);
    if (fileList[i].isFile()) {
    // si c'est un fichier on ajoute l'�l�ment au noeud
    node.add(new FSNode(fileList[i].getName(), fileList[i]));
    catch (NullPointerException e) {
    // rien
    * Recuperation des sous-elements d'un noeud
    * @param node
    public void addFolder(FSNode node) {
    setCursor(new Cursor(3)); // WAIT_CURSOR est DEPRECATED
    for (int i = 0 ; i < node.getChildCount() ; i++) {
    addFolder(((FSNode)node.getChildAt(i)).getFile(), (FSNode)node.getChildAt(i));
    setCursor(new Cursor(0)); // DEFAULT_CURSOR est DEPRECATED
    * Tri une liste de fichier
    * @param listFile
    public void sortFiles(File[] listFile) {
    triRapide(listFile, 0, listFile.length - 1);
    * QuickSort : Partition
    * @param listFile
    * @param deb
    * @param fin
    * @return
    private int partition(File[] listFile, int deb, int fin) {
    int compt = deb;
    File pivot = listFile[deb];
    int i = deb - 1;
    int j = fin + 1;
    while (true) {
    do {
    j--;
    } while (listFile[j].getName().compareToIgnoreCase(pivot.getName()) > 0);
    do {
    i++;
    } while (listFile[i].getName().compareToIgnoreCase(pivot.getName()) < 0);
    if (i < j) {
    echanger(listFile, i, j);
    } else {
    return j;
    * Tri rapide : quick sort
    * @param listFile
    * @param deb
    * @param fin
    private void triRapide(File[] listFile, int deb, int fin) {
    if (deb < fin) {
    int positionPivot = partition(listFile, deb, fin);
    triRapide(listFile, deb, positionPivot);
    triRapide(listFile, positionPivot + 1, fin);
    * QuickSort : echanger
    * @param listFile
    * @param posa
    * @param posb
    private void echanger(File[] listFile, int posa, int posb) {
    File tmpFile = listFile[posa];
    listFile[posa] = listFile[posb];
    listFile[posb] = tmpFile;

  • How to get the pricing hierarchy based on the delivery date for sales order

    Hi,
    How to get the pricing hierarchy based on the delivery date for sales order other than system date.
    My requirement is to get the Pricing hierarchy based on the delivery date other than system date.
    Waiting for kind response.
    Best Regards,
    BDP

    HI Sai,
    please refer teh document already how to write FM based extration on generic extractors.
    and here  the logic to find the latest records values:-
    -> get the data in an internal table
    ->Sort the internal table data based from date descending
    -> Using READ statement , we can read the first record of the table which is nothign but your latest record.
    Regards.
    Sakthi

  • How to get the values from popup window to mainwindow

    HI all,
       I want to get the details from popup window.
          i have three input fields and one search button in my main window. when i click search button it should display popup window.whenever i click on selected row of the popup window table ,values should be visible in my main window input fields.(normal tables)
       now i am able to display popup window with values.How to get the values from popup window now.
       I can anybody explain me clearly.
    Thanks&Regards
    kranthi

    Hi Kranthi,
    Every webdynpro component has a global controller called the component controller which is visible to all other controllers within the component.So whenever you want to share some data in between 2 different views you can just make it a point to use the component controller's context for the same. For your requirement (within your popups view context) you will have have to copy the component controllers context to your view. You then will have to (programmatically) fill this context with your desired data in this popup view. You can then be able to read this context from whichever view you want. I hope that this would have made it clear for you. Am also giving you an [example|http://****************/Tutorials/WebDynproABAP/Modalbox/page1.htm] which you can go through which would give you a perfect understanding of all this. In this example the user has an input field in the main view. The user enters a customer number & presses on a pushbutton. The corresponding sales orders are then displayed in a popup window for the user. The user can then select any sales order & press on a button in the popup. These values would then get copied to the table in the main view.
    Regards,
    Uday

  • How to get the table of value field? and can we expand the technical limits

    Dear
    I have created value field in COPA with KEA6. And now, I need the table which the value fields are saved. Yet, I have tried a lot to find it and get failure? Can any guy help me? Please tell me how to get the table of a value field.
    And another question is that, can we extend the technical limits for the number of value field for ECC6.0?
    We have a note for R.4.x Please see below:
    OSS note 160892
    You can display the length of a data record using Transaction KEA0 ('Maintain Operating Concern'). After you have navigated to the 'Characteristics Screen' or to the 'Value field Screen' choose menu path 'Extras -> Technical Limits'.
    The maximum displayed here under 'Length in bytes on the DB' is the maximum length permitted by the Dictionary. The reserve required for the release upgrade must be subtracted from this value.
    To increase the allowed number of the value fields, increase the value that is assigned to field ikcge-bas_max_cnt (FORM init_ikcge_ke USING fm_subrc, approx. line 165) in Include FKCGNF20. It specifies the number of the possible value fields. The corresponding part of the source code is attached to the note as a correction.
    David Sun
    Regards!

    how to extend the limit of value numbers? please see the original question.

  • I downloaded and bought a movie from iTunes on my iPad and now want the same movie on my MacBook Pro but its not offering me to download it, it giving me the options of buying it which I already did. How I get the movie onto my MacBook?

    I downloaded and bought a movie from iTunes on my iPad and now want the same movie on my MacBook Pro but its not offering me to download it, it giving me the options of buying it which I already did. How I get the movie onto my MacBook?

    You can connect the iPad to your Mac's iTunes and do File > Devices > Transfer Purchases, that should copy it over to the Movies part of your library.
    Depending upon what country that you are in, and whether the film studio allows it, you might also be able to re-download it on your Mac via the Purchased link under Quicklinks on the right-hand side of the iTunes store home page.

  • How to get the value from a JavaScript and send the same to Java file?

    Hi.
    How to get the value from a JavaScript (this JS is called when an action invoked) and send the value from the JS to a Java file?
    Thanks and regards,
    Leslie V

    Yes, I am trying with web application.
    In the below code, a variable 'message' carries the needed info. I would like to send this 'message' variable with the 'request'.
    How to send this 'message' with and to the 'request'?
    Thanks for the help :-)
    The actual JS code is:
    function productdeselection()
    var i=0;
    var j=0;
    var deselectedproduct = new Array(5);
    var message = "Are you sure to delete Product ";
    mvi=document.forms[0].MVI;
    mei=document.forms[0].MEI;
    lpi=document.forms[0].LPI;
    if(null != mvi)
    ++i;
    if(null != mei )
    ++i;
    if(null != lpi)
    ++i;
    if(null != mvi && mvi.checked)
    deselectedproduct[++j]="MVI?";
    if(null != mei && mei.checked)
    deselectedproduct[++j]="GAP?";
    if(null != lpi && lpi.checked)
    deselectedproduct[++j]="LPI?";
    if( 0!=j)
    if(i!=j)
    for (x=0; x<deselectedproduct.length; x++)
    if(null != deselectedproduct[x])
    message =message+ "-" +deselectedproduct[x];
    alert(message);
    else
    //alert(" You cannot remove all products!");
    return false;
    return true;
    }

  • How to get the value from databank

    Hi,
    How to get the value from databank? and how to set the same value to visual script object?
    thanks,
    ra

    Hi,
    You can use GetDatabankValue(HeaderName, Value) to get the value from databank and SetDataBankValue(HeaderName, Value) to set the value to databank.
    You can refer to the API Reference to see list of associated functions and techniques we can use with related to Data Bank.
    This is the for OFT but if you are using Open Script then you have direct access for getting the databank value but when it comes to setting a value you have to use File operation and write you own methods to do the set operation.
    Thanks
    Edited by: Openscript User 100 on Nov 13, 2009 7:01 AM

Maybe you are looking for

  • Ssrs iif expression

    In an ssrs 2008 r2 report, I need to place a 'customer short name' in a detail line when the field has a value in it. When there is no value in the 'customer short name', I am suppose to use the 'customer long name'. Thus can you should me how to set

  • Is it better to sleep your macbook pro 13, or just close it?

    Is it better to put your macbook pro to sleep or just closing the lid?... if you are just leaving for like a 5 minute. Thanks

  • SQL Datamodeler: engineer to relational model: column names

    Hello Suppose I have an attribute called DAY OF BIRTH. Is there a way I can forward engineer this attribute to a column name DAY_OF_BIRTH? (I know you could have a coulmn name "day of birth" but thats not what I want) Regards Erik

  • Why does my xfce4-panel taskbar look like this?

    Why does one task take up the whole bar? It's so ugly!!

  • Printer / Mac OS X Version Upgrade help

    I recently purchased a HP Deskjet 2300 series for my Mac, but the printer wont run on my mac which is v10.2.8. If I upgraded to v10.4 tiger, would my printer be able to operate? Or would I have to upgrade to 10.3 jaguar first?   Mac OS X (10.2.x)