How do I sort by month ? using the "Month" format

Hello All,
Is it possible to sort by month using the follwoing SQL.
Select TO_CHAR (RCA_CLOSE_DATE, 'MON-YY') "Month",
SUM (ADJUSTMENT_INCL_GST)
From My_Table
Group By TO_CHAR (RCA_CLOSE_DATE, 'MON-YY')
Output
Month Sum(Adjustment Incl Gst)
APR-06 $6,539,983.08
AUG-06 $23,122,705.31
FEB-06 $14,365,106.52
JUL-06 $19,776,122.04
JUN-06 $20,161,278.12
MAR-06 $8,248,955.87
MAY-06 $18,498,683.04
NOV-06 $24,120,095.49
OCT-06 $12,781,721.23
SEP-06 $15,632,604.21
Hope someone can help
Frank

If the desired sort order is MM-YYYY, then how would...
ORDER BY
    TO_CHAR(RCA_CLOSE_DATE, 'MM-YYYY') ...not achieve this?
Perhaps the original poster could clarify what they mean by "sort by month". In numeric order by month then year, in numeric order by year then month, or in some other order?
If you do not like TO_CHAR, another approach (again assuming "numeric order by month then year" is what is desired) might be:
SELECT
    TO_CHAR(RCA_CLOSE_DATE, 'MON-YY') AS MONTH,
    SUM(ADJUSTMENT_INCL_GST) AS TOTAL
FROM
    MY_TABLE
GROUP BY
    EXTRACT(MONTH FROM RCA_CLOSE_DATE),
    EXTRACT(YEAR FROM RCA_CLOSE_DATE),
    TO_CHAR(RCA_CLOSE_DATE, 'MON-YY')
ORDER BY
    EXTRACT(MONTH FROM RCA_CLOSE_DATE),
    EXTRACT(YEAR FROM RCA_CLOSE_DATE)In any event, in a query with GROUP BY clause:
1. The expression(s) in ORDER BY clause do not need to appear in the SELECT clause.
2. The expression(s) in ORDER BY clause do need to appear in the GROUP BY clause (unless you want to order on the result of an aggregate expression, like involving SUM, which does not appear to be the case here).
3. Expressions in the SELECT clause do need to appear in the GROUP BY clause, unless they are aggregate expressions, like involving SUM.
Hope this helps.
P.S. If the desired order is "in numeric order by year then month", then you might use TRUNC like this:
SELECT
    TO_CHAR(RCA_CLOSE_DATE, 'MON-YY') AS MONTH,
    SUM(ADJUSTMENT_INCL_GST) AS TOTAL
FROM
    MY_TABLE
GROUP BY
    TRUNC(RCA_CLOSE_DATE, 'MONTH'),
    TO_CHAR(RCA_CLOSE_DATE, 'MON-YY')
ORDER BY
    TRUNC(RCA_CLOSE_DATE, 'MONTH')Doing the TRUNC in a subquery and formatting the result in the outer query as John has suggested may be more efficient.

