IFNULL Equivalent for Date Columns
Hello experts,
is it possible to have an ifunull like function for dates that aren't there in the DB on 10g. For example I get the date format in 00/00/00 and I want it to show 'N/A' instead.
Best Regards
Hi zaid,
Write a case function on the date column f(x) like this,this will work
case when date='00/00/00' then 'N/A' else date end;
UPDATE POST
check your date column data type....if its date or varchar.....change according to your requirment by using it in RPD
like cast(date as varchar) then at answers end you apply this case function in f(x)
Hope answers your question.
Cheers,
KK
Edited by: Kranthi on Feb 8, 2011 2:41 AM
Similar Messages
-
APEX_UTIL.IR_FILTER with BETWEEN operator for date columns
Hi,
when I run my application I can set a BETWEEN-filter for date columns. I can't find a way how to use it with the APEX_UTIL.IR_FILTER function. Maybe I miss something?
Documentation: http://download.oracle.com/docs/cd/E17556_01/doc/apirefs.40/e15519/apex_util.htm#CHDDDFBF
TobiasTobias,
If you think about it, a "Between" is nothing more than a single line way to say
WHERE :X >= :Y
AND :X <= :Z
So you should be able to apply two filters to the report using the LTE and GTE operators
Hope this helps
Doug Gault
www.sumneva.com -
Using number datatype for date column
Hi
Is there a side effect for using "number" datatype for "date" column?
If so, what is the disadvantage?
Many thanksHi,
Ora_83 wrote:
Hi
Is there a side effect for using "number" datatype for "date" column?
If so, what is the disadvantage?Yes, there's a definite disadvantage.
Oracle provides date arithmetic and a number of functions for manipulating DATEs. None of them work with numbers.
For example,
SELECT TRUNC (order_date, 'MONTH') AS order_month
, AVG (ship_date - order_date) AS avg_delay
FROM orders
GROUP BY TRUNC (order_date, 'MONTH')
;order_month involves a DATE function; it's pretty easy to find the month that conatins order_date.
avg_delay involves date arithmetic. It's extrememly easy to find how much the time passed between order_date and ship_date.
Depending on how you code dates as numbers, doing either one of the above may be just as easy, but doing the other will be very difficult. You'll waste a lot of effort converting the NUMBERs to real DATEs whenever you need to manipulate them.
Validation can be very difficult for NUMBERs, also.
Watch this forum. It's a rare day when there's not some question about how to get around a problem caused by storing dates in a NUMBER (or VARCHAR2) column. Don't add to that. Always use DATE columns for dates. -
JQuery format mask for date columns in tabular form
Hi,
How can I apply jQuery format mask for date columns in a tabular form?
Thanks.
AndyOK, I realized I didn't choose the default type as "Pl/SQL Expression", now it's working correctly.
Thank you very much! -
Attached document for data column in BPS Web application
Hi,
I have created layout for a BPS application, the layout has been configured to have the ability to allow the used to create the attached documentd for the data column. when the user open the layout through the planning profile, the icon for those documents is displayed and can be open by click those icons. After we generated the Web applicatios, those icons are gone and the user can not open them any more.
I notice that there is document subcomponent under BPS-WB, I added that subcomponent to my web layout, it still not work.Anybody know how to display the attached documents on the Web, Is this doable?Hi Marc,
I did exactly what you mention in your responce e-mail, but it still not work coreectly.
following is my propperty configuration for layout and documents:
Planning layout (layout_lay01)
Only ready for output: True
Row/Cell Selection: Cell
Event on selection: true
Document on planning layout (Document1)
Layout: = layout_lay01
Only ready for output: false
When I launch the application through the Tcode BPS_WIF0
There is no document icon display for each data columns which can been in UPSPL. Instead there is a generic document input/display space under the lauout,however there is no any document display within the box, and I can not input anything within the document box. I changes some of the property for the layout and document, but it not work.
Did I forget some thing? -
Edit Renderer for Date columns
I tried to use EditRenderer for a column that is a Date. BC4J automatically renders this as DateField, but I don't want this, so I set the EditRenderer to something else. But it seems BC4J ignores this and renders it as DateField (for Varchar fields it works well).
I use JDev 9.0.3.3 and UIX+JSP.I found it out: on the Control Hints tab change the Control type from "default" to "edit" and the EditRenderer works
-
Performance question for date column
Hi All,
I have a select query which joins two tables with more than 20 million records each based on a where condition of year = 2006. Would creating an function based index on the date column help improve the performance. Please suggest any other alternatives. The query is supposed to return about 10 million records which is taking about 10 hrs right now. How can I improve the performance.
ThanksRob, Here is the explain plan. Any suggestions based on this information. Please refer me to any information on how to interpret this information. Thanks
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 101K| 10M| | 173K| | |
| 1 | HASH JOIN | | 101K| 10M| 3088K| 173K| | |
| 2 | PARTITION RANGE ALL| | | | | | 1 | 9 |
| 3 | TABLE ACCESS FULL | Table A | 101K| 1888K| | 87464 | 1 | 9 |
| 4 | PARTITION RANGE ALL| | | | | | 1 | 9 |
| 5 | TABLE ACCESS FULL | Table B | 156K| 13M| | 85454 | 1 | 9 | -
Which type of index is useful for date columns with time stamp
Hi all,
I am using date column in the where clause of an SQL Query. The values stored in the date column are includes timestamp. The query is very slow and there is no index on the date column.
Can any body suggest which index is better on date columns
ThanksI am using date column in the where clause of an SQL Query.Dates a re hard queries to tune. This ...
WHERE start_date BETWEEN to_date('01-SEP-05') AND to_date('02-SEP-05')...probably requires a very different execution plan to this...
WHERE start_date BETWEEN to_date('01-JAN-01') AND to_date('02-SEP-05')Just bunging an index on the date column may speed up your specific query but break something else. So be careful.
Cheers, APC -
Help ! for date column type
Hi,
I am having two tables tdz12 and tdf31. TDF31 is a date field. and TDZ12 is transactions history table. If I do
11:30:39 SQL> alter session set nls_date_format='DD-MON-RRRR HH24:MI:SS';
11:30:57 SQL> select c65201 from tdf31;
C65201
30-NOV-2006 00:00:00
11:46:48 SQL> select distinct a9000 from tdz12 where a9000 >= '01-NOV-06';
A9000
01-NOV-2006 00:00:00
02-NOV-2006 00:00:00
03-NOV-2006 00:00:00
04-NOV-2006 00:00:00
06-NOV-2006 00:00:00
07-NOV-2006 00:00:00
08-NOV-2006 00:00:00
09-NOV-2006 00:00:00
10-NOV-2006 00:00:00
11-NOV-2006 00:00:00
13-NOV-2006 00:00:00
14-NOV-2006 00:00:00
15-NOV-2006 00:00:00
16-NOV-2006 00:00:00
17-NOV-2006 00:00:00
18-NOV-2006 00:00:00
20-NOV-2006 00:00:00
21-NOV-2006 00:00:00
22-NOV-2006 00:00:00
23-NOV-2006 00:00:00
24-NOV-2006 00:00:00
25-NOV-2006 00:00:00
27-NOV-2006 00:00:00
28-NOV-2006 00:00:00
29-NOV-2006 00:00:00
30-NOV-2006 00:00:00
26 rows selected.
If I do
11:26:39 SQL> select sum(a9060)
11:27:52 2 from tdz12
11:27:52 3 where A9000>=(select to_date(to_char(C65201,'YYYYMM')||'01','YYYYMMDD') FROM TDF31);
SUM(A9060)
0
Why I am getting 0 records ? ( Pl tell me the reason, not alternate way to get records )
thanks & regards
PJPTRUNC(c65201,'MONTH')is a simpler alternative to
TO_DATE(TO_CHAR(c65201,'YYYYMM')||'01','YYYYMMDD')although it will give the same result here. -
"DatePart" Equivalent for a calculated list column
Hello All,
I need to break out dates from a calendar field into separate columns of month and year. In SQL I would just use DatePart, but I can't find a similar function for SP 2010 calculated columns. Is there a DatePart equivalent for calculated columns using just
the web interface?
Also, does anyone know where is the list of functions for calculated columns?
Thanks in advance for the support.
AlcideHi Alcide,
you should be able to do something like =Year([Date column]) for your Year column and =Month([Date column])for your month column
here is a reference of calculated field functions from Microsoft.
http://msdn.microsoft.com/en-us/library/bb862071.aspx
Please let me know if this helps,
Alex -
ORA-01841 Error when value for date col is NULL in .dat (using SQL Loader)
Hello Gurus,
I have some data in .dat file which needs to be loaded into oracle table. I am using SQL * Loader to do the job. Although "NULLIF col_name =BLANKS" works for character datatype, but when value for date col is NULL then I get ORA-01841 error. I have to make NULL for all rows withour value for date column
Early reply will be highly appreciated
FarooqHi,
May be this problem is not with the NULLIF. The value for the date column is not in proper date format.
create table:
create table kk (empno number, ename varchar2(20), deptno number, hiredate date)
Control file:
LOAD DATA
INFILE 'd:\kk\empdata.dat'
insert into TABLE kk ( empno position (1:2) integer external,
ename position(4:5) char NULLIF ename=BLANKS,
deptno position (7:8) integer external NULLIF deptno=BLANKS,
hiredate position (10:20) date NULLIF hiredate=BLANKS)
data file:
10 KK 01-jan-2005
20 10
SELECT * FROM KK;
EMPNO ENAME DEPTNO HIREDATE
10 KK 01-JAN-05
20 10
Verify the data file.
Hope it will help -
Anomaly in Forms6.0 (Especially for Date Field)
Dear all OTN Members,
I Don't have any idea of this "anomaly" happened in my Dev2K. My problem is When I run my form with f60run.exe, everything run as normal as it is. But sometimes, when I get my cursor focused in one field, which have Date datatype, and I try to insert the date (sample : '02-04-2000'), It goes mad. I mean that everytime I try to type the year, it always become '02-04-0002' and the cursor will highlight the field. For additional information, I didn't put any trigger in that field. I think I need some suggestion here, I don't know if it is some kind of bugs or just my Dev2K need to be reinstalled. I have try to run my forms in another PCs, but the anomaly still show up sometimes. I really need help on this. Thanks for your suggestions.Hi Franko,
I just want to confirm whether u are using any calendar to select your date value.I do face problem while selecting a date value from a calendar.The problem is a replica as in your case.Without that looks like forms6i is doin fine for date columns.I shall get back to u in case i find any solutions to ur problems.
Venkatesh C -
Generated schema on a query returns xsd:string for date data type
I'm a complete newbie to oracle's xml generation and have encountered the following problem. But first the important details:
select * from v$version
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
PL/SQL Release 10.2.0.2.0 - Production
"CORE 10.2.0.2.0 Production"
TNS for Linux: Version 10.2.0.2.0 - Production
NLSRTL Version 10.2.0.2.0 - Production
We have a large number of dynamic queries that we would like to generate xml for. I'm currently using the dbms_query.getXML(context, 2) to generate the schema definition for the columns as well as the xml row data. Currently, the problem I have is that the schema definition for date columns is being returned as xsd:string rather than xsd:date. I've no idea why it is coming back that way, and haven't found anything to point me in the direction of any configuration data where this can be changed. Here is the table and code I'm using:
query: select dbms_xmlquery.getxml('select * from clh_xml_test',2) from dual
table definition:
create table CLH_XML_TEST
ID NUMBER not null,
NAME VARCHAR2(50) not null,
DATE_COL DATE,
EMAIL_ADDRESS VARCHAR2(100) not null,
URL VARCHAR2(100) not null,
TIMESTAMP_COL DATE
Sample results:
<?xml version="1.0"?>
<DOCUMENT xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ROWSET">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ROW" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ID" type="xsd:double" minOccurs="0"/>
<xsd:element name="NAME" nillable="true" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="DATE_COL" type="xsd:string" nillable="true" minOccurs="0"/>
<xsd:element name="EMAIL_ADDRESS" nillable="true" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="URL" nillable="true" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="TIMESTAMP_COL" type="xsd:string" nillable="true" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="num" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<ROWSET xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="#/DOCUMENT/xsd:schema[not(@targetNamespace)]">
<ROW num="1">
<ID>779451193</ID>
<NAME>Clh Test</NAME>
<DATE_COL>1/1/2001 0:0:0</DATE_COL>
<EMAIL_ADDRESS>[email protected]</EMAIL_ADDRESS>
<URL>http://www.google.com</URL>
<TIMESTAMP_COL>7/8/2004 10:7:4</TIMESTAMP_COL>
</ROW>
</ROWSET>
</DOCUMENT>
Thank you for your help, let me know if I can provide any additional information.
Chris
Message was edited by:
user538302use DBMS_XMLGEN.
-
Using MODEL clause and COUNT for not numeric data columns....
Hi ,
Is it possible somehow to use the COUNT function to transform a non-numeric data column to a numeric data value (a counter) and be used in a MODEL clause....????
For example , i tried the following in the emp table of SCOTT dataschema with no desired result...
SQL> select deptno , empno , hiredate from emp;
DEPTNO EMPNO HIREDATE
20 7369 18/12/1980
30 7499 20/02/1981
30 7521 22/02/1981
20 7566 02/04/1981
30 7654 28/09/1981
30 7698 01/05/1981
10 7782 09/06/1981
20 7788 18/04/1987
10 7839 17/11/1981
30 7844 08/09/1981
20 7876 21/05/1987
30 7900 03/12/1981
20 7902 03/12/1981
10 7934 23/01/1982
14 rows selected Now , i want to use the MODEL clause in order to 'predict' the number of employees who were going to be hired in the 1990 per deptno...
So , i have constructed the following query which , as expected, does not return the desired results....
SQL> select deptno , month , year , count_
2 from
3 (
4 select deptno , to_number(to_char(hiredate,'mm')) month ,
5 to_number(to_char(hiredate , 'rrrr')) year , count(ename) count_
6 from emp
7 group by deptno , to_number(to_char(hiredate,'mm')) ,
8 to_number(to_char(hiredate , 'rrrr'))
9 )
10 model
11 partition by(deptno)
12 dimension by (month , year)
13 measures (count_ )
14 (
15 count_[1,1990]=count_[1,1982]+count_[11,1982]
16 )
17 /
DEPTNO MONTH YEAR COUNT_
30 5 1981 1
30 12 1981 1
30 2 1981 2
30 9 1981 2
30 1 1990
20 4 1987 1
20 5 1987 1
20 4 1981 1
20 12 1981 1
20 12 1980 1
20 1 1990
10 6 1981 1
10 11 1981 1
10 1 1982 1
10 1 1990 As you see , the measures for the 1990 year is null...because the measure(the count(deptno)) is computed via the group by and not by the MODEL clause...
How should i transform the above query... so as the "count_[1,1982]+count_[11,1982]" will return non-null results per deptno...????
Thanks , a lot
SimonConnected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL>
SQL> SELECT department_id, MONTH, YEAR, count_
2 FROM (SELECT e.department_id
3 ,to_number(to_char(e.hire_date, 'mm')) MONTH
4 ,to_number(to_char(e.hire_date, 'rrrr')) YEAR
5 ,COUNT(e.first_name) count_
6 FROM employees e
7 WHERE e.department_id = 20
8 GROUP BY e.department_id
9 ,to_number(to_char(e.hire_date, 'mm'))
10 ,to_number(to_char(e.hire_date, 'rrrr')));
DEPARTMENT_ID MONTH YEAR COUNT_
20 8 1997 1
20 2 1996 1
SQL> --
SQL> SELECT department_id, MONTH, YEAR, count_
2 FROM (SELECT e.department_id
3 ,to_number(to_char(e.hire_date, 'mm')) MONTH
4 ,to_number(to_char(e.hire_date, 'rrrr')) YEAR
5 ,COUNT(e.first_name) count_
6 FROM employees e
7 WHERE e.department_id = 20
8 GROUP BY e.department_id
9 ,to_number(to_char(e.hire_date, 'mm'))
10 ,to_number(to_char(e.hire_date, 'rrrr')))
11 model
12 PARTITION BY(department_id)
13 dimension BY(MONTH, YEAR)
14 measures(count_)(
15 count_ [1, 1990] = count_ [2, 1996] + count_ [8, 1997]
16 );
DEPARTMENT_ID MONTH YEAR COUNT_
20 8 1997 1
20 2 1996 1
20 1 1990 2
SQL> ---
SQL> SELECT department_id, MONTH, YEAR, count_
2 FROM (SELECT e.department_id
3 ,to_number(to_char(e.hire_date, 'mm')) MONTH
4 ,to_number(to_char(e.hire_date, 'rrrr')) YEAR
5 ,COUNT(e.first_name) count_
6 FROM employees e
7 GROUP BY e.department_id
8 ,to_number(to_char(e.hire_date, 'mm'))
9 ,to_number(to_char(e.hire_date, 'rrrr')))
10 model ignore nav
11 PARTITION BY(department_id)
12 dimension BY(MONTH, YEAR)
13 measures(count_)(
14 count_ [1, 1990] = count_ [2, 1996] + count_ [8, 1997]
15 );
DEPARTMENT_ID MONTH YEAR COUNT_
100 8 1994 2
30 12 1997 1
100 3 1998 1
30 7 1997 1
5 1999 1
30 12 1994 1
30 11 1998 1
30 5 1995 1
100 9 1997 2
100 12 1999 1
30 8 1999 1
1 1990 0
30 1 1990 0
100 1 1990 0
90 9 1989 1
20 8 1997 1
70 6 1994 1
93 rows selected
SQL> -
Get frequent data for each column of a table
What is the best way to get the most frequent data in each column of a table.
we have around 25 tables and each table has around 20 columns , so rather than writing group by for each column of table , is there any easy way to find this?
example we have table
Column A Column B Column C
Apple Monday Red
orange Tuesday Green
Apple Monday Red
Lemon Wednesday Green
Apple Thursday Red
in this table, column A's frequnt data is Apple , column B's frequent data is Monday , Column C's frequnt data is Red
Apple 3 Monday 2 Red 3
Orange 2 Tuesday 1 Green 2
Lemon 1 Wednesday 1
Thursday 1
Group by kind of query will give this result, but with 20 tables each having 20 - 30 columns if we need similar kind of result .. is there any way to get this data.Hi,
GROUP BY (using aggregate functions) is the best way to do what you described.
PIVOT and UNPIVOT are probably what you'd want in this case. The phrase "GROUP BY" may not actually appear in your code, but you'll essentially be doing a GROUP BY.
Analytic functions (rather than aggregate functions) can do the job, too, but they'll be less efficient. Analytic functions get you results about the groups, without losing each row's identify, but in this case, losing each row's identity is eactly what you want to do. You only want 'Apple' to appear 1 time, not 3 times.
The fact that you need to do the same query on 20 different tables suggests that there's something wrong with your table design. Wouldn't it be better to have 1 big table, with a new column that has 20 unique values instead?
I hope this answers your question.
If not, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Simplify the problem as much as possible. For example, instead of posting a problem with 20 tables, each having 25 columns, post a similar problem involving, say, 2 tables, each with 3 columns.
Always say which version of Oracle you're using (for example, 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
Maybe you are looking for
-
Voice memos lost after restore. I've tried everything.
When I plugged my iPhone 5 in a few weeks ago it said it needed to update the software. I clicked OK. It froze hard while doing this. I had to do a restore. That's when I "lost" my voice memos. For voice memos I use the app "Recorder" by Bear-Softwar
-
Hi all I have created an asset PO for 1 computer by assigning A as a Account assignment Category. I have given the asset number and order number(single assignement) in accout assigment tab to which 1 computer is to be issued. I made GR for 1 computer
-
Read details of a sales order using bapi
Hi All, Can somebody tell me how to read details of a sales order that is under creation using a BAPI? Also I need to change some of the parameters eg, pricing details, using some API. Regards, - Prasenjit
-
Error with connecting ipod touch to computer
applemobiledevice stops working and freezes itunes. I've done everything possible to try and fix this, reinstall, turn off firewall, repair the feature, and start/restart the feature. i dont know what to do, i had all my music, videos, and pictures o
-
I want to modify the "find" box to be avble to only search for whole words.
I want to modify the "find" box to look only for matching "whole words," otherwise--it's pretty pointless!!!