Order by date with a format mask column

10g - 10.2.0

Hello

This is my request
select to_char(exp_Date,'Mon-YYYY') dt, count(*) from exp_main
where exp_type like 'Income%Photo%'
group by to_char(exp_Date,'Mon-YYYY')
order by exp_date

 
When I run this I get: not a GROUP BY expression

If I remove the order by, it works fine.

Is it possible to order by since the output of the query is sorted character.

I search online most suggested to use the order of column_name. But does not work for me.

Thank you!
Ryan

Hello

Keep the date information as a DATE, with the exception (if required) for display. That means that GROUP BY and ORDER BY DATE, not a string:

SELECT    TO_CHAR ( TRUNC (exp_Date, 'MONTH')
              , 'Mon-YYYY'
            )          AS dt
,       COUNT (*)           AS cnt
FROM        exp_main
WHERE        exp_type     LIKE 'Income%Photo%'
GROUP BY  TRUNC (exp_Date, 'MONTH')
ORDER BY  TRUNC (exp_date, 'MONTH')
;

Tags: Database

Similar Questions

  • validation of digital data with a format mask

    Hello

    I have the following situation:

    field 'Amount' COMP (11.0) in a table.
    a form for this amount with a p8_amount parameter and a format mask. for example 1234 becomes 1,234.

    I entered a large amount of data.

    Now, I want to build a validation.
    But I get an error of conversion (character number) takes the apex the field amount 1234 makes 1.234
    and that's why I no longer use to_number (causing the conversion error).

    How to convert the parameter to a number?

    Any response will be appreciated.

    Thanks in advance.

    Leoa

    Hello

    TO_NUMBER (String) may have problems if there is non-numeric characters, however, you can apply a format string so that it can be used in the conversion:

    TO_NUMBER(string, '9G999')
    

    Andy

  • Download Apex 4.2 - blob in report with the Format mask

    Hello

    I need a little help.

    I have a report like this:

    SELECT id, file_name, dbms_lob.getlength (blob_content)

    of blob_docs;

    The column with the dbms_lob, is defined by the format mask, as a download link, saving up the BLOB to the user of the computer.

    My problem is a bit silly, I don't want to see 'Download', but the file name of each record, such as the 'link text'... but I can't seem to achieve this goal.

    My format mask looks like:

    DOWNLOAD: BLOB_DOCS:BLOB_CONTENT:ID:MIMETYPE:FILE_NAME:LAST_UPDATE:CHARSET:Attachment: download

    I tried to use #FILE_NAME # in the field 'Text download', since it is one of the column names, but nothing helped.

    Also used & FILE_NAME. but obviously does not work and gets the text "Download".

    All I want is a report that looks like

    File1

    File2

    File3

    Instead of

    Download file1

    Download File2

    Download file3

    Does anyone know how to get there?

    Thank you!!

    jaydarp wrote:

    I need a little help.

    I have a report like this:

    SELECT id, file_name, dbms_lob.getlength (blob_content)

    of blob_docs;

    The column with the dbms_lob, is defined by the format mask, as a download link, saving up the BLOB to the user of the computer.

    My problem is a bit silly, I don't want to see 'Download', but the file name of each record, such as the 'link text'... but I can't seem to achieve this goal.

    My format mask looks like:

    DOWNLOAD: BLOB_DOCS:BLOB_CONTENT:ID:MIMETYPE:FILE_NAME:LAST_UPDATE:CHARSET:Attachment: download

    I tried to use #FILE_NAME # in the field 'Text download', since it is one of the column names, but nothing helped.

    Also used & FILE_NAME. but obviously does not work and gets the text "Download".

    All I want is a report that looks like

    File1

    File2

    File3

    Instead of

    Download of file1

    Download File2

    File3 download

    Unfortunately (and annoying), it doesn't seem possible to do using the declarative format BLOB mask. Instead, a personalized download link should be generated in the report query using the apex_util.get_blob_file_src method of the API.

  • [REQUEST] Automatically display the number with the format mask

    Hi Expert,

    I use Jdeveloper 11.1.1.6.0.

    I have a problem to display the input text that automatically uses the format mask user input, as for example the entered user 10000 then the field will automatically display of 10,000

    Is this possible to do?


    I already find but I just had to format mask that the user must input 10 000 not automatically display in format.


    Please your advice, really appreciate your help.


    Thank you

    I already find but I just had to format mask that the user must input 10 000 not automatically display in format.

    Can you describe your use case a little more?

    The format is applied only when the focus is moved out of the field.

    You want to display the groups directly separator when the user inserts the value in the field?

    In this case, you will need to use javascript, and format the entry after each character. This technique is described in the blog of Frank https://blogs.oracle.com/jdevotnharvest/entry/get_social_security_numbers_right

    Timo

  • Default value in the item with the format mask DATE: DD-MON-RRRR HH:MIPM

    Dear all,

    I created OF type date DATE and mask game format: DD-MON-RRRR HH:MIPM

    and need to display the default code:

    declare

    v_start timestamp;

    Start

    BEGIN

    Select FROM_DATE IN v_start of TOUR_MAS

    where id =: P67_ID

    EXCEPTION WHEN OTHERS THEN

    v_start: = SYSDATE;

    END;

    RETURN v_start;

    END;

    But value display the DATE element is "11.02.00.000000 may 20, 15 h.

    In the table FOLLOWING is the timestamp.

    How to display the query result of default in the format ""HH:MIPM DD-MON-RRRR ". "

    How can I do that.

    Thank you

    Hi Maxence,

    Try this:

    DECLARE
    
      V_START VARCHAR2(64);
    
    BEGIN
    
      BEGIN
        SELECT TO_CHAR(FROM_DATE,'DD-MON-RRRR HH:MI PM')
          INTO V_START
          FROM TOUR_MAS
         WHERE ID =:P67_ID;
      EXCEPTION WHEN OTHERS THEN
        V_START:=TO_CHAR(SYSDATE,'DD-MON-RRRR HH:MI PM');
      END;
    
      RETURN V_START;
    
    END;
    

    Kind regards

    Kiran

  • SQL Developer: How to copy the data with the output grid column headers?

    Hello

    I use the 2.1.1.64 Version.

    I run a SQL query, down the results grid in the "Query result" window below. Say that I get 10 rows returned, with 5 columns.

    I want to copy this whole grid, as well as the names/column headers to the Clipboard. If I can stick under the original query to document the results of this query.

    I can't find any way to do this. I can copy/paste the results grid, but it does not copy the headers.

    The only way I think to do is to go through many steps to export in a TXT file, then paste that. Unfortunately, that's a lot of steps wasted if I need to do it again and again, and more, the output is pasted in an ugly format with double quotes, etc..

    It seems that the easiest feature is copy and paste the entire grid of the results, and of course, you could the headers. Why is it so difficult/impossible to do?

    (I think that the toad has the same problem. DBArtisan lets you copy and paste the results together, as well as headers, however.)

    Any help would be appreciated!

    Thank you
    John

    Shift-Ctrl-C will copy the headers of columns as well as the selected data.

  • Excerpt from SQL data with specific format.

    All,

    I have the oracle database version 10.2.0.4 in which I need to extract data from a table using the format below.

    1.1 st 3 positions of the postal code, followed by
    2.1 st letter of the name, followed by
    3.1 st 2 consonants in the name of the street, followed
    4 2 (for companies)

    I can use the function substr to 1 and 2 above.
    For 3, I tried regexp_substr. but the output includes vowels too. I don't know how to proceed. Is there another function or is there another way to do it?

    I am concatenating 3 columns and display data as below.
    for example
    Col1            Col2         Col3     
    FLOOR INC  24540       67 FRANKLIN TPKE STE 114 
    
    Displayed as 
    245FFR2     
    234AAS2 
    Help, please.
    -- testdata:
    with yourtable as
    (
      select 'abcdefg' name from dual union all
      select '1aBexea' name from dual
    )
    -- query for first two consonants:
    select substr(regexp_replace(regexp_replace(name,'[^a-zA-Z]',''),'[aeiouAEIOU]',''),1,2)
    from yourtable;
    

    Explanation:
    -Internal Regexp removes everything except the letters.
    -Outer Regexp removes vowals and keep the consonants.
    -substr selects the first two consonants.

  • Import ASCII dates with different format

    Hello

    I need to import data from a CSV of ASCII.

    The problem is the date format in this particular data file (.csv)

    The date format for day< 10="" and="" month="" from="" jan="" to="" sep="">

    AAAA/_M/_Dthe character '_' is a simple space, not an underscore literally

    The format of the date days > = 10 and Jan to Sep month is:

    _M/JJ/AAAA

    The format of the date days > = 10 and months of Oct to dec is:

    YYYY/MM/DD

    The date format for day< 10="" and="" months="" from="" oct="" to="" dec="">

    YYYY/MM/_D

    Possible solution:

    I already create a routine that recognizes the date in the title and one of the 4 (.stp) filter uses for data processing. These are the works.

    Next problem:

    The days are separated into 2 files, a file from 09:00 to 21:00 one day and the other from 21:00 to 09:00 on the following day. It's the way I've lost data when the day changes from 9th to the 10th of each month and the month change of Sept Oct and Dec to Jan.

    I just need to delete the blankspace unconfortable before the changes of dates 2-digit, but I do not know how to deal with the before CSV imported to tiara (10.2).

    My other idea is to recognize this file and any double (once with each please) but I need to exactly position the import is not the problem with the data of novalue. (Until know I got complicated for a simple mistake of blankspace).

    I hope that you have ideas...

    Thanks in advance...

    I don't know if I understand that measures are not clear. Here's what I think you want to do:

    (1) load data from different files in DIAdem

    To do this, you must use "DataFileLoad("E:\Customer_Requests\caracasnet\log(111231).csv","caracasnet_log","Load") call.

    You call DataFileLoad for each of the files.

    (2) you want to concatenate the groups.
    This should be no different than what you've done up to now

    (3) you want to store the data in a file (TDM).
    To do this, you must call DataFileSave (...)

    Let me know if you have any other questions...

  • Problem with order by Date

    Apex 3.2

    I have a report based on a collection, but the ranking of start_date and end_date does not work.

    Select

    C002 start_date,

    C003 end_date,

    -start_date to_char (to_date (c002, 'dd.mm.yyyy'), 'dd.mm.yyyy'),

    -End_date to_char (to_date (c003, 'dd.mm.yyyy'), 'dd.mm.yyyy'),

    C004 conversion_factor,

    SI.apskey SMI,

    SI.longdescr Description

    to apex_collections, if udm_si

    where si.siid = c001

    and collection_name = "SMI_INSERT_COL."

    I tried

    C002 start_date,

    C003 end_date

    and put exact in the formatting of column

    I tried

    start_date to_char (to_date (c002, 'dd.mm.yyyy'), 'dd.mm.yyyy'),

    -End_date to_char (to_date (c003, 'dd.mm.yyyy'), 'dd.mm.yyyy'),

    with no formatting of column

    I also tried

    start_date to_char ("c002, ' dd.mm.yyyy")

    but I get an error

    error report:

    ORA-01722: invalid number

    Gus

    Some previous threads please refer to "-" the origin of this. Try to split the "-"s: ".

    ' ': apex_item.display_and_save (2, c002)

  • Format mask number in the XML editor reports

    Hi all

    I have a requirement in the format mask in xml publisher reports.

    I have a field in my report that the quantity,

    1 > if the value is 1234 I need to show as 1 234

    2 > if the value 1234.56 I need to show 1,234.56

    so I tried with properties of form with number format mask ' #, # 0.00' decimal so that's good, but for like number for 1234 also he 1,234.00 impression so I need 1 234, how I can do this, please help me.

    Thank you

    Thank you Deb to clarify. Yes just check the decimal (.) will work.

    I tried with my example of xml data, and it worked.

    Try this now...

  • Transfer of data with rowtype block

    Hello

    I'm using the version of oracle forms 11g (11.1.2.1.0 on 64-bit windows).

    I have a block of data with a lot of columns.

    I have what it takes to fill the block of data at A TIME-NEW-FORM-INSTANCE with the query.

    My problem is, I have what it takes to fill the block with % rowtype (and not every article in separately), since I have a lot of elements (= columns) in this data block.

    Here is my code (in One TIME-NEW-FORM-BODY relaxation):

    DECLARE

    CURSOR pop_blck_cur IS

    Select *.

    ALERTS. CRDX_ALERTS_PROCESS_TYPES

    where (PROCESS_TYPE_ID, STATUS_DATE) in (select PROCESS_TYPE_ID, max (STATUS_DATE), 'MOST UPDATED'

    ALERTS. CRDX_ALERTS_PROCESS_TYPES

    Group of PROCESS_TYPE_ID)

    order of PROCESS_TYPE_ID;

    l_row pop_blck_cur % ROWTYPE;

    l_first_rec NUMBER;

    l_last_rec NUMBER;

    cur_rec NUMBER;

    BEGIN

    LAST_RECORD;

    l_last_rec: =: system.trigger_Record;

    PREMIER_ENREGISTREMENT;

    l_first_rec: =: system.trigger_Record;

    cur_rec: = l_first_rec;

    FOR rec IN pop_blck_cur

    LOOP

    GO_BLOCK ('ALERTS_PROCESS_TYPES_BLOCK');

    cur_rec: = GET_BLOCK_PROPERTY ('ALERTS_PROCESS_TYPES_BLOCK', CURRENT_RECORD);

    GO_RECORD (cur_rec);

    ALERTS_PROCESS_TYPES_BLOCK % ROWTYPE : = l_row;        -here I need the slider assignment to my block of data

    WHEN THE OUTPUT: SYSTEM. LAST_RECORD = "TRUE";

    NEXT_RECORD;

    END LOOP;

    How to achieve this?

    Tanks in advance,

    Elad

    This isn't the works of forms in a way.

    Your base on your table of CRDX_ALERTS_PROCESS_TYPES block

    Equip your WHERE condition the default value of the property - where the block.

    In the WHEN-NEW - EXAMPLE of FORM, just put an EXECUTE_QUERY;

    If you want to fill the block "by hand", you will need to assign each item separately.

  • Identify the weekend and the days of the week a date and update the empty column

    Hi, I look at previous posts that are similar to my question, but nothing helps.

    I have a column called incident_date that is in this format and comes from the Nov_Final table
    01-JUL-2009 20.10
    04-NOV-2009 17.00
    16-DEC-2009 16.00
    In Nov_Final, I created a column called weekend

    What I want to do is to perform an update, something like this:
    Update Nov_Final
    
    SET Weekend=(case when Incident_date ='WEEKEND' THEN 'Y' ELSE 'N' END)
    Banner:
    Oracle Database 11 g Release 11.2.0.2.0 - 64 bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE 11.2.0.2.0 Production."
    AMT for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    Weekend would be Saturday or Sunday. 
    In short I need to find out if the incident_date falls on a weekend and if it does update the weekend column as 'Y' else 'N' if it's not.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    You can use TO_CHAR function with a format mask as "fmDAY" to your needs:

    with t_data
    as
    (
    select sysdate + level as col1 from dual connect by level <= 7
    )
    SELECT
        col1,
        TO_CHAR(col1,'fmDAY') col_day,
        CASE
            WHEN TO_CHAR(col1,'fmDAY') IN ('SATURDAY','SUNDAY')
            THEN 'Y'
            ELSE 'N'
        END AS weekend_ind
    FROM
        t_data;
    
    COL1                      COL_DAY                     WEEKEND_IND
    ------------------------- --------------------------- -----------
    08-NOV-11 07:54:12        TUESDAY                     N
    09-NOV-11 07:54:12        WEDNESDAY                   N
    10-NOV-11 07:54:12        THURSDAY                    N
    11-NOV-11 07:54:12        FRIDAY                      N
    12-NOV-11 07:54:12        SATURDAY                    Y
    13-NOV-11 07:54:12        SUNDAY                      Y
    14-NOV-11 07:54:12        MONDAY                      N           
    
    7 rows selected
    
  • Digital Format on column displayed as a Popup LOV mask

    APEX 4.2 using theme 24.  In a tabular presentation, I have a column that is defined in the table as number 4 and I display as a Popup LOV.  I want to display on the initial load data form left padded with zeros - 0000 format mask. The Popup LOV gray on the ability to set the format mask. If I change it to a text field I can define the mask and display it as I want. I need to allow users to choose one of the LOV based on another table where the column is defined as a character. When the value is selected in the LOV it appears with the full left 4 digits padded with leading zeros, which is what I want.  However as I said on the initial load of data the leading zeros are not displayed.  It's really just a matter of Visual for the users, it is part of a GL account number and users are accustomed to seeing the full figures as if it was the character.  And please do not suggest I change the column in the table of characters too much process on the side server use it as a number.

    Thanks for the feasible suggestions!

    Therese

    Theresas wrote:

    APEX 4.2 using theme 24.  In a tabular presentation, I have a column that is defined in the table as number 4 and I display as a Popup LOV.  I want to display on the initial load data form left padded with zeros - 0000 format mask. The Popup LOV gray on the ability to set the format mask. If I change it to a text field I can define the mask and display it as I want. I need to allow users to choose one of the LOV based on another table where the column is defined as a character. When the value is selected in the LOV it appears with the full left 4 digits padded with leading zeros, which is what I want.  However as I said on the initial load of data the leading zeros are not displayed.  It's really just a matter of Visual for the users, it is part of a GL account number and users are accustomed to seeing the full figures as if it was the character.  And please do not suggest I change the column in the table of characters too much process on the side server use it as a number.

    Simply select it in the source region like query:

    ...
    to_char(col, 'fm0000') col_alias
    ...
    
  • Print data with Format separated by commas.

    Hello

    I need to establish a rapport with the values in column format, separated by commas. I use > > express edition of oracle 11g

    Table used names and customer number, he participated in the interview, it is stored in the format below.
    emp_name client_name
    JAMES HAS
    JAMES B
    JAMES C
    ALEX HAS
    ALEX D
    SCOTT B
    SCOTT C
    my requirement for the report is shown below
    emp_name count (client_name) client_name
    JAMES 3 A, B, C
    ALEX 2A, D
    2 B, C SCOTT
    please advise me is there any function that converts and print format separated by commas.


    Thank you
    Sudhir

    Try this...

    / * code deleted after suggested by BluShadow * /.

    I'll post other methods of String-aggregation...
    Try this...

    select
        emp_name,
        count(client_name) cnt,
        rtrim(XMLAGG(xmlelement(e, client_name||',')).extract('//text()'),',')
    from xx
    group by emp_name
    order by cnt desc;
    

    For versions > 11g Release 2

    select
        emp_name,
        count(*) cnt,
        LISTAGG(client_name,',') WITHIN GROUP(ORDER BY NULL)
    from xx
    group by emp_name;
    

    Published by: Vanessa B on 7 December 2012 18:50
    -adding code

  • Edition of text column data Format database columns of answers

    Hello

    We use Oracle Business Intelligence Enterprise Edition v10.1.3.4 on the cube for OLAP Oracle 11 g. Reports we create have (among other things) columns with an underlying type of VARCHAR data in oracle tables.

    When we try to change the properties of such a VARCHAR column column, "Data Format" tab shows only 'Plain Text' as an option under the menu drop-down "Override default data Format". Options to display the text 'HTML' or 'LINKS', etc. are not available.

    All entries on what can be done in the answers or the repository to get these options for formatting of column data are highly appreciated.

    Thank you
    Piyush

    You set your HardenXSS to false in the instanceconfig.xml file? By default, OBIEE is set to true. Setting to false allows the HTML tags to appear as options for fields VAR. check it out here... Chapter 2, page 37.

    http://download.Oracle.com/docs/CD/B40078_02/doc/bi.1013/b31766.PDF

Maybe you are looking for

  • new hard drive for HP Pavilion all-in - One MS228sc

    I need to get af new hard drive to my HP Pavilion all-in-One MS228sc I have a lot of trouble to get in touch with HP Denmark since my product is out of warranty. My question is if the PC can handle a larger than my current on the 500 GB drive. Even m

  • STOP button for program waiting in a state machine

    Hello I am trying to create a state machine in order to control a conveyor, mixer pump and linear actuator. Each component runs in sequential order all the time, so I thought that using a state machine would probably be the best architecture program.

  • tables dynamic thread-safe

    Hi all trying to convert my application single-threaded for multithreading, that I met a new obstacle: I would like to have a global data structure. This structure must be dynamically allocated and reallocated as the number of threads (and thus the s

  • BlackBerry 10 has anyone else lost voice on the CARDS

    I lost instructions on MAPS. Someone else, and if so, were you able to come back and how to get it?

  • Add pre directive processor use of programming

    Hello I'm new to the blackberry development. I need to add the directive of preprocessor to build according to the version of the OS. I wrote a logic to get a version of the OS and its very good operation, but the problem is that I'm not able to add