Similar Messages

  • After my 1 month trial verion expired, i paid for the Adobe XI month to month sub, downloaded the trial version again from the cloud and now when i try to use the month to month paid version it says my trial version has expired, an clues on how i access m

    after my 1 month trial verion expired, i paid for the Adobe XI month to month sub, downloaded the trial version again from the cloud and now when i try to use the month to month paid version it says my trial version has expired, an clues on how i access my paid version?

    sign out and then back in to your cc desktop app, Sign out, Sign in | Creative Cloud Desktop app
    when signing in, use the same adobe id you used to subscribe.

  • After 6 months of iPad bliss....My iPad has the incorrect apple ID how do I get it to use the correct one?

    After 6 months of iPad bliss....My iPad has the incorrect apple ID how do I get it to use the correct one?

    Settings > Store > Apple ID.  Sign out and sign in with the correct one.  Note that all apps are forever tied to the account they are purchased under.

  • How can I sort a table using more than one column in Numbers or in Pages?

    How can I sort a table using more than one column in Numbers or in Pages?

    Hi Ron,
    On the right side of the Toolbar click the Sort and Filter button, then select Sort.
    You can then set up a multiple column sort.
    Click Add A Column, Specify the sort for that column, Repeat.
    Jerry

  • Sorting a vector using the selection sort method

    I have to write a program that sorts a Vector using the selection sort algorithm. Unfortunately the textbook only has about 2 pages on vectors so needless to say I'm pretty clueless on how to manipulate vectors. However I think I'm on the right path, however I'm stuck on one part as shown in the code below.     
    private static void  selectionSort(Vector parts)
          int index;
            int smallestIndex;
            int minIndex;
            int temp = 0;
            for (index = 0; index < parts.size() - 1; index++)
              smallestIndex = index;
              for (minIndex = index + 1; minIndex < parts.size(); minIndex++)
               if (parts.elementAt(minIndex) < parts.elementAt(smallestIndex))  // this is where I'm having trouble
                  smallestIndex = minIndex;
                parts.setElementAt(temp, smallestIndex);
                parts.setElementAt(smallestIndex, index);
                parts.setElementAt(index, temp); if (parts.elementAt(minIndex) < parts.elementAt(smallestIndex))
    is returning "ProcessParts3.java:51: operator < cannot be applied to java.lang.Object,java.lang.Object"
    Here is the full program:
    import java.util.*;
    import java.io.*;
    public class ProcessParts3
         static Vector parts;
         public static void main(String[] args)
              loadVector();
         private static void loadVector()
         try
              Scanner fileIn = new Scanner(new File("productionParts.txt"));
              parts = new Vector();
              String partIn;
              while (fileIn.hasNext())
                   partIn = fileIn.nextLine();
                        parts.addElement(partIn.trim());
              selectionSort(parts);
                   for (int i = 0; i < parts.size(); i ++)
                   System.out.println(parts.elementAt(i));
         catch(Exception e)
              e.printStackTrace();
         private static void  selectionSort(Vector parts) //from this part down I'm responsible for the coding, everything
                                                               // everything above this was written by the teacher
                 int index;
            int smallestIndex;
            int minIndex;
            int temp = 0;
            for (index = 0; index < parts.size() - 1; index++)
                smallestIndex = index;
                for (minIndex = index + 1; minIndex < parts.size(); minIndex++)
                    if (parts.elementAt(minIndex) < parts.elementAt(smallestIndex))
                        smallestIndex = minIndex;
                parts.setElementAt(temp, smallestIndex);
                parts.setElementAt(smallestIndex, index);
                parts.setElementAt(index, temp);
    }Edited by: SammyP on Nov 27, 2009 11:43 AM

    SammyP wrote:
    I have to write a program that sorts a Vector using the selection sort algorithm...Hmmm.... Your teacher is, in my humble opinion, a bit of a tard.
    1. Vector is basically deprecated in favor of newer implementations of the List interface which where introduced in [the collections framework|http://java.sun.com/docs/books/tutorial/collections/index.html] with Java 1.5 (which became generally available back in May 2004, and went end-of-support Oct 2009). ArrayList is very nearly a "drop in" replacement for Vector, and it is much better designed, and is marginally more efficient, mainly because it is not syncronised, which imposes a small but fundamentally pointless overhead when the collection is not being accessed across multiple threads (as is the case in your program).
    2. Use generics. That "raw" Vector (a list of Objects) should be a genericised List<String> (a list of Strings)... because it's compile-time-type-safe... mind you that definately complicates the definition of your static sort method, but there's an example in the link... Tip: temp should be of type T (not int).
    Note that String implements [Comparable<String>|http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html], so two String's can safely be compared using the compareTo method... In Java the mathematical operators (<, >, &#43;, -, /, &#42;, etc) are only applicable to the primitive types (byte char, int, float, etc)... The Java Gods just chose to muddy the waters (especially for noobs) by "overloading" the &#43; operator for String (and String only) to enable succinct, convenient string-concatenation... which I personally now see as "a little bit of a mistake" on there part.
         private static void  selectionSort(Vector parts)  {
    int index, smallestIndex, minIndex, temp = 0;
    for (index = 0; index < parts.size() - 1; index++) {
    smallestIndex = index;
    for (minIndex = index + 1; minIndex < parts.size(); minIndex++) {
    if (parts.elementAt(minIndex) < parts.elementAt(smallestIndex)) {
    smallestIndex = minIndex;
    parts.setElementAt(temp, smallestIndex);
    parts.setElementAt(smallestIndex, index);
    parts.setElementAt(index, temp);
    }3. ALLWAYS use {curly braces}, even when not strictly necessary for correctness, because (a) they help make your code more readable to humans, and also (b) if you leave them out, you will eventually stuff it up when you insert a line in the expectation that it will be part of the if statement (for example) but you forgot to also add the now mandatory curly-braces... This is far-too-common source of bugs in noob-code. Almost all professionals, nearly allways allways use curly braces, most of the time ;-)
    4. Variable names should be meaningful, except (IMHO) for loop counters... Ergo: I'd rename index plain old i, and minIndex to plain old j
        for ( int i=0; i<list.size()-1; ++i) {
          int wee = i; // wee is the index of the smallest-known-item in list.
          for ( int j=i+1; j<list.size(); ++j ) {Cheers. Keith.
    Edited by: corlettk on 28/11/2009 09:49 ~~ This here fraggin forum markup friggin sucks!

  • I am changing from Word to Pages. I have created my custom template with all my styles etc and that is what comes up when I go for a New Document. Fine. How do I get it to use the same Custom Template when I use Pages to open a Word document?

    I am changing from Word to Pages. I have created my custom template with all my styles etc and that is what comes up when I go for a New Document. Fine. How do I get it to use the same Custom Template when I use Pages to open a Word document?

    The template is a document in itself, it is not applied to an existing document whether it is a Pages document or a Word document converted to a Pages document.
    You would need to either copy and paste content, using existing styles, or apply the styles to the converted Word document.
    You can Import the Styles from an existing document and those imported Styles can be used to override the current document's styles:
    Menu > Format > Import Styles
    The process is simplified if the styles use the same names, otherwise you will need to delete the style you don't want and replace it with the one that you do want when asked, then the substitution is pretty straightforward.
    Peter

  • How many users are registered for using the firefox sync server?

    I'm working on a german wikipedia article about "Firefox Sync" and I need more information about the current usage and the historical development of this feature - number of registered users for the Sync Server at Mozilla - would be nice to have numbers for 2011, 2012, and current usage.
    If possible, it would be also useful to know how many german speaking users are using the sync service.
    Where are your Sync Servers located (US, Europe, Asia)?
    What kind of systems and platforms are supported?
    Is there a current documentation about the importance of the Firefox Sync Service, that I may reference?

    thanks for your fast reply,
    your URL to the page with the ideas of the new PiCL service shows in the remark about the usability of the "Firefox Sync" some hints about the usage of the current sync service "only 1% of our users have actually done so" - so I will use that as reference.
    But it would be nicer to have some public message - for example: a mozilla blog entry - from the mozilla services group about the number of registered Sync Server User - and also about performance and reliabilty.
    But if that is private information only, you can close this problem.

  • I have two Apple ID, how can I delete one and use the email address associates to the main one?

    I have two Apple ID, how can I delete one and use the email address associates to the main one?

    If you abandon one of the Apple IDs you will also basically be abandoning any content that you have acquired with that Apple ID. Content can only be updated and re-downloaded with the Apple ID that was used to buy it. Apple will not combine the content of Apple IDs and Apple will not transfer the content from one Apple ID to another Apple ID.

  • I created a signature ID and customized the signature; however, when I go to sign it only shows the name layout or graphic image? How do I go back to using the certificate?

    Dear Forum
    I was using Adobe version XI and the signature feature disappeared from the menu. Now I downloaded Acrobat Reader DC. Using the menu and instructions I created a signature ID and customized the signature; however, when I go to sign a document it only shows the name layout or graphic image? How do I go back to using the certificate that I created?
    Any help would be greatly appreciated.
    Regards
    Carlos

    Firefox works fine on Windows 2000 SP4 for me.
    Any chance you have a dial-up connection that uses a web accelerator to speed the loading of content?

  • Apple recently replaced my broken iPhone 5 with a new one. I backed up all my stuff in iCloud. When I set up the new phone I apparently used a back up from an earlier date. Now I am missing some of my stuff. How do I go back and use the most current I cln

    Apple recently replaced my broken iPhone 5 with a new one. I backed up the contents of my phone with iCloud.
    When setting up my new phone I used an iCloud back up from an earlier date. Now I am missing some of my most recent stuff. How
    Do I go back to use the proper iCloud back up to set up my new phone?

    Tap settings> general> reset> erase all content and settings...then you'll have a chance to setuo your phone again

  • How do my wife and i use the same ipad?

    How do my wife and i use the same ipad?

    Nothing keeps you from handing it "back and forth" to share. I do this all the time on our couch with my Wife's iPad...
    I think your quesiton revolves around having your own bookmarks and other data/info on the device. 
    The iPad is meant to be a "single user device"; there isn't a login/logout to differenciate one user from another.  "The iPad isn't a computer"..  ;-)
    But, that being said, there are lots of ways to share the iPad/iOS environment.  Many apps, such as Facebook, let you login and out..  so, while you share the same app, each of your login is different.
    For bookmarks and notepad it is a little trickier..  You can each use a different browser (so all of your bookmarks are complerety seperate.)
    In some cases I would sugest a couple get a $900 Macbook Air rather than an iPad if this sharing won't work.  "Why can't I log in and out of and iPad?".  I think that the fact that it doesn't gives the iPad many adantages over a computer.
    If you have more specific questions pleaser ask away.  Just like you share the kitchen table and many other things around your household, there are many ways to make this work!  ;-)
    Matt

  • How to get default values while using the transaction "BP"

    Hi Group,
    I have a query on how to get default values while using the transaction <b>BP</b>?
    The thing is:
    when I enter into the transaction "BP", I need to see some default values to some of the input fields in the screen.
    how can I achieve this?
    So please kindly let me know the procedure to achieve this.
    Thanks & Regards,
    Vishnu.

    Hi,
    The events of BDT can be used to default some fields on creating a partner.
    For this create a function module for ISDAT. attach that event in BUS7.
    In the ISDAT funtion modulethe following code should be used.
    For example to set the nationality:
    I_BUSDEFAULT-NATIO = 'DE.
    CALL FUNCTION 'BUP_BUPA_FIELDVALUES_SET'
    EXPORTING
    i_busdefault = I_BUSDEFAULT
    Regards, Smita.

  • How can i reformat my harddrive using the recovery disk stored in partition drive?

    hi guys! i need help. i need to reformat my harddrive and i will do this for the first time. however, i was not ablt to make the recovery disk since i purchased the tx2 1275dx laptop last july 2009. what i have is a recovery disk stored in a partition harddrive. how can i reformat my cpmputer using the recovery disk in partition harddrive? my OS is windows vista.  thank you...  

    Hi,
    Shutdown the notebook.  Tap away at f11 as you start to access Recovery Manager which you can then use to reinstall the Operating System.
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • How do I download Adobe Acrobat using the Agreement Number provided by my employer.  Having difficulty connecting to Adobe Chat with Support option.

    How do I download Adobe Acrobat using the Agreement Number provided by my employer?  Having difficulty connecting to Adobe Chat with Support option.

    Hi,
    If you already have the serial number then I would request you to download the software from the below link and install it.
    http://www.adobe.com/downloads/other-downloads.html
    Regards,
    Anand

  • If I have an iTunes gift card already redeemed on my account, than how do I buy a song using the money from the gift card instead of charging my credit card?

    If I have an iTunes gift card already redeemed on my account, than how do I buy a song using the money from the gift card instead of charging my credit card?

    Hi, in my case It did not use the balance first.  I had balance but it used my credit card.  Do I have to sign in Itunes first?  Thanks.

Maybe you are looking for

  • Mr8m with freight charges maintain

    Hi, i have done miro for a PO with an freight charge included /maintain in the PO condition. the entry after miro is - AP + GR/IR acnt + Freight acnt Now am trying to reverse/cancel the miro but am having error message. "invoice document XXXXX cannot

  • Bill of Lading field in VL06I

    Dear MM Gurus, I am capturing the Bill of Lading Number in the 'Header > Shipment > Bill of Lading field', T/code: VL31N.  But when I execute the report VL06I the field Bill of Lading is not available.  Can anybody please advise how to bring the fiel

  • ORA-02266: unique/primary keys in table referenced by enabled foreign keys

    Hi, I am trying to delete data from a table by dropping a partition. I have identified all the child tables by running the following command. select 'select count(*) from '||table_name||' where employee_id = 100;' from dba_constraints where constrain

  • Sample API files uploaded

    Hi All, While going through the user guide i came across the API and the location where i could find the samples for those For the following files, go to Oracle_Home/ip/samples/TPSelfService This directory is not present at all in my installation. 1.

  • Creating JCO Connection in CE 7.1 SR5?

    hi @, I have installed CE 7.1 and creating Java Web Dynpro Application .I imported the RFC from R/3 System as model and completed my design. Now When I am trying to create the JCO connection I am getting error and it is not able to create the same. I