dbTalk Databases Forums  

Finding out erroneous records

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Finding out erroneous records in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Sandy80
 
Posts: n/a

Default Finding out erroneous records - 05-05-2008 , 03:00 AM






Hi,

I have a table that has sample records like below:

Emp No. Unique ID From Date To Date
11 1234 01-Jan-2005 30-Sep-2005
11 2345 01-Oct-2005 31-Oct-2005
11 3456 01-Nov-2005 31-Oct-2005


The task that I have is to find out records where the From Date is
greater than the To Date. This is needed because the 3rd record in the
example above is actually an erroneous record which needs to be
deleted. The query that I was able to write was returning the 2nd
record also because 01-Oct-2005 is greater than 30-Sep-2005. Please
help me with the query which would return only the 3rd record.

Any help would be appreciated...thanks!
Sandy

Reply With Quote
  #2  
Old   
fitzjarrell@cox.net
 
Posts: n/a

Default Re: Finding out erroneous records - 05-05-2008 , 07:39 AM






On May 5, 3:00*am, Sandy80 <svarshneym... (AT) gmail (DOT) com> wrote:
Quote:
Hi,

I have a table that has sample records like below:

Emp No. * * * * Unique ID * * * * * * * From Date * * * * * * * To Date
11 * * * * * * *1234 * * * * * *01-Jan-2005 * * 30-Sep-2005
11 * * * * * * *2345 * * * * * *01-Oct-2005 * * 31-Oct-2005
11 * * * * * * *3456 * * * * * *01-Nov-2005 * * 31-Oct-2005

The task that I have is to find out records where the From Date is
greater than the To Date. This is needed because the 3rd record in the
example above is actually an erroneous record which needs to be
deleted. The query that I was able to write was returning the 2nd
record also because 01-Oct-2005 is greater than 30-Sep-2005. Please
help me with the query which would return only the 3rd record.

Any help would be appreciated...thanks!
Sandy
You've written the query already, albeit in text rather than SQL; I
don't understand what query you've written to return the data you
report as it's likely far more complex than it needs to be.
'Translate', if you will, your English text into SQL and you'll have
your answer:

"find out records where the From Date is greater than the To Date."

The SQL, as shown below, should be easy to write from that description
--

SQL> create table sandy(
2 emp_on number,
3 unique_id number,
4 from_date date,
5 to_date date
6 );

Table created.

