order by clause union in date column

Hi gems... good evening...

Oracle version: 11.2.0.2 EL6 Linux server

I have a query as below:

Select col1, col2, col3 col4
tab1, tab2, tab3
where the conditions
Union
Select col1, col2, col3 col4
tab1, tab2, tab3
where the conditions
Union
Select col1, col2, col3 col4
tab1, tab2, tab3
where the conditions;

Now the col4 is a date column, and I need to order by on that entire result sets. I know that I can do (order of col4) (order by 4) or at the end of all of the query.

But the problem is that the output is coming to Mon-dd-yyyy (i.e. 31-Dec-2012).

I want each output in the format dd/mm/yyyy, so I need to use the function to_char.

But in this case, I can't use the order by clause, because in this case it's get organized by character IE by 1,2,3,4,5 like that.

How can I solve my problem... Please help... Thanks in advance.

Published by: gogol on 3 November 2012 08:05

Maybe - when you order by date column, she did it with a date internal representation so on exit you can use any date format you think appropriate

select distinct
       col1,col2,col3,col4
  from (select col1,col2,col3,col4
          from tab1,tab2,tab3
         where conditions_1
            or conditions_2
            or conditions_3
       )

Concerning

Etbin

Tags: Database

Similar Questions

  • Order by for the prompt Date column

    Hi Experts,

    We have date column Date_Name varchar (15) in the command prompt. It display data in alphabetical order. But we want to see it in chronological order.



    Please suggest.


    Kind regards
    S

    Hello

    What is the format of the column that you get.

    Is it possible that you can convert it to the Date format... using cast and everything...

    Concerning
    Kishore Guggilla

  • What's the point of having several columns in the ORDER BY clause?

    DB version: 10 gr 2

    When you use the ORDER BY clause, the lines are always sorted by the first column in the ORDER BY clause. So, what's the point of having several columns in the ORDER BY clause (I always see this in production codes)?

    For the below SQLs' schema SCOTT, result sets are always classified according to the first column ename. When I added use asc and desc of employment, does not change the result set.
    SQL> select * from emp order by ename;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    20
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
    
    14 rows selected.
    
    SQL> select * from emp order by ename, job;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    20
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
    
    14 rows selected.
    
    SQL>  select * from emp order by ename, job desc;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    20
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
    
    14 rows selected.

    Search in this example, you will see the difference

    SQL> create table test_order (name varchar2(10), surname varchar2(10), age number);
    
    Table created.
    
    SQL> insert into test_order values('Kamran','Agayev',26);
    
    1 row created.
    
    SQL> insert into test_order values('Kamran','Taghiyev',26);
    
    1 row created.
    
    SQL> insert into test_order values('John','Kevin',23);
    
    1 row created.
    
    SQL> select * from test_order;
    
    NAME       SURNAME           AGE
    ---------- ---------- ----------
    Kamran     Agayev             26
    Kamran     Taghiyev           26
    John       Kevin              23
    
    SQL> select * from test_order
      2  order by age;
    
    NAME       SURNAME           AGE
    ---------- ---------- ----------
    John       Kevin              23
    Kamran     Agayev             26
    Kamran     Taghiyev           26
    
    SQL> select * from test_order
      2  order by age asc, surname desc;
    
    NAME       SURNAME           AGE
    ---------- ---------- ----------
    John       Kevin              23
    Kamran     Taghiyev           26
    Kamran     Agayev             26
    
    SQL>
    

    When in the second query, I sorted out only for age, you saw it there two 26 years old Keita, there was first Agayev, then Taghiyev. But if I want to get the family names in descending order when there are two very old person, then I will add the second column in the order by clause

    - - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev a. (10g OCP)
    http://kamranagayev.WordPress.com

  • order of varchar and digital data

    Hello

    I use the apex of oracle 10g 3.2

    I am using an sql query in a region. I want to make sure he by setting col.parameter column is varchar2 (1000).
    The values can be of a character or the format of number of characters.
    as
    format ABC or def - 1

    Now, I want to use the order by clause in there.

    But when I have data like
    ABC-1, abc-2 11 - abc

    His comes as
    ABC-1
    ABC-11
    ABC-2

    instead of abc - 1
    ABC-2
    ABC-11

    the query is

    Select distinct
    p.Parameter Test
    of T_RESULTS t, M_PARAMETERS p where p.parameter_id = t.parameter_id and
    t.service_registration_id =: P43_SERVICE_REGISTRATION_ID
    order to decode (instr(p.parameter,'-'), 0, p.parameter, to_number (substr (p.parameter, instr(p.parameter,'-') + 1)))

    So, what should I do?

    Thank you

    Hello

    with t as (select 'abc-1' col1 from dual union all
    select 'abc-11' col1 from dual union all
    select 'abc-2' col1 from dual)
    select col1
    from   t
    order by case instr(col1,'-') when 0 then col1 else substr(col1,1,instr(col1,'-')-1) end,
                 case instr(col1,'-') when 0 then 0 else to_number(substr(col1,instr(col1,'-')+1)) end
    

    The first element will sort the alphanumeric characters, the other numbers if they exist.

    Herald tiomela
    htendam.WordPress.com

  • How to remove the Order By clause

    How can I get rid of the Order By clause in the underlying SQL query? I created a simple hierarchy, but when I use the hierarchy in the analysis and then come down, the results show multiple occurrences of each child. For some reason, I was able to reduce the number of occurrences of each child by adding a saved filter.

    I was expecting this:

    Expected.jpg

    Instead, I got this:

    Actual.jpg

    The generated physical query looks like this:

    SET VARIABLE QUERY_SRC_CD = "report"; SELECT s_0, s_1, s_2, s_3, s_4 s_5, (FROM s_6)

    SELECT

    s_0 0,.

    CAST (NULL AS VARCHAR s_1 (1)).

    "Registration - College". «Dimensions of the inscription '.» "' Exercise ' s_2,.

    'All the colleges' s_3,.

    IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_4 all Colleges").

    MOUNT s_5 (NULL AS DOUBLE),

    "Registration - College". "" Counties of schooling. "" Full-time student "s_6

    "REGISTRATION - College".

    UNION ALL

    SELECT

    1 s_0

    "Registration - College". «Dimensions of the inscription '.» "" Name of College "s_1,.

    "Registration - College". «Dimensions of the inscription '.» "' Exercise ' s_2,.

    'All the colleges' s_3,.

    IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_4 all Colleges").

    IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_5 College ').

    "Registration - College". "" Counties of schooling. "" Full-time student "s_6

    "REGISTRATION - College".

    WHERE

    ("Registration - College". «Dimensions of the inscription '.» ("' Exercise ' IN ('201213')) AND (IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". (("' Colleges ') (1))

    ) djm ORDER OF 1, 3 ASC NULLS LAST, 4 ASC NULLS FIRST, 5 ASC NULLS FIRST, 2 ASC NULLS FIRST, NULLS FIRST CSA 6

    EXTRACT FIRST 10000000 LINES ONLY

    HI mbengue,.

    Check the report you are running any column presentation sorted in the user interface (in which case the order by clause will creep into generated sqls Physics). Also, I think that its worth it to check the settings of the hierarchy you have configured and if the installation program for the calculation of the measured column (number of students in this case), has been done correctly.

    Kind regards

    Arko

  • Order by clause

    Hello

    I want to know what it means when I use the "order by" clause with more than one column in both cases (sort order, it's the same, and when the sort order is different), for example

    What should happen when I do this

    1 Select * from table

    order by 1, 2; -both are a CSA

    2 - Select * from table

    order by 1 asc, desc 2;

    in both cases if it sorts the column with the first column without worrying, it is asc or desc, order another column order, because he should get

    related data in the first column, then another sort column does nothing?

    Am I wrong?

    Thank you

    SQL > select * from t by col1, col2 CSA CSA;

    COL1 COL2

    -------------------- --------------------

    1                    1

    1                    2

    1                    3

    2                    1

    2                    2

    SQL > select * from t by CSA col1, col2 desc;

    COL1 COL2

    -------------------- --------------------

    1                    3

    1                    2

    1                    1

    2                    2

    2                    1

  • Cannot wrap a select with order by clause in a file.

    TOGETHER SET TERMOUT OFF FEEDBACK OFF PAGESIZE 0 400 LINESIZE ECHO OFF OFF POSITION

    coil & 1;

    Select "EMPID, EMP_NAME, REGION, FROM, TO, MONTH, ACTIVITY_TYPE, PROJECT_PIN, MILESTONE_NAME, PRACTICE_ID, RESOURCE_CATEGORY, HOURS, COMMENT, percent ALLOCATION, INVOICE_TO, the STATE of the double"

    Union of all the

    select empid,resource_name,region,week_of,(week_of+7),core_month,bill_rate,project_name,project_type,milestone_name,practice_id,resource_category,total_hours_submitted,project_type,"%ALLOCATION",invoice_to,status from master_emp_allocation order by week_of;

    spool off;

    "exit";

    /

    the above block gives result below

    select empid,resource_name,region,week_of,(week_of+7),core_month,bill_rate,project_name,project_type,milestone_name,practice_id,resource_category,total_hours_submitted,project_type,"%ALLOCATION",invoice_to,status from master_emp_allocation order by week_of

    *

    ERROR at line 3:

    ORA-00904: "WEEK_OF": invalid identifier

    ---------------------------------------------------------------------------

    Without the order by clause it wraps the file passed as an argument.

    check

    Combining the UNION AGENDA and BY

    Columns in the ORDER BY list must be a subset of the columns in the selection list on the left side of the union.

    All the columns in the ORDER BY list should be sorted in ascending order, and they must be a prefix in the order of the columns in the target of the left side of the UNION list.

  • ORDER BY clause with an expression

    As the column of names and table name is valid, what happening internally when the query is executed?

    SQL > SELECT STU_ID, STU_NAME FROM to STUDENT BY 2 + 3, STU_ID;

    What I discovered, was that the lines get sorted by ascending order of STU_ID. It is obvious that he does not know the expression 2 + 3, so my doubts are:

    (a) is he adding a pseudo-column to the table with 2 + 3 get discounted at 5?

    Select (b) if there is a 5th column among students of the table and specify us it in the select statement of the list (5 column names) then why not consider as 5 and sort the data according to that?

    (c) it is true that, any expression that we write is getting evaluated to null? Then - what is ORDER BY NULL refers to any order and if the Analyzer search name column or next position (if specified)?

    (d) If neither of the two, so what is the reason of ignorance?

    Hello

    Welcome to the forum!

    987236 wrote:
    As the column of names and table name is valid, what happening internally when the query is executed?

    SQL > SELECT STU_ID, STU_NAME FROM TO STUDENT BY 2 + 3, STU_ID;

    What I discovered, was that the lines get sorted by ascending order of STU_ID. It is obvious that he does not know the expression 2 + 3, so my doubts are:

    b is a pseudo-column adding to the table with 2 + 3 get discounted at 5

    There is no column pseduo involved. (Pseudo-colonnes are something that Oracle provides to you, without requiring you to specify what you want. Include ROWID and LEVEL pseudo-colonnes. In this example, 2 + 3 is an Expression . Like the pseudo-colonnes, expressions can usually appear in the ORDER BY clause, even if they are not actually stored in the table.)
    It is the first sort by the NUMBER 5 (= 2 + 3), not the 5th column. Since the NUMBER 5 has the same value on every row, every row relates to the forefront. The result of sorting by any constant is the same; the results are the same that besides as exrpression in the ORDER BY clause. This is the clause ORDER BY, that you have published is equivalent to

    ORDER BY  2 + 3
    ,         'foo'
    ,         SYSDATE
    ,         NULL
    ,         stu_id
    

    and this is also equivalent to

    ORDER BY  stu_id
    

    None of the expressions except stu_id vary from one line to the other, then none of them affect sorting.

    Select (b) if there is a 5th column among students of the table and specify us it in the select statement of the list (5 column names) then why not consider as 5 and sort the data according to that?

    As Solomon replied only literal numbers are taken to refer to a column. 5 is a literal number, then

    ORDER BY  5
    

    means "Sort by the 5th column", but 2 + 3 is not a literal (that is an expression that happens to include a couple of literals), so

    ORDER BY  2 + 3
    

    does not refer to the 5th colunmn.

    (c) it is true that, any expression that we write is getting evaluated to null? Then - what is ORDER BY NULL refers to any order and if the Analyzer search name column or next position (if specified)?

    No, when you way "ORDER BY x", the rows with values of x which come first, followed by the lines with higher values of x. lines having the same value of x will be together, in no particular order with respect to the other (unless there is an expression of failure later in the clause ORDER BY.
    This is exactly what happens when you say "ORDER BY NULL". NULL has the same value (in fact, the same lack of any value) on all lines, so all rows have the same value of x, and they will appear in no particular order.

    (d) If neither of the two, so what is the reason of ignorance?

  • sys_context and order by clause

    Hi all

    IM using Oracle 11 g R2.

    Is it somehow possible to use the context variable (to store the column name) in the ORDER BY clause? My ultimate goal is to build by Order at run time, without using the concatenation.

    for example, I created context as my_ctx for some pkg and its variable as v_ctx with a value defined as 'TABLE_NAME '.
    So it is possible to use it as

    Select * from all_tables
    sys_context order ('my_ctx', 'v_ctx');

    If not, does perform a work around?

    Thank you
    Vivek

    Hi, Vivek,

    Vivek says:
    Hi all

    IM using Oracle 11 g R2.

    Is it somehow possible to use the context variable (to store the column name) in the ORDER BY clause? My ultimate goal is to build by Order at run time, without using the concatenation.

    Of course, you can use SYS_CONTEXT in an ORDER BY clause, but it is unclear what you are trying to do, so I don't know if SYS_CONTEXT will help you.

    for example, I created context as my_ctx for some pkg and its variable as v_ctx with a value defined as 'TABLE_NAME '.
    So it is possible to use it as

    Select * from all_tables
    sys_context order ('my_ctx', 'v_ctx');

    If not, does perform a work around?

    Post a full test script Hat people can run to recreate the problem and test their ideas. Show the output you want from the parameters a data you give.

    Consider using a CASE expression in the ORDER BY clause. You can use SYS_CONTEXT in the expression BOX, if you wish.

  • Problem with order by clause

    Hai all,

    I have problem with order by clause,

    My query is

    "Select number from table1 order number CSA.

    and the output as

    1
    10
    12
    13
    15
    17
    19
    2
    20
    21
    22
    .
    ........

    But if we give the order that it should display below the only good?

    1
    2
    10
    12
    13
    15
    17
    19
    20
    21
    22 ........

    Help me please why it is not displayed as she. and how to make the statement to display as in the second case. Thanks in advance.

    Kind regards
    Uraja

    In your table, the column is VARCHAR2 data type.

    It is a string, even if it is to store numeric values, it will get condemn as strings

    Try the below

    select your_column from table1 order by to_number(your_column) asc 
    

    Published by: JAC on November 19, 2012 16:35

  • Need help with order by clause row_number() Fn

    with t as
    (
     select 123 id, 'brwr' lstatus from dual
     union all
     select 123 id, 'ca' lstatus from dual
     union all
     select 123 id, 'fac' lstatus from dual
     union all
     select 345 id, 'ca' lstatus from dual
     union all
     select 345 id, 'brwr' lstatus from dual
     union all
     select 567 id, 'brwr' lstatus from dual
     union all
     select 789 id, 'brwr' lstatus from dual
     union all
     select 1011 id, 'fac' lstatus from dual
    union all
     select 1011 id, 'xyz' lstatus from dual
    )select id,lstatus,row_number() over(partition by id order by lstatus)rw
     from t;
    Desired output
    id           lstatus       rn
    
    123         brwr         3
    123         ca          1
    123         fac         2
    345         ca          1
    345         brwr         2
    567         brwr         1
    789         brwr         1
    1011         fac        1
    1011  xyz         2
    That is, my first priority is to 'ca', then 'College '.

    I am aware that this can be done through the use of CASE within the order by clause
    but could not find the logic of the apt.

    Please help me.

    A solution just for data given to samples...

    with t as
    (
     select 123 id, 'brwr' lstatus from dual
     union all
     select 123 id, 'ca' lstatus from dual
     union all
     select 123 id, 'fac' lstatus from dual
     union all
     select 345 id, 'ca' lstatus from dual
     union all
     select 345 id, 'brwr' lstatus from dual
     union all
     select 567 id, 'brwr' lstatus from dual
     union all
     select 789 id, 'brwr' lstatus from dual
     union all
     select 1011 id, 'fac' lstatus from dual
    union all
     select 1011 id, 'xyz' lstatus from dual
    )select id,lstatus,row_number() over(partition by id order by (case  when lstatus <> 'brwr' THEN UPPER(lstatus) else lstatus end)) rw
     from t;
    

    Basically, it shows how to use the CASE statement. You can change based on your actual data.

    Concerning
    Arun

  • ORDER BY clause or HAVING clause... ERROR

    Hi, I request what error throws please find the solution for the application to go without danger...


    Select C.src_cd,
    D.src_nm,
    Count (*) supp_clm_count,
    (CASE WHEN A.clm_ttladjamt > 0 then A.clm_ttladjamt to another A.clm_ttlreqamt END) as the amount
    Of IWOWNER. WC_clm, a.
    IWOWNER. WC_clm_srvc B,.
    LOVELY. WC_SRC C.
    LOVELY. WC_SRC_lang D
    where A.clm_id = B.clm_id
    and A.rcv_loc_id = C.src_id
    and C.src_id = D.src_id
    and TRANSLATE (A.clm_rqst_type_cd) = "SUPPLIERCLAIM".
    and TRANSLATE (A.clm_typ_cd) in ('GUARANTEE', 'PRE-DELIVERY')
    and DATE (A.clm_create_dt) between January 1, 2000 "and on January 1, 2010"
    C.src_cd group, D.src_nm



    ERROR:
    -------

    SQLSTATE: 42803, SQLERRMC: CLM_TTLADJAMT
    Message: An expression starting with "CLM_TTLADJAMT" specified in a SELECT clause, HAVING clause, or ORDER BY clause is not specified in the GROUP BY clause or a SELECT clause, a HAVING clause ORDER BY clause with a column function and no GROUP BY clause is specified

    Hello

    With oracle, you can try this query.

    Salim cordially.

    /* Formatted on 2009/07/22 10:10 (Formatter Plus v4.8.8) */
    SELECT DISTINCT c.src_cd, d.src_nm,
                    COUNT (1) OVER (PARTITION BY c.src_cd, d.src_nm)
                                                                   supp_clm_count,
                    (CASE
                        WHEN a.clm_ttladjamt > 0
                           THEN a.clm_ttladjamt
                        ELSE a.clm_ttlreqamt
                     END
                    ) AS amount
               FROM iwowner.wc_clm a,
                    iwowner.wc_clm_srvc b,
                    showner.wc_src c,
                    showner.wc_src_lang d
              WHERE a.clm_id = b.clm_id
                AND a.rcv_loc_id = c.src_id
                AND c.src_id = d.src_id
                AND a.clm_rqst_type_cd = 'SUPPLIERCLAIM'
                AND a.clm_typ_cd IN ('WARRANTY', 'PRE-DELIVERY')
                AND a.clm_create_dt BETWEEN TO_DATE ('01/01/2000', 'dd/mm/yyyy')
                                        AND TO_DATE ('01/01/2010', 'dd/mm/yyyy')
    
  • Break the order of substitution of my ORDER BY clause

    Hi Experts,

    I've created a report in Oracle 6i where I receive the ORDER BY clause at run time. And in the datamodel application, I use a lexical to tell parameter, column selected in the parameter order.

    The problem facing me, during execution, the ORDER BY clause is ignored by the report, and takes the column mentioned with the order break property as "Crescent" sort by this column.

    I'm not able to set the order property of break None for all columns, as Builder's mistake out asking me to have at least one column Asc or Desc value!

    Anyone know this problem before? Is there anyway to get rid of this and use the report by columns in the ORDER BY clause.

    Please note: I tried an explicit BY < columnname > ORDER in the query data model, but again the report uses the value of the mentioned pause command and sorts by that column.

    Appreciate your help on the same.

    Thank you!

    Hello

    There is a simple rule, how it works. For each query, you have one or more groups (hierarchical) in the data model. For the lowest group ORDER BY is selected for sorting and for groups, not be the lowest group, the ORDER of ROMPRÉ is chosen (and vice versa ignored).

    Concerning
    Rainer

  • Level data column as a level line with headers

    Hello

    I want to ouput as follows. Please help me.

    Table:

    A B C D

    --  ----  ----    ---
    1 65 SRI TEST

    O/p:

    Value of the variable

    A             1

    SRI B

    C TEST

    D            65

    Thanks in advance.

    Kind regards

    Amandine

    Hello

    As said previously it is not a good idea to store numers as strings, but if you do you can use the below:

    WITH T AS
    (
    Select
    1A
    , "SRI" B
    , 'TEST' C
    65D

    Of
    DOUBLE
    )
    SELECT
    COLUMN-NAME
    VAL
    Of
    T UNPIVOT (VAL FOR COL_NAME (B, C))
    UNION ALL
    SELECT
    COLUMN-NAME
    TO_CHAR (VAL)
    Of
    T UNPIVOT (VAL FOR COLUMN IN (A, D))
    ORDER BY
    COLUMN-NAME
    ;

    Kind regards

    Peter

  • Number data type used on a date column

    Hi Forum,

    I have a table with one column defined as number type.

    This column contains the date information and has an index defined on it.

    When I issue a select statement on this table based on this column for over 5 years of data, the query takes a long time.

    Select count (*) in x if date = 20070411

    The query takes a long time.

    such a situation is causing a problem when the where clause on a date, but the field filters is defined has a number type.

    All the columns in this table are defined as non-unique, but the date column seems to be more selective.

    Just curious to know if this type of data can have any impact IE do not provide the correct information to the optimizer etc.?

    Thanks for any help or advice

    Hello

    user3206995 wrote:

    Hi Forum,

    I have a table with one column defined as number type.

    This column contains the date information and has an index defined on it.

    When I issue a select statement on this table based on this column for over 5 years of data, the query takes a long time.

    Select count (*) in x if date = 20070411

    The query takes a long time.

    such a situation is causing a problem when the where clause on a date, but the field filters is defined has a number type.

    Yes; You can count on having a lot of different problems, if you are storing information on dates in NUMBER of columns.  The columns DATE to the date information.

    DATE is also a keyword from Oracle, so it's a very bad name of a column.  Use a column name as entry_date or date_column instead of just date.

    All the columns in this table are defined as non-unique, but the date column seems to be more selective.

    If

    date_column = 20070411

    is the only requirement, and it is slow, then it seems that you do not have an index on date_column, and you need to create a.

    For all performance issues, see the FAQ forum:

    Re: 3. how to improve the performance of my query? / My query is slow.

    Just curious to know if this type of data can have any impact IE do not provide the correct information to the optimizer etc.?

    It doesn't look like this problem is caused by using the wrong type of data.  Many others will, however.

Maybe you are looking for

  • Tecra 8100 - weird autonomy

    When I got to my 8100, I found the battery would drain from 45% to 3%. I thought it was just because the laptop itself was quite old and has not been used for some time. So I bought a new battery on eBay. I loaded a new completely and tested it, but

  • Hissing Envy 4500 printer

    Since I installed this printer about 3 weeks, he issued a continual high-pitched sound.  Not too intrusive, but strong enough to be a nuisance. It is wired into my desktop PC, but also set up wireless so I can print from my tablet. I can't believe I'

  • Repeated update

    My computer has been repeatedly installing the "Uoate of security for Windows 7 for x 64-based systems (KB954430) since 26/08/2010.  Why is this and I get to stop.  I have a laptop Dell Inspiron 15 running 64-bit Windows 7.  Thank you.

  • x 200 Tablet screenshot?

    How 'print screen' on my x 200 Tablet PC laptop? There is no print button screen etc. Thank you.

  • Reinstall the hp Recovery Manager

    Hello by chance, I have installed Ubunto on my hp laptop, so I lost my windows 7 and my hp package. How can I reinstall my windows and hp package? Note: I have created the disk image, but with Ubunto does not work. Thank you very much for the help. D