How to sort database record in an Ascending or Descending order

First script below is on Initialize the second on Validate.  I need the database to sort on an ascending order.  I tried using the order by script in RED below to the Validate script but to no avail.  Any help would be greatly appreciated.
$sourceSet.DataConnection2.#command.query.select.nodes.item(0).value = Concat("Select * from brw.ps_m_ee_genl_data Where FULL_NAME = ", Ltrim(Rtrim(SelectField.rawValue)) , " order by FULL_Name asc")
form1.#subform[0].SelectField::initialize - (JavaScript, client)
/* This listbox object will populate two columns with data from a data connection.
sDataConnectionName - name of the data connection to get the data from. Note the data connection will appear in the Data View.
sColHiddenValue - this is the hidden value column of the listbox. Specify the table column name used for populating.
sColDisplayText - this is the display text column of the listbox. Specify the table column name used for populating.
These variables must be assigned for this script to run correctly. Replace <value> with the correct value.
var 
sDataConnectionName = "DataConnection2"; // example - var sDataConnectionName = "MyDataConnection";
var 
sColHiddenValue = "FULL_NAME"; // example - var sColHiddenValue = "MyIndexValue";
var 
sColDisplayText = "EMPLID"; // example - var sColDisplayText = "MyDescription"
// Search for sourceSet node which matchs the DataConnection name
var 
nIndex = 0;
while 
(xfa.sourceSet.nodes.item(nIndex).name != sDataConnectionName){
nIndex
++;}
var 
oDB = xfa.sourceSet.nodes.item(nIndex);oDB.open();
oDB.first();
// Search node with the class name "command"
nIndex
= 0;
while 
(oDB.nodes.item(nIndex).className != "command"){
nIndex
++;}
// Need to set BOF and EOF to stay
oDB.nodes.item(nIndex).query.recordSet.setAttribute("stayBOF"
, "bofAction");oDB.nodes.item(nIndex).query.recordSet.setAttribute("stayEOF"
, "eofAction");
// Search for the record node with the matching Data Connection name
nIndex
= 0;
while 
(xfa.record.nodes.item(nIndex).name != sDataConnectionName){
nIndex
++;}
var 
oRecord = xfa.record.nodes.item(nIndex);
// Find the value node
var 
oValueNode = null;
var 
oTextNode = null;
for 
(var nColIndex = 0; nColIndex < oRecord.nodes.length; nColIndex++){
if(oRecord.nodes.item(nColIndex).name == sColHiddenValue){
oValueNode
= oRecord.nodes.item(nColIndex);}
else if(oRecord.nodes.item(nColIndex).name == sColDisplayText){
oTextNode
= oRecord.nodes.item(nColIndex);}
while 
(!oDB.isEOF()){
this.addItem(oValueNode.value
, oValueNode.value); 
//IDList.addItem(oValueNode.value, oTextNode.value);
oDB.next();
// Close connection
oDB.close();
form1.#subform[0].SelectField::validate - (FormCalc, client)
 if  (Len(Ltrim(Rtrim(SelectField.rawValue))) > 0) then
 //Change the commandType from TABLE to TEXT. TEXT is the equivalent of SQL Property
$sourceSet.DataConnection2.#command.query.commandType= "text" 
//Set the Select Node. Select in this case will be whatever the SQL Property you want.
$sourceSet.DataConnection2.#command.query.select.nodes.item(0).value= Concat("Select * from brw.ps_m_ee_genl_data Where FULL_NAME = ", Ltrim(Rtrim(SelectField.rawValue)) , "") 
//Reopen the Dataconnection
$sourceSet.DataConnection2.open()endif

This is in Mavericks, but I think it also applies to the Finder in Lion.
View menu / Arrange by / Name.

Similar Messages

  • How to output database record in .doc format?

    Good day to all of you! I want to output the database records to a formatted .doc document.For example,
    Here are the db records:
    firstname mid lastname age
    ryan g gomez 23
    shiela m vanilla 21
    and the created document will be a .doc file, which will be formatted with image etc...
    +"File for the first record let's say RyanGomez.doc"+
    h4. Company Logo || Company Name
    h4. -------------------------------------------------------------------------------------------------------
    First Name: Ryan Middle Intial:G Last Name:Gomez
    +"and a separate file for the second format.. and so on...til all the records are created"+
    h4. Company Logo || Company Name
    h4. -------------------------------------------------------------------------------------------------------
    First Name:Shiela Middle Intial:A Lastname:Vanilla
    I know that I need Bufferedwriter/reader or printwriter but I'm having a problem on how to format or edit the output ...any help regarding this?
    I have tried using iText but I think it can only output pdf file...I need a doc output file.

    try {
            // Create a statement
            Statement stmt = connection.createStatement();
            // Prepare a statement to insert a record
            String sql = "DELETE FROM my_table WHERE col_string='a string'";
            // Execute the delete statement
            int deleteCount = stmt.executeUpdate(sql);
            // deleteCount contains the number of deleted rows
            // Use a prepared statement to delete
            // Prepare a statement to delete a record
            sql = "DELETE FROM my_table WHERE col_string=?";
            PreparedStatement pstmt = connection.prepareStatement(sql);
            // Set the value
            pstmt.setString(1, "a string");
            deleteCount = pstmt.executeUpdate();
            System.err.println(e.getMessage());

  • How to sort  the arry value in ascending order

    I have a string array where i need to sort the below values in ascending order in the same format...can anyone give me clue on this?
    9.3
    3.1
    9.1
    19.1
    19
    9.4
    9.1.1
    the sorted order should be
    3.1
    9.1
    9.1.1
    9.3
    9.4
    19
    19.1

    You may have easier luck writing your own comparator for this. These are headings in a table of contents, right?
    Write a comparator that tokenizes a string on the '.' character, or use a StringBuffer to remove them, and then order the elements according to the combined numbers. Since alphanumeric would order this list as you want it anyway you could just order that way once the '.' are removed.
    In other words your comparator would do this in the "compare" method:
    public class MyComparator implements Comparator, java.io.Serializable {
    private static Comparator stringComparator = java.text.Collator.getInstance();
    ...constructor(s), your own private "instance" variable of type MyComparator, a getInstance() method of your own, yadda yadda...
    public int compare(Object item1, Object item2) {
    try {
    value1 = removePeriods((String)item1);
    value2 = removePeriods((String)item2);
    if (value1 == null) {
    return (value2 == null) ? 0 : (-1);
    return compare(value1, value2);
    } catch (ClassCastException cce) {
    System.err.println("Wrong Object Type, JackAss!");
    protected int compare(String str1, String str2) {
    return MyComparator.stringComparator.compare(str1, str2);
    private String removePeriods(String value) {
    StringBuffer sb = new StringBuffer(value);
    int decimalIndex = value.indexOf('.');
    while (decimalIndex != -1) {
    sb.delete(decimalIndex, (decimalIndex + 1));
    }

  • Sorting Database record results

    Hello,
    I have a cfm that outputs a table and populates it with
    records of the database. Using the following query:
    As you can see from the SQL, the query can read url
    parameters like such:
    "index.cfm?eng=MC&month=4&year=2007&destino=EXTRANJERO&submit=Submit+Query"
    and output the records that fit the criteria.
    Now my problem is everytime I try to sort by any of this
    headers
    <a href="index.cfm?sort=#IIF(sort is 19, '20',
    '19')#"> the server will forget allt he other search
    parameters within the url.
    How do I preserve the other url parameters before sorting?
    Also, if someone could plz point me in the direction of
    another site with a great CF community I would appreciate it.
    Thanks

    One option is to parse the CGI.QUERY_STRING (ie a string of
    all url variables) and grab all of the parameters except "sort".
    Then append those parameters to your header. Possibly something
    like this
    <cfset newQueryString = reReplaceNoCase(CGI.QUERY_STRING,
    "&*sort=[^&]*", "", "all")>
    <a href="index.cfm?sort=#IIF(sort is 19, '20',
    '19')#&#newQueryString#"> ..
    Btw, I would recommend using cfqueryparam. Its dangerous to
    use URL variables directly in a query.
    Update: Corrected typo in CGI variable name

  • How to identify database records without using rowid.

    Hello,
    I want to find a way to identify records uniquely in my database without the use of the rowid.
    What I want to do is the following :
    I have a table that contains images. Something like that :
    Table images (id number, image blob).
    Lets say that in this table I have scanned images of persons, invoices and orders.
    I want to be able to associate a record with different records from different tables from my ERP via an association table.
    this table could be :
    Table image_associations (imageid number, rowid_column varchar2(100))
    The "rowid_column" would contain the rowid of the row that is associated with the image.
    The problem is that the rowid is something that changes (for example after export/import).
    So I do not want to use rowid.
    Any ideas?
    Thanks

    What you are saying is you want to avoid theaccepted relational design theory and subvert the
    fundamental principles of very model?
    Yes !!!!Then you are very short sighted and will fail. Why would you want to do this? How is it that you think you are smarter than the forefathers of our industry? an idea so compelling that huge companies have many massive profits implementing the concepts? (sometimes even properly) and how is it that you imagine you can work outside the concepts underlying those tools, within the tool and come to a better solution? this is arrogance surely.
    >
    I think a lot of people use rowid to identify within
    plsql code a record instead of using the table-key.
    There is very limited specific application of the ROWID for temporary reference within known bounds.
    You shouldn't rely on the ROWID. Think about what it actually is: a physical location address hash.
    Don't use it. Just don't.
    As I can remember from my classrooms (a lot of years
    ago) rowid was never mentioned in ER models. Still
    that helps a lot..For very good reason. Rowid is an implementation concept, and not a logical concept.
    Oracle already makes provision at the physical storage level to store BLOBs out of line with a record. You don't need to try to do this at the logical level as I said already.

  • How to display database records in text item

    hello friends,
    I'm using forms6i..
    I have text item named "username" in layout editor.I created this text item from data block wizard..I set Number of items displayed=3 in that wizard..
    In property palette of of "username" i have following changes
    Number of items displayed =3;
    When i click the button named "list_user" it should shows all user names in text item..
    my when-button-pressed trigger code is:
    declare
    cursor c1 is
    select Logid from log1 where logout_date is null;
    begin
    open c1;
    fetch c1 into :username;
    end;
    But my problem is when i run the form only one user displayed in text item..Remaining two text items are having no data..
    The result of the cursor query is :
    SQL> ed
    Wrote file afiedt.buf
    1 select logid from log1 where logout_date is null
    SQL> /
    LOGID
    104
    105
    106
    pls help me
    Edited by: Balraj on Feb 23, 2011 1:45 AM

    I have text item named "username" in layout editor.I created this text item from data block wizard..I set Number of items displayed=3 in that wizard..
    In property palette of of "username" i have following changes
    Number of items displayed =3;Its great that it is working fine, but seems your block is database block based on the same table log1, then why do you want to loop when form has better way.
    Secondly if you have set No of Records for a block then there is no need to set the No of Items displayed for the Item if it is the same as Records displayed for block.
    You can use No of Items displayed for an Item if you need to display no different then no of records else no need to change the default that is 0
    No of items displayed is usually used to display Summary Columns in a multi record block so that you will be able to display just 1 Item rather then as many as the No of records.
    Best Regards
    Arif Khadas

  • Can I turn off grouping by date in Finder and also 'Arrange by' and 'Sort by' in ascending and descending order?

    I am trying to arrange my photostream saved search (which doesn't update automatically after I did the search for the first time which is very annoying) but finder won't let me arrange in ascending order of date (i.e.: oldest to newest). Is there a way I can do this or will my folder arrangements always be the one way without the option to change it to the opposite arrangement (same for alphabetical). Also, Finder automatically arranges my photos into groups of dates (e.g.: 'previous 30 days', 'September'). Is there any way I can turn this off?
    Also if anyone can fix this stupid photostream issue for me that would be great!
    thanks very much 

    Even in list view, the photos are grouped by previous seven days, previous 30 days, October, and so on.. there is no option i see that will let me change to order by date modified without these groupings or to just turn these groupings off altogether
    but thank you for your reply
    -Peelo2311

  • Ascending vs Descending Order in Photoshop

    When I have multiple files open in Photoshop I always have this issue: I will be editing multiple files, and I prefer to work on them in ascending order. However, once I close a file so I can move on to the next one, Photoshop jumps to the last file in the sequence. For example, if I am working on image 001 and close it, I would like Photoshop to automatically go to image 002. Instead, it always goes to image 010. How can I change this?

    Hi Ashok,
    Thanks for your reply. I tried the option given by you that is changing the definition of the info object from Text to Key and loaded the data accordingly. But when I run the report, I could see no changes in the sheet as before. But when I put this info object in the first column, I mean I changed the order of the info objects in the query designer then it worked for only first column but not for any other columns. I just wonder why it is happening, is there any way to find out what should be the order as I have followed the order given by the functional guys in their requirement? I tried with deifferent positions but it is working for only the first column.
    Please reply...

  • How to sort Invoices through Personalization!!

    Dear All,
    Kindly give me some solutions about how to sort invoices on GL date through personalization?
    Please reply urgently!!
    Regards,
    Younus

    Hi,
    you try like this..
    with the help "Folder Tools",
    1)move the "GL date" column into first position.
    2)Goto "Folder" menu, then select "Sort" submenu
    3)then select ascending or descending order.
    check it and update the status
    regards
    mahes

  • How to delete a database record by using EJB entity beans

    Hi, All,
    Does anyone know how to use entity bean to delete a database record? I have all the EJB entity beans created, including access beans to each. I can successfully create records, find and update records, however, I haven't find a way to delete records yet.
    Your response is appreciated.
    Cathy

    Please see EJB Forums for continue discussion on this subject.
    Reference titile: "how to delete database record by using CMP entity beans "

  • Problem in sorting the records

    Hi All,
    I have to sort some records based on a key. If the key field is optional then how to sort the records. For example consider the follwing records.
    <row>
          <name>jaya</name>
          <address>hyd</address>
          <material>d</material>
          <units>4</units>
          <price>6</price>
    </row>
      <row>
          <address>ss</address>
          <material>wd</material>
          <units>7</units>
          <price>9</price>
       </row>
    <row>
          <name>radha</name>
          <address>pune</address>
          <material>g</material>
          <units>9</units>
          <price>3</price>
    </row>
    Here name field is used as a key in sorting the records. in the second record name field does'nt exists. All the records that doesnt have the name field shud come on the top and the rest with name field shud come sorted.
    Can anyone please helpout how to solve this problem??

    Jhansi,
    Did u solved the issue? The scenario is lil bit complicated, please consider my below suggestion, if you haven't achieved your results.
    I must really thankful to Michal and all my SDN friends,who guided me to use the logic-using multiple Mapping program in one Interface mapping.
    /people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping
    Ok, let us come to the logic.
    For your problem we need to use two mapping programs.
    <b>Mapping Program 1</b>
    http://www.flickr.com/photo_zoom.gne?id=897495319&size=o
    <b>Mapping Program 2</b>
    http://www.flickr.com/photo_zoom.gne?id=897495327&size=o
    http://www.flickr.com/photo_zoom.gne?id=897495341&size=o
    <b>UDF1 - Testing</b>
    http://www.flickr.com/photo_zoom.gne?id=897495429&size=o
    String temp;
    for(int i=0;i<Name.length;i++)
    for(int j=i1;j<Name.length;j+)
    if(Name<b>[</b>i<b>]</b>.compareToIgnoreCase(Name[j])>0)
               temp = Name<b>[</b>i<b>]</b>;
                Name<b>[</b>i<b>]</b>= Name[j];
                Name[j]=temp;
    for(int i=0;i<Name.length;i++)
    if(Name<b>[</b>i<b>]</b>.equals("0"))
    result.addSuppress();
    result.addContextChange();
    else
    result.addValue(""Name<b>[</b>i<b>]</b>"");
    result.addContextChange();
    <b>UDF 2 - Testin1</b>
    http://www.flickr.com/photo_zoom.gne?id=897495437&size=o
    String temp,temp1;
    for(int i=0;i<Name.length;i++)
    for(int j=i1;j<Name.length;j+)
    if(Name<b>[</b>i<b>]</b>.compareToIgnoreCase(Name[j])>0)
               temp = Name<b>[</b>i<b>]</b>;
                Name<b>[</b>i<b>]</b>= Name[j];
                Name[j]=temp;
          temp = Values<b>[</b>i<b>]</b>;
                Values<b>[</b>i<b>]</b>= Values[j];
                Values[j]=temp;
    for(int i=0;i<Values.length;i++)
    result.addValue(""Values<b>[</b>i<b>]</b>"");
    result.addContextChange();
    <b>Interface Mapping</b>
    http://www.flickr.com/photo_zoom.gne?id=897495361&size=o
    <b>Finally -Results:</b>
    http://www.flickr.com/photo_zoom.gne?id=897498639&size=o (My Data)
    http://www.flickr.com/photo_zoom.gne?id=897498659&size=o (Your Data)
    I hope it helps you!!!!
    I don't know whether this is the correct way or any other simplest way to do so. Also I request our friends to feedback their inpute regarding this logic.
    Jhansi,if you have any doubts in achieving the same, kindly reply back.
    Best regards,
    raj.

  • Implementing database records through Trees

    I am having a problem regarding trees.. Can anyone send me the code ,how to implement records from the Database through trees.. i m using JDBC. Please let me know soon .. and send me the syntax aswell..
    Bye.. Thankssss

    Since I am using CMP Entity Beans, I would like to use CMP/BMP facilities to delete
    the Entity EJB instances (perhaps database rows) instead of taking a different
    approach just for deletion.
    Thanks anyway for your response.
    William Kemp <[email protected]> wrote:
    Perhaps a stateless session bean that does some jdbc to remove the records?
    You could
    call it from anywhere, servlet, client side, entity bean....
    With some sql something like:
    "delete from table where column = criteria"
    Bill
    Satya wrote:
    I am using CMP for the entity beans in our project and I have a questionregarding
    remove.
    How to remove database records?
    I know one solution which is to find the records by EJB finder methodand call
    remove() in each entity bean instace.
    Is there any other way to remove the records, for example I want toremove a bunch
    of records based on a criteria in one shot.
    Thanks in advance for your suggestion.

  • Using JavaScript need to Sort subsite site collection based on date in descending order

    Hi,
    Below is my code, where i need to sort the " webCollection
    = web.getSubwebsForCurrentUser(null)" web collection based on the web.get_created() in
    descending order. How could i do it any suggestions. Also i need it in JavaScript.
    <script src="/_layouts/15/sp.runtime.js" type="text/javascript"></script>
    <script src="/_layouts/15/SP.js"></script>
    <script type="text/javascript">
    var context = SP.ClientContext.get_current();
    var web = context.get_web();
    ExecuteOrDelayUntilScriptLoaded(getWebProperties, "sp.js");
        function getWebProperties() {
                    webCollection = web.getSubwebsForCurrentUser(null);
            context.load(webCollection)
            //ctx.load(this.web);
            context.executeQueryAsync(Function.createDelegate(this, this.onSuccess),
                Function.createDelegate(this, this.onFail));
        function onSuccess(sender, args) {
            //alert('web title:' + this.web.get_title() + '\n ID:' + this.web.get_id()
    + '\n Created Date:' + this.web.get_created());
            alert("Number of sites: " + webCollection.get_count());
                   var webEnumerator = webCollection.getEnumerator();
                    while (webEnumerator.moveNext()){
       var web = webEnumerator.get_current();
      alert("Title="+web.get_title() +"\n"+ "Created="+web.get_created());
        function onFail(sender, args) {
            alert('failed to get list. Error:'+args.get_message());
    //getWebProperties();
    </script>
    Thanks!
    MCTS- Please vote and mark posts as answered where appropriate.

    Hi,
    According to your post, my understanding is that you wanted to sort the subsite based on the date in descending order.
    You can refer to the following code snippets, it sorts the subsites by the date in descending order.
    <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    // When the body is loaded, the onload event handler executes each function whose name is contained in this array.
    _spBodyOnLoadFunctionNames.push("callCSOM");
    function callCSOM()
    $("#Button1").click(function()
    ExecuteOrDelayUntilScriptLoaded(RetriveSites, "sp.js");
    var currentcontext = null;
    var currentweb = null;
    function RetriveSites()
    currentcontext = new SP.ClientContext.get_current();
    currentweb = currentcontext.get_web();
    this.subsites = currentweb.get_webs();
    currentcontext.load(this.subsites);
    currentcontext.executeQueryAsync(Function.createDelegate(this, this.ExecuteOnSuccess),
    Function.createDelegate(this, this.ExecuteOnFailure));
    function ExecuteOnSuccess(sender, args)
    var subsites = '';
    var enum1 = this.subsites.getEnumerator();
    var siteCreatedTime = '';
    var array=new Array();
    while (enum1.moveNext())
    var site = enum1.get_current();
    array.push(new Array(site.get_created(),site.get_title()));
    alert(array);
    array=sortMethod(array);
    alert(array);
    function sortMethod(arr) {
    var i, j, stop, len = arr.length;
    for (i=0; i<len; i=i+1)
    for (j=1;j<len - i; j++)
    // change the "<" to ">" would be sort by the Ascending.
    if (new Date(arr[j-1][0]) < new Date(arr[j][0]))
    //swap(j, j+1);
    var temp = arr[j-1];
    arr[j-1] = arr[j];
    arr[j] = temp;
    //alert(new Date(arr[j]));
    return arr;
    function ExecuteOnFailure(sender, args) {
    alert("error");
    </script>
    <input id="Button1" type="button" value="Run Code"/>
    Results:
    Sort before:
    Sort after:
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected].
    Jason Guo
    TechNet Community Support

  • Sorting a two dimensional array in descending order..

    Guy's I'm a beginning Java programmer. I've been struggling with finding documentation on sorting a two dimensional primitive array in descending order.. The following is my code which goes works, in ascending order. How do I modify it to make the list write out in descending order?
    class EmployeeTable
         public static void main(String[] args)
         int[][] hours = {
              {2, 4, 3, 4, 5, 8, 8},
              {7, 3, 4, 3, 3, 4, 4},
              {3, 3, 4, 3, 3, 2, 2},
              {9, 3, 4, 7, 3, 4, 1},
              {3, 5, 4, 3, 6, 3, 8},
              {3, 4, 4, 6, 3, 4, 4},
              {3, 7, 4, 8, 3, 8, 4},
              {6, 3, 5, 9, 2, 7, 9}};
         int [] total = new int [hours.length];
         for (int i = 0; i < hours.length ; i++){
              for (int j = 0; j < hours.length ; j++){
                   total[i] += hours[i][j];
         int[] index = new int[hours.length];
         sortIndex(total, index);
    for (int i = 0; i < hours.length; i++)
    System.out.println("Employee " + index[i] + " hours are: " +
    total[i]);
    static void sortIndex(int[] list, int[] indexList) {
    int currentMax;
    int currentMaxIndex;
    for (int i = 0; i < indexList.length; i++)
    indexList[i] = i;
    for (int i = list.length - 1; i >= 1; i--) {
    currentMax = list[i];
    currentMaxIndex = i;
    for (int j = i - 1; j >= 0; j--) {
    if (currentMax < list[j]) {
    currentMax = list[j];
    currentMaxIndex = j;
    // How do I make it go in descending order????
    if (currentMaxIndex != i) {
    list[currentMaxIndex] = list[i];
    list[i] = currentMax;
    int temp = indexList[i];
    indexList[i] = indexList[currentMaxIndex];
    indexList[currentMaxIndex] = temp;

    Bodie21 wrote:
    nclow all you wrote was
    "This looks to me like a homework assignment that you're asking us to solve for you. Your description of what it does isn't even correct. It doesn't sort a 2d array.
    You would probably elicit better help if you could demonstrate that you've done some work and have something specific that you don't understand."
    To me that sounds completely sarcastic. You didn't mention anything constructive besides that.. Hence I called you a male phalic organ, not a rear exit...Bodie21, OK, now you've got 90% of us who regularly contribute to this forum thinking your the pr&#105;ck. Is that what you wanted to do? If so, mission accomplished. Many will be looking for your name next time you ask for help. Rude enough for you?

  • Mix Ascending and Descending in SQL

    I am very new to Oracle and SQL, but I am very curious if one can sort by mixing both ascending and descending orders within a single SELECT statement.
    I have been trying to figure out why this would even be needed, but I'm certain that there are unique circumstances where one would want this capability.

    SQL> select rank() over (order by a1 asc) "ASC",
      2     rank() over (order by a1 desc) "DESC"
      3  from test_asc_desc
      4  order by a1 asc;
           ASC       DESC
             1          6
             2          5
             3          4
             4          3
             5          2
             6          1
    6 rows selected.
    SQL> select row_number() over (order by a1 asc) "ASC",
      2     row_number() over (order by a1 desc) "DESC"
      3  from test_asc_desc
      4  order by a1 asc;
           ASC       DESC
             1          6
             2          5
             3          4
             4          3
             5          2
             6          1
    6 rows selected.

Maybe you are looking for