SQL>
SQL> insert all
2 into sandy
3 values(11,1234,to_date('01-Jan-2005','DD-Mon-YYYY'),to_date('30-
Sep-2005','DD-Mon-YYYY') )
4 into sandy
5 values(11,2345,to_date('01-Oct-2005','DD-Mon-YYYY'),to_date('31-
Oct-2005','DD-Mon-YYYY') )
6 into sandy
7 values(11,3456,to_date('01-Nov-2005','DD-Mon-YYYY'),to_date('31-
Oct-2005','DD-Mon-YYYY') )
8 select * from dual;

3 rows created.

SQL>
SQL> commit;

Commit complete.

SQL>
SQL> select *
2 from sandy
3 where to_date < from_date;

EMP_ON UNIQUE_ID FROM_DATE TO_DATE
---------- ---------- --------- ---------
11 3456 01-NOV-05 31-OCT-05

SQL>


David Fitzjarrell


Reply With Quote
  #3  
Old   
fitzjarrell@cox.net
 
Posts: n/a

Default Re: Finding out erroneous records - 05-05-2008 , 07:39 AM



On May 5, 3:00*am, Sandy80 <svarshneym... (AT) gmail (DOT) com> wrote:
Quote:
Hi,

I have a table that has sample records like below:

Emp No. * * * * Unique ID * * * * * * * From Date * * * * * * * To Date
11 * * * * * * *1234 * * * * * *01-Jan-2005 * * 30-Sep-2005
11 * * * * * * *2345 * * * * * *01-Oct-2005 * * 31-Oct-2005
11 * * * * * * *3456 * * * * * *01-Nov-2005 * * 31-Oct-2005

The task that I have is to find out records where the From Date is
greater than the To Date. This is needed because the 3rd record in the
example above is actually an erroneous record which needs to be
deleted. The query that I was able to write was returning the 2nd
record also because 01-Oct-2005 is greater than 30-Sep-2005. Please
help me with the query which would return only the 3rd record.

Any help would be appreciated...thanks!
Sandy
You've written the query already, albeit in text rather than SQL; I
don't understand what query you've written to return the data you
report as it's likely far more complex than it needs to be.
'Translate', if you will, your English text into SQL and you'll have
your answer:

"find out records where the From Date is greater than the To Date."

The SQL, as shown below, should be easy to write from that description
--

SQL> create table sandy(
2 emp_on number,
3 unique_id number,
4 from_date date,
5 to_date date
6 );

Table created.

SQL>
SQL> insert all
2 into sandy
3 values(11,1234,to_date('01-Jan-2005','DD-Mon-YYYY'),to_date('30-
Sep-2005','DD-Mon-YYYY') )
4 into sandy
5 values(11,2345,to_date('01-Oct-2005','DD-Mon-YYYY'),to_date('31-
Oct-2005','DD-Mon-YYYY') )
6 into sandy
7 values(11,3456,to_date('01-Nov-2005','DD-Mon-YYYY'),to_date('31-
Oct-2005','DD-Mon-YYYY') )
8 select * from dual;

3 rows created.

SQL>
SQL> commit;

Commit complete.

SQL>
SQL> select *
2 from sandy
3 where to_date < from_date;

EMP_ON UNIQUE_ID FROM_DATE TO_DATE
---------- ---------- --------- ---------
11 3456 01-NOV-05 31-OCT-05

SQL>


David Fitzjarrell


Reply With Quote
  #4  
Old   
fitzjarrell@cox.net
 
Posts: n/a

Default Re: Finding out erroneous records - 05-05-2008 , 07:39 AM



On May 5, 3:00*am, Sandy80 <svarshneym... (AT) gmail (DOT) com> wrote:
Quote:
Hi,

I have a table that has sample records like below:

Emp No. * * * * Unique ID * * * * * * * From Date * * * * * * * To Date
11 * * * * * * *1234 * * * * * *01-Jan-2005 * * 30-Sep-2005
11 * * * * * * *2345 * * * * * *01-Oct-2005 * * 31-Oct-2005
11 * * * * * * *3456 * * * * * *01-Nov-2005 * * 31-Oct-2005

The task that I have is to find out records where the From Date is
greater than the To Date. This is needed because the 3rd record in the
example above is actually an erroneous record which needs to be
deleted. The query that I was able to write was returning the 2nd
record also because 01-Oct-2005 is greater than 30-Sep-2005. Please
help me with the query which would return only the 3rd record.

Any help would be appreciated...thanks!
Sandy
You've written the query already, albeit in text rather than SQL; I
don't understand what query you've written to return the data you
report as it's likely far more complex than it needs to be.
'Translate', if you will, your English text into SQL and you'll have
your answer:

"find out records where the From Date is greater than the To Date."

The SQL, as shown below, should be easy to write from that description
--

SQL> create table sandy(
2 emp_on number,
3 unique_id number,
4 from_date date,
5 to_date date
6 );

Table created.

SQL>
SQL> insert all
2 into sandy
3 values(11,1234,to_date('01-Jan-2005','DD-Mon-YYYY'),to_date('30-
Sep-2005','DD-Mon-YYYY') )
4 into sandy
5 values(11,2345,to_date('01-Oct-2005','DD-Mon-YYYY'),to_date('31-
Oct-2005','DD-Mon-YYYY') )
6 into sandy
7 values(11,3456,to_date('01-Nov-2005','DD-Mon-YYYY'),to_date('31-
Oct-2005','DD-Mon-YYYY') )
8 select * from dual;

3 rows created.

SQL>
SQL> commit;

Commit complete.

SQL>
SQL> select *
2 from sandy
3 where to_date < from_date;

EMP_ON UNIQUE_ID FROM_DATE TO_DATE
---------- ---------- --------- ---------
11 3456 01-NOV-05 31-OCT-05

SQL>


David Fitzjarrell


Reply With Quote
  #5  
Old   
fitzjarrell@cox.net
 
Posts: n/a

Default Re: Finding out erroneous records - 05-05-2008 , 07:39 AM



On May 5, 3:00*am, Sandy80 <svarshneym... (AT) gmail (DOT) com> wrote:
Quote:
Hi,

I have a table that has sample records like below:

Emp No. * * * * Unique ID * * * * * * * From Date * * * * * * * To Date
11 * * * * * * *1234 * * * * * *01-Jan-2005 * * 30-Sep-2005
11 * * * * * * *2345 * * * * * *01-Oct-2005 * * 31-Oct-2005
11 * * * * * * *3456 * * * * * *01-Nov-2005 * * 31-Oct-2005

The task that I have is to find out records where the From Date is
greater than the To Date. This is needed because the 3rd record in the
example above is actually an erroneous record which needs to be
deleted. The query that I was able to write was returning the 2nd
record also because 01-Oct-2005 is greater than 30-Sep-2005. Please
help me with the query which would return only the 3rd record.

Any help would be appreciated...thanks!
Sandy
You've written the query already, albeit in text rather than SQL; I
don't understand what query you've written to return the data you
report as it's likely far more complex than it needs to be.
'Translate', if you will, your English text into SQL and you'll have
your answer:

"find out records where the From Date is greater than the To Date."

The SQL, as shown below, should be easy to write from that description
--

SQL> create table sandy(
2 emp_on number,
3 unique_id number,
4 from_date date,
5 to_date date
6 );

Table created.

SQL>
SQL> insert all
2 into sandy
3 values(11,1234,to_date('01-Jan-2005','DD-Mon-YYYY'),to_date('30-
Sep-2005','DD-Mon-YYYY') )
4 into sandy
5 values(11,2345,to_date('01-Oct-2005','DD-Mon-YYYY'),to_date('31-
Oct-2005','DD-Mon-YYYY') )
6 into sandy
7 values(11,3456,to_date('01-Nov-2005','DD-Mon-YYYY'),to_date('31-
Oct-2005','DD-Mon-YYYY') )
8 select * from dual;

3 rows created.

SQL>
SQL> commit;

Commit complete.

SQL>
SQL> select *
2 from sandy
3 where to_date < from_date;

EMP_ON UNIQUE_ID FROM_DATE TO_DATE
---------- ---------- --------- ---------
11 3456 01-NOV-05 31-OCT-05

SQL>


David Fitzjarrell


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.