Sort data

How to sort data query result each time one clicks sort
button ...sort by name,date,etc

I did dont work...
=====
<CFQUERY NAME="Rec" DATASOURCE="#EazyVector#">
SELECT ctrData.FACILITY AS Facil,ctrData.CONTRACTNO AS
CONTRACTNO,ctrData.CONTRACTDATE AS
CONTRACTDATE,ctrData.CONTRACTTITLE AS
CONTRACTTITLE,ctrData.DRWPROVIDEBY AS DRWPROVIDEBY,ctrDocs.DRWNO AS
DRWNO,ctrDocs.SHEETNO AS SHEETNO,ctrDocs.CONTRACTNO AS
DocCtrNo,ctrDocs.DRWTYPE AS DRWTYPE,ctrDocs.DISCIPLINE AS
DISCIPLINE,ctrDocs.DRWTITLE AS DRWTITLE,ctrDocs.CONFCADDFILENAME AS
ImageName,ctrDocs.DRWDATE AS DRWDATE ,ctrDocs.DOCID AS
DOCID,ctrLoc.READONLYMEDIAPATH AS READONLYMEDIAPATH,
ctrLoc.CONTRACTNO AS LocCtrNo
FROM CONTRACTS ctrData,CONTRACT_DOCS
ctrDocs,IMGS_LOCATION_FOLDER ctrLoc
WHERE lower(ctrData.CONTRACTNO)=lower(ctrDocs.CONTRACTNO(+))
AND lower(ctrData.CONTRACTNO)=lower(ctrLoc.CONTRACTNO(+))
<CFIF Form.ConTNo NEQ "">
AND lower(ctrData.CONTRACTNO) like lower('%#Form.ConTNo#%')
</CFIF>
<CFIF Form.ConTitle NEQ "">
AND lower(ctrData.CONTRACTTITLE) like
lower('%#Form.ConTitle#%')
</CFIF>
<CFIF #Form.Discipline# NEQ "">
AND lower(ctrDocs.DISCIPLINE) LIKE
lower('%#Form.Discipline#%')
</CFIF>
<CFIF #Form.DrawingNo# NEQ "">
AND lower(ctrDocs.DRWNO) LIKE lower('%#Form.DrawingNo#%')
</CFIF>
<CFIF #Form.Facil# NEQ "">
AND lower(ctrData.FACILITY) LIKE lower('%#Form.Facil#%')
</CFIF>
<CFIF #Form.DrwTitle# NEQ "">
AND lower(ctrDocs.DRWTITLE) LIKE lower('%#Form.DrwTitle#%')
</CFIF>
<!--- Month
<CFIF #Form.selectMonth# NEQ "">
AND EXTRACT(MONTH FROM ctrData.CONTRACTDATE ) IN
(#ListQualify(Form.selectMonth, "'")#)
</CFIF>
<!--- Day --->
<CFIF #Form.selectDay# NEQ "">
AND EXTRACT(DAY FROM ctrData.CONTRACTDATE ) IN
(#ListQualify(Form.selectDay, "'")#)
</CFIF>
<!--- Year --->
<CFIF #Form.selectYear# NEQ "">
AND EXTRACT(YEAR FROM ctrData.CONTRACTDATE ) IN
(#ListQualify(Form.selectYear, "'")#)
</CFIF>--->
<!--- Between Two Years --->
<CFIF (#Form.selectYearF# NEQ "") AND (#Form.selectYearT#
NEQ "")>
AND ( EXTRACT(YEAR FROM ctrData.CONTRACTDATE ) BETWEEN
#Form.selectYearF# AND #Form.selectYearT# )
</CFIF>
<!--- ORDER by most recent date first --->
ORDER BY #sortKey# DESC
</CFQUERY>

Similar Messages

  • Pb retrieving sorted data from Table in SQL.

    Hi,
    I get problem to retrieve data in the right order from table in database SQL.
    See code attached: code.png
    I want to sort data according to ID number And then to retrieve those data and fill out a ring control in the right order "descending" .
    But i got always ID 2 instead of 1. See attached  picture : control.png
    it seems that the select statement (see under) is not woking properly. But it is working well in a query in Access DataBase .  
    //Select statement
       hstmt = DBActivateSQL (hdbc, ("SELECT * FROM %s ORDER BY ID DESCENDING",szTableName));
       if (hstmt<= DB_SUCCESS) {ShowError(); goto Error;}
    Some idea ??
    Lionel.
    Attachments:
    code.PNG ‏39 KB
    control.png ‏32 KB

    Hello Lionel,
    According to the document Robert linked, the prototype of DBActivateSQL() is:
    int statementHandle = DBActivateSQL (int connectionHandle, char SQLStatement[]);
    For the 2nd parameter(SQLStatement), you're sending:
    ("SELECT * FROM %s ORDER BY ID DESCENDING",szTableName)
    Probably your intention is to substitute %s with szTableName, but that's not what it happens.
    By using comma operator, ("SELECT * FROM %s ORDER BY ID DESCENDING",szTableName) is evaluated to szTableName, so you call is equivalent to:
    hstmt = DBActivateSQL (hdbc, szTableName);
    In order to substitute %s with szTableName you need to first build the string you're passing as the 2nd parameter:
    char query[512];
    sprintf(query, "SELECT * FROM %s ORDER BY ID DESCENDING",szTableName);
    hstmt = DBActivateSQL (hdbc, query);

  • How to sort data in cl_gui_alv_tree class?

    Hi,
    I thought that since this object uses an alv grid that the standard sort functionality would exist.  Now that I've developed most of the code, I realize that there is no native sorting functionality.
    Is there some way I can make use of the Superclass CL_ALV_TREE_BASE?
    It has some methods that are "Private", "Instance"  - I'm still a rookie at OO programming in SAP so I'm not sure how best to approach the situation.
    As I see it, I have a few options:
    1)  Manually manage sorting by providing an ascending and descending button/icon on the toolbar and then delete and rebuild the nodes in the tree.
    2)  Manually track the data along with the nodekeys and then use method MOVE_NODE to reposition the data in the tree
    3)  Clone these objects and somehow find the code that is causing the sort options to be suppressed in the toolbar.
    Has anyone built any applications using CL_ALV_TREE_BASE that permit sorting?
    Please don't waste my time by pasting in the links to all the SAP online help for ALV and expect to get points.  Been there, done that.  If there is a particular section that is of specific value, I'll happily study it and report my findings.  Particularly something that explains how to invoke the methods of a superclass and the difference between protected, public, and private.
    Mostly though, I really need a way to sort data in the CL_GUI_ALV_TREE class.
    Thanks

    Hi Ray,
    As far as I know, this will not work. I've had the same problem. The only solution I have found was to re-build the tree each time. It is easier than moving nodes around.
    You can take a look at the class cl_wa_notifications_wps - in case you have a PM or an A&D system.
    Ferenc

  • Use drag and drop to sort data in report

    Hello!
    I found a good description to sort data in a Tabular Form per drag and drop.

    Here is the url: Read Article - Drag &amp;amp; Drop tabular form rows
    It works fine if one follow the hint from Baki (For apex 4.2 one have to adapt a css class).
    Afterwards I tried the same with an Interactive Report. It nearly works.
    I once again had to adapt a css class.
    I used the
    apexir_WORKSHEET_DATA
    class instead of the
    uReportStandard
    in the JavaScript for the Interactive Report.
    Everything went fine. Except the "Save the Thing to the DB" issiu did not work.
    The following code do not work (the "APEX_APPLICATION.G_FROWID.COUNT" is allways 0):
    FOR i IN 1 .. APEX_APPLICATION.G_FROWID.COUNT 
    LOOP
    UPDATE emp SET sort_order = i WHERE rowid = APEX_APPLICATION.G_FROWID(i);
    END LOOP;
    Does anybody know why?
    Best thanks,
    Ilb

  • How do I sort data in columns using Pages

    How do I sort data in columns (alphabetically) using Pages?

    If you are referring to text or numbers in a column (not table), then get the free Service plug-in WordService, from Devon Technologies. Put it in the
    /Users/yourlogin/Library/Services folder location.
    Select your data to be sorted. From the Pages menu > Services > Sort Ascending will do the trick. This will work with Pages ’09 and Pages v5.2 or later, as well as Apple Mail, TextEdit, etc.
    The WordService files include a PDF (Read Me) that describes the services included with the package.
    The Service items will only appear in the Services submenu when you have selected your data prior to sort. If these WordService items do not appear in the Services menu as they should per the preceding sentence, then you will need to enable them.
    System Preferences > Keyboard > Shortcuts > Services. Scroll through the right hand list of services until you encounter Sort Ascending and ensure that it is selected.
    If you were referring to sorting a column of data in a table:
    Pages ’09
    Select all cells containing your unordered data. In the Table Inspector, under Edit Rows & Columns, choose Sort Ascending.
    Pages v5.2
    Select cells as before. In the Table heading (A, B, C, etc.) when you roll over the letter, a down-arrow appears. Click, and choose Sort Ascending from the drop down menu.

  • SPGridView - sorting Dates doesn't work properly & how to display the title column as link?

    Hi,
    I've got a SPGridView that is being filled with data from several lists. Some of them are a date-field and a title-field. I already added sorting, paging and filtering options and at first look they seem to work fine. But now I noticed that sorting dates
    doesn't work as expected. If I select ascending sorting, the result is something like this:
    01.08.2014
    02.08.2014
    17.07.2014
    18.07.2014
    23.07.2014
    If I select descending sorting, the result is this:
    23.07.2014
    18.07.2014
    17.07.2014
    02.08.2014
    01.08.2014
    This isn't what I want obviously. 
    I just added the EventReceiver for the sorting like it is shown in several tutorials:
    (The date field is a BoundField.)
    grid.Sorting += new GridViewSortEventHandler(grid_Sorting);
    private void grid_Sorting(object sender, GridViewSortEventArgs e)
    if (ViewState["FilterExpression"] != null)
    gridDS.FilterExpression = (string)ViewState["FilterExpression"];
    And my second problem is how to add a link to the title column. In my grid I'm displaying tasks from different lists and I want to link the title to the related task. I stumbled accross HyperLinkFields and tried this:
    HyperLinkField hyperLinkField = new HyperLinkField();
    hyperLinkField.DataTextField = "Titel";
    hyperLinkField.DataNavigateUrlFields = new string[] { "Titel" };
    hyperLinkField.DataNavigateUrlFormatString = "{0}";
    hyperLinkField.HeaderText = "Titel";
    hyperLinkField.SortExpression = "Titel";
    grid.Columns.Add(hyperLinkField);
    The resulting link is something like ...sites/MySite/_catalogs/masterpage/A1-V1-2 where "A1-V1-2" is the name of the task and also shown in the title field.
    The actual link should look more like ...sites/MySite/Lists/mytasklistname/DispForm.aspx?ID=.... or something like that to display the task details. How could I achieve that?
    Thanks in advance

    http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/MS-SharePoint/Q_27718782.html
    Here is the exact code you need to use:
    http://social.msdn.microsoft.com/Forums/ar/sharepointcustomization/thread/c463a8c6-4806-4233-b6a4-8db8369c5fc2
    http://sharepoint.stackexchange.com/questions/53459/change-title-linked-to-item-with-edit-menu-to-different-column
    Open the AllItems.aspx page for the specific list.
    Search for the <ViewFields> tag
    List item LinkToItem="TRUE" to whichever column you want the link:
    <ViewFields><br/>
    <FieldRef Name="Attachments"/><br/>
    <FieldRef Name="LinkTitle"/><br/>
    <FieldRef Name="linkThisColumn" LinkToItem="TRUE"/><br/>
    <FieldRef Name="data_x0020_column"/><br/>
    <FieldRef Name="Another_x0020_column"/><br/>
    </ViewFields><br/>
    http://sharepoint.stackexchange.com/questions/58954/link-title-in-list-to-value-in-url-column
    Create calculated column.
    Insert following formula -
    ="<a href='"&UrlFieldName&"'>"&Title&"</a>"
    Set "data type returned from this formula is" to integer.
    As a result on list view you will see the title with link to your url.
    UPD: It seems that URL field is not valid for calculated column, as workaround you can copy url value in a receiver into the another text field, which is not shown on the view.
    If this helped you resolve your issue, please mark it Answered

  • Sort data does not match song info

    I've just discovered that some of my songs have sort data from different files. Short of going though all my music song by song is there a way to clear all sort data?

    Generally setting a common Album Artist will fix split albums.
    For deeper problems see Grouping tracks into albums.
    tt2

  • Performance - using JDBC call with 'order by' vs sorting data on app server

    Hello! I need some valid thoughts on the performance of using a JDBC call versus processing information on the application server.
    Here is the somewhat simplified scenario:
    I need to retrieve customer information (name, e-mail, telephone), display it in HTML format and then be able to redisplay it in a different order. For example, initially the list would be displayed sorted by last name, but then a user might choose to sort it by e-mail address. Initial call to DB uses 'order by' in the SQL stmt to get me the initial ordering by last name. Results are stored in 2D array. However, when a user selects a different sort I have two options:
    1) just make another call to the DB with a different order by clause. This means I need to create a DB connection, connect to DB, retrieve the results and read them from result set into a 2 dimensional array
    2) re-sort data in the 2D array populated during the initial call. This means I need to use java.util.Arrays.sort(my_2D_resultsArray, my_custom_comparator)
    Question is : which is more efficient? Number of entries retrieved can be anywhere from 0 to a few thousands (depending on other filters such as customer's country). My feeling is that option umber 2 is better, but I would like to get your opinion.
    Thank you!

    Good points! Thanks! I ran a test (see code below) and it takes less than a second to sort 2000 Strings and 2000 nulls. The only thing I ran the test at a UNIX prompt as oppose to from within app server (Weblogic). I expect the speed to be compatible though. Do you think that test was valid and tells us that sorting on the app server is probably faster than doing another SQL query?
    import java.io.*;
    import java.math.*;
    import java.util.*;
    import java.util.Arrays.*;
    public class Test {
      public static void main(String[] args) throws Exception {
        Test test = new Test();
        test.testSortingPerformance();
      public void testSortingPerformance() {
        Object[] objArray2 = new Object[]{};
        Vector v = new Vector();
        Date start, end;
        java.util.Random rd = new java.util.Random(2000);
        for (int i = 0; i < 2000; i++){
          v.add(new Object[]{new String("" + rd.nextInt())});
          v.add(new Object[]{null});
        objArray2 = v.toArray();
        Object[] innerObjArray2 = new Object[]{};
        MyComparator2 myComp = new MyComparator2();
        start = new Date();
        java.util.Arrays.sort(objArray2, myComp);
        end = new Date();
        for (int i = 0; i < objArray2.length; i++) {
          System.out.println();
          innerObjArray2 = (Object[])objArray2;
    for (int j = 0; j < innerObjArray2.length; j++) {
    System.out.print(innerObjArray2[j] + " ");
    System.out.println(v.size());
    System.out.println("Start " + start + " End " + end);
    import java.util.*;
    public class MyComparator2
    implements Comparator {
    //position in the inner array to use for comparison
    private int position = 0;
    //default empty constructor
    public MyComparator2() {
    //implement compare method
    public int compare(Object o1, Object o2) {
    Object[] strAr1 = (Object[]) o1;
    Object[] strAr2 = (Object[]) o2;
    if (strAr1[0] == null){
    if (strAr2[0] == null){
    return 0;
    else{
    return -1;
    else if (strAr2[0] == null){
    return 1;
    return ( (String) strAr1[0]).compareTo( (String) strAr2[0]);

  • Sort data in a ref cursor

    Hello,
    I would like to know if the following is possible:
    I'm getting data from different sources in a ref cursor. Is it possible to sort this ref cursor on a specific column in the ref cursor? If so, how?
    Thanks
    Karuna

    Note that this is a duplicate post of this thread
    sort data in ref cursor
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Sort Date format in Oracle XML Publisher

    Hi All,
    I have a requirement like trx_date sort. i have taken trx_date in dd-mon-yyyy format. now i given sort option like this..
    <?for-each:G_TRX_ORDER_NUMBER?><?sort:TRANSACTION_TYPE?><?sort:DUE_DATE;'ascending';data-type=date?> <?sort:TRX_NUMBER?>
    now i have 3 dates
    07-NOV-10
    20-MAY-11
    20-DEC-10
    using above sort option.. this dates are not coming as per the ascending order.
    Can any one tell me what i have to ?
    Thanks

    What is your application release?
    Does the sort work for other data types?
    What if you change "<?sort:DUE_DATE;'ascending';data-type=date?>" to "<?sort:DUE_DATE;'ascending';data-type='date'?>", does it make any difference?
    Few examples about the sort can be found in these docs/links.
    How to Group Data Dynamically at Runtime in a BI/XML Publisher RTF Template? [ID 1062816.1]
    Sorting Data In eText Template [ID 1263511.1]
    Oracle XML Publisher User's Guide
    http://download.oracle.com/docs/cd/B25516_18/current/acrobat/115xdoug.zip
    Thanks,
    Hussein

  • Sorting Data in Tables

    Hi anyone help with trying to resolve an issue with sorting data in a table I have created in Pages 08 v 3.0.2.
    I have a table six columns across with rows down of data. I have so far entered 10 rows of data and wanted to sort the data based on column 1 then column 2 with the associated data in the other columns staying connected to column 2. Fairly straightforward stuff I thought so clicked the table header for column 1 then the ascending sort button in Inspector the results I got were not quite what I expected.
    Here are three lines of data taken from columns 1 & 2. The sequence below is how I entered it. The data as you will see relates to classical music. In column 1 is the single word 'Mozart' all the other data is in column 2 on one line:
    Mozart Symphony No 29 in A Major KV201
    Mozart Symphony No 4 in D Major KV19
    Mozart Symphony No 36 in C Major KV425 'Linz'
    When I clicked the header for column 1 then the button in Inspector to sort the data ascending this is the result I got:
    Mozart Symphony No 29 in A Major KV201
    Mozart Symphony No 36 in C Major KV425 'Linz'
    Mozart Symphony No 4 in D Major KV19
    The first two entries are in the right order but the third one should obviously be first. Anyone know how I could resolve the issue I have with sorting data in the table I have created?
    Thanks ....

    Just to expand on Beatrice's answer, Pages (as most other word processors) sorts alphabetically. 4 comes after 39 alphabetically because the 4 comes after the 3. It doesn't think, "oh, that's the number 4 which is smaller than the number 39." By placing the leading 0 we wind up comparing 04 to 39 and yes, the zero is in front of the 3 so it gets placed ahead of it.

  • Excel14.4.7 (Excel for Mac 2011); can't sort data

    Upgraded to Excel for Mac 2011 (v.14.4.7) and cannot sort data. Have read instructions but keep getting error message "missing column/row name"
    Tried doing it with box checked "My list has headers" and with the box unchecked....same non-result and error message.
    I'm doing something wrong, obviously but can't figure it out. I am totally mystified & frustrated!
    any ideas????
    Thank you
    Rose

    This may be a related issue and fix:
    https://discussions.apple.com/message/26086328#26086328

  • Sort data Date wise(YYYY-MM-Date) in BPEL output

    HI,
    Can any one help me, how to write code for sort data Date wise(YYYY-MM-Date) .
    I pass the input as Name from the service wsdl(Exposed Services) and its call the third party service(External References) , its return the output like below one,
    Name:Vodafone
    Pole:INdia
    End Date:2012-05-12
    Name:Airtel
    Pole:USA
    End Date:2012-05-13
    Name:Uninor
    Pole:Canda
    End Date:2020-10-13
    Name:Celltell
    Pole:INdia
    End Date:2011-03-21
    Above o/p in Random way, but i need this one in sort data date wise.
    Finally i need output based on the latest End Date..
    like,
    Name:Uninor
    Pole:Canda
    End Date:2020-10-13
    Name:Airtel
    Pole:USA
    End Date:2012-05-13
    Name:Vodafone
    Pole:INdia
    End Date:2012-05-12
    Name:Celltell
    Pole:INdia
    End Date:2011-03-21.
    Could you please help me the format of code, and where to i implement this one. its very urgrnt.
    Regards,
    Harsih

    Hi
    Sukanya,
    Thanks for ur quick replyy, i fetch data from external reference onlyy. If i fetch data from DB what u said its exactly right.
    Re: Sort data Date wise(YYYY-MM-Date) in BPEL output 

  • How can I sort date?

    hi,
    How do I sort date? Its in the following format 11 Mar 2002. The date is written using the calendar class in java.util.* package.
    Please help me out.
    Regards
    Deepa Datar

    long[] longArray = new long[dateArray.length];
    for(int i=0;i<dateArray.length;i++) {
       longArray[i] = dateArray.getTimeInMillis();
    Arrays.sort(longArray);
    Now you can format the sorted longArray into appropriate date format.

  • Efficent method to sort data from tab delimited text file

    I am currently writing a program to sort through data that was acquired and display it on a graph and some other indicators.  The file is a tab delimited text file with possibly 100,000s of data points.  the current method that I have tried using was that if I wanted all of the data from Oct, I would parse out the month from the timestamp, compare that to the desired month, and add it to the array if it is the same.  Other possible options of sorting are yearly and daily, possibly even hourly.
    The method does work, however it does take some time (up to a minute on a P4 3.6 GHz with 2 gb ram), and most of the other computers are not nearly as fast or with as much memory.  Is there a more efficent method to sorting the data??
    I attached my sorting vi as well as a sample data file.
    thanks for the advice.  It is saved in LV8.0.1
    Kenny
    Kenny
    Attachments:
    data sort.zip ‏84 KB
    oven1.txt ‏21 KB

    First of all, "sorting" has usually a different meaning (Sorting and numeric array ascending or descending, a string array aphabetically, etc.). Your data already seems sorted by date and time, you just want to pick a subset having certain characteristics.
    The main problem that is slowing you down is your constant growing of large arrays. This causes constant memory reallocations.
    Since your data is already sorted by date and time, all you need is to place your data in a sutable data structure, find the start and end point of your selection, then use "array subset" for example.
    Your code also seems to have a lot of unecessary complexity. See for example your "test for sort data" (see image below).
    the four cases only differ by filename --> only the file name belongs into the case and the file operation outside the inner case. Even better, just use autoindexing.
    that shift register does not do anything, because it always contains the same data. Using "index array" with index wired to [i] is equivalent to an autoindexing tunnel.
    You have a case structure to select which files to read, skipped files give you an empty array. Do you really need to do all these operations on an empty array. Why not place all code inside the TRUE case??
    Below is an image of one possible code alternative that addresses some of these points.
    Message Edited by altenbach on 10-26-2006 09:32 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    testForSortData.png ‏33 KB

  • UDF for sorting date

    Hi Guys,
    I am doing scenario File to Idoc, i have to sort date in acending order, the date format will be in either 22.10.2007 or 22/10/2007 . can any one send UDF for this.
    Regards,
    venu gopal

    Hi Venu
    You can execute this without UDF. Use " Transform" function in the Date functions.
    When you are using the UDF....you keep the strucure as "yyyMMddhhmmss" for that clickon Trnasform function and there you can see ShowAdvancedProperties...there u can find the format of the source which you are expecting and also change the strucutre of you target expected format.
    You please try this and check the mapping it will get execute.
    Use Standard Date Function DATATRANS. It have the property for format and input is the source date field. It will convert the date format to required specified format which you menstion in the DARTATRANS function
    for UDF
    Re: UDF  for this mapping rule
    Re: Problem in UDF please Help?
    Thanks!

Maybe you are looking for

  • ITunes install on Win 8.1 Pro x64; Could not open key

    iTune install stalls with message "Could not open key .......string of numbers ....."

  • FBCJ Vendor Payment

    Dear all, In Tcode : FBCJ , getting error, Enter a vendor for this accounting transaction,     Message no. F5A053 Details like , I am using "Vendor Payment" as a business transaction and entering Vendor Code and amount in FBCj. In same Business Trans

  • HT201328 Does your iphone need to be updated to the newest OS to unlock it?

    I haven't updated my phone in about a year it seems because I didn't want the new changes.  So I think my OS is 5.1.1.  Anyways I got a code from ATT for an unlock which is useless since it sounds like I don't even need a code, however my phone won't

  • Audible book on ipod in car

    I listen to books downloaded from audible.com to my ipod in my facotory fitted connector in an Acura RL and it usually works fine. However, from time to time, it jumps from one part to an other after starting the car up. I think there is a power surg

  • How eliminating duplicated values from selecItem's List...

    Hi guys, i've a problem. I've a list of selectItem elements. private List<SelectItem> names; filled with some values. In this values there are some duplicated values, so i need to eliminate them. How can i do it? Please help me,thanks