Why this erroneous query works well? -Answer
DB version: 10 gr 2I wanted to reproduce the non-use of rownum when used with an ORDER BY clause.
Because ORDER BY is evaluated finally (after ROWNUMs are generated), the query below give bad result put most of the time.
But the following query
select ename,join_date
from test
where rownum<4
order by join_date
give me a correct result. Then, when this query will start to give erroneous results?alter session set nls_date_format='DD-MM-YYYY HH:MI:SS';
SELECT SYSDATE FROM DUAL;
SYSDATE
-------------------
15-12-2008 11:40:30
create table test
(ename varchar2(15),
join_date date);
insert into test values('JAMES',SYSDATE);
insert into test values('CHESTER',SYSDATE);
insert into test values('SUNITA',SYSDATE);
insert into test values('GARRY',SYSDATE);
insert into test values('KAREN',SYSDATE);
insert into test values('ABDUL',SYSDATE);
insert into test values('YING',SYSDATE);
set lines 400
select * from test;
ENAME JOIN_DATE
--------------- -------------------
JAMES 15-12-2008 11:41:21
CHESTER 15-12-2008 11:41:40
SUNITA 15-12-2008 11:41:56
GARRY 15-12-2008 11:42:17
TIM 15-12-2008 11:42:44
KAREN 15-12-2008 11:52:46
ABDUL 15-12-2008 11:53:01
YING 15-12-2008 11:53:18
CHAICE 15-12-2008 12:14:27
THELMA 15-12-2008 12:14:54
select ename,join_date
from test
where rownum<4
order by join_date;
ENAME JOIN_DATE
--------------- -------------------
JAMES 15-12-2008 11:41:21 --correct
CHESTER 15-12-2008 11:41:40 --correct
SUNITA 15-12-2008 11:41:56 --correct
Published by: Nichols on December 15, 2008 03:37Published by: Nichols on December 15, 2008 03:56
Published by: Nichols on December 15, 2008 04:09
Run the same query, but the order of join_date DESC. You will see that the result is completely incorrect.
The query takes just three records (not the 'top three' - there is no order) and then ordered these records based on the ORDER BY in the final predicate.
Tags: Database
Similar Questions
-
Query works well in an environment, but not in the other environment
Hello
I have a question that I am trying to run in two different environments.
Test: - Oracle Database 11 g Release 11.2.0.1.0 - 64 bit Production
Prod: - Oracle Database 11 g Release 11.2.0.1.0 - 64 bit Production
Now the query runs fine in one environment and fails in the other environment.
It gives following error.
ORA-01861: literal does not match the format string
01861 00000 - "literal does not format string.
The query is too long and contains CHAR-DATE and DATE-CHAR conversions.
The same query works very well on the TEST environment and the PROD environment.
Any help related to it would be appreciated.
Thank you
MaheshMaheshGx wrote:
HelloI have a question that I am trying to run in two different environments.
Test: - Oracle Database 11 g Release 11.2.0.1.0 - 64 bit Production
Prod: - Oracle Database 11 g Release 11.2.0.1.0 - 64 bit ProductionNow the query runs fine in one environment and fails in the other environment.
It gives following error.ORA-01861: literal does not match the format string
01861 00000 - "literal does not format string.The query is too long and contains CHAR-DATE and DATE-CHAR conversions.
The same query works very well on the TEST environment and the PROD environment.
Any help related to it would be appreciated.
Thank you
MaheshThis is called a bug. One caused by the person who developed the code. They relied on an implicit conversion between strings and dates when
production quality code will always use the function to_char and to_date with a format mask. -
Please tell me why this won't work cross-platform (parallax)
http://jeyone.BusinessCatalyst.com
My new test site: http://jeyone.BusinessCatalyst.com
In chipboard with Adobe song > downloaded through Dream Weaver > account BC
IM struggling to understand why this Parallax site or this entire site will not work on iphone 5 or ipad
Simon
Hi Simon,.
iOS does not support Parallax scrolling.
The reason for this, is because Parallax is too heavy on the graphics processor. iOS cannot handle [yet].
-
Update query works well when a subquery in where the article is wrong.
Hello
I executes a statement-update
Update table set Column1 = 2000
where a.column2 in (select column 3 of table b where b.col4 = 111)
Now when I run the subquery: select column 3 of table b where b.col4 = 111-> it gives me the error ' identifier not valid col 3.
But when I run the full query, then it updates the 700 lines.
Can someone there explain please?
My subquery throw error but when I use it in another application it works well.Col_3 must be in your external table (table_a, I guess).
If you always the prefix names of columns with a table alias, you know in an instant.
-
When I open a bookmark a box appears that says "what should firefox with this file?" open with Internet Explorer? When I browse I don't find firefox to change. Last week this bookmark worked perfectly.
Start Firefox in Firefox to solve the issues in Safe Mode to check if one of your modules is causing your problem (switch to the DEFAULT theme: Tools > Modules > themes).
See the extensions, themes and problems of hardware acceleration to resolve common troubleshooting Firefox problems and troubleshooting questions with plugins like Flash or Java to solve common Firefox problemsIf this does not work in safe mode and then disable all your extensions and then try to find out who is causing by allowing both the problem reappears.
You can use 'Disable all add-ons' on the start safe mode window.
You will need to close and restart Firefox after each change through "file > exit" (on Mac: "Firefox > Quit") -
Why this read_write.vi works in the second inning?
Hello
I'm having a problem with the instrument drivers that I got from Newport.com. Most of instrument drivers for controlling the SMC100 uses a vi file named: read_write.vi, could someone let me know how we can change this vi, it seems to me there are too many false by default on this block diagram, is another way we can simplify this vi? Please see the photo and vi as an attachment.
-
Why faces of Photos work well with Contacts?
I edit a contact in the Contacts and try to add a photo. The contact in question has a face in the Album of the faces in the Photos, but it does not appear when I select the option of face to change the photo in Contacts. What appears is the photos in which appears the face. OK, so I tried zooming in on the particular face and tap done. When I come back to touch the center of the photo is lost and the photo/face has point random zoom? Obviously a bug, but what is the fix or workaround?
-
materialized view ora-00907, although sql query works well
Hello
It seems to be a bug with db oracle 10.2.0.1 and his prod. env, I can't apply the patch quickly, can anyone give me a tip
CREATE THE MV_TEN MATERIALIZED VIEW
BUILDING THE INDEX REFRESH IMMEDIATE TO COMPLETE ON DEMAND HELP
AS
SELECT ten.tcy_refno AS TENANCY_REF,
Rev.rac_accno AS REV_ACC_NO,
Rev.rac_last_aba_date AS LAST_ABA_DATE,
Rev.rac_last_aba_balance AS LAST_ABA_BALANCE,
AAA.aca_status AS ARREARS_STATUS,
AAA.aca_ara_code AS ARREARS_ACTION_CODE,
AAA.aca_effective_date AS EFFECTIVE_DATE,
AAA.aca_balance AS ACCOUNT_BALANCE,
ARA.ara_description AS ARREARS_DESCRIPTION,
NPA.nop_text
OF REVENUE@remotedb rev.
Ten TENANCT@remotedb.
ACCOUNT_ARREARS_ACTIONS@remotedb aaa
LEFT OUTER JOIN ARREARS_ACTIONS@remotedb ara
ON aaa.aca_ara_code = ara.ara_code
LEFT OUTER JOIN NOTEPADS@remotedb IR
ON aaa.aca_reusable_refno = npa.nop_reusable_refno
WHERE ten.tcy_refno = rev.rac_tcy_refno
AND rev.rac_end_date IS NULL
AND rev.rac_accno = aaa.aca_rac_accno
AND aaa.aca_status! = "DEL".
AND npa.nop_current_ind = 'Y ';
ORA-00907: missing just paraenthesis
Thank youSee
http://asktom.Oracle.com/pls/asktom/f?p=100:11:4226402560732847:P11_QUESTION_ID:6585774577187
-
query works not in the APEX but works in TOAD
Hello
I had major problems trying to build a LOV cascading. I narrowed the problem down to SELECT which it depends.
I have the following:
SELECT pasv.vendor_name
pasv.vendor_site_code
pasv.vendor_id
pasv.vendor_site_id
OF po_asl_suppliers_v pasv
po_asl_documents_v padv
po_asl_attributes_v paav
WHERE pasv.owning_organization_id = 26
AND pasv.item_id = 131089
AND pasv.asl_id = padv.asl_id
AND pasv.asl_id = paav.asl_id
AND padv.document_type = 'COVERAGE '.
ORDER BY pasv.vendor_name
pasv.vendor_site_code
This query works well as a TOAD, but when I run it in APEX "SQL commands" it comes up with the error "ORA-01722: invalid number ' and when I try to generate a report about this no return value (the values are returned when you run the same query in TOAD and SQL Developer)."
Any advice would be great.
Thank you
ChrisWork around:
SELECT RPAD (SUBSTR (pasv.vendor_name, 1, 20), 20,' ') | » '|| RPAD (SUBSTR (padv.document_type, 1, 20), 20,' ') | RPAD (SUBSTR (padv.document_num, 1, 10), 20,' ') PROVIDER
pasv.vendor_id
OF po_asl_suppliers_v pasv
po_asl_documents_v padv
po_asl_attributes_v paav
WHERE pasv.owning_organization_id = 26
AND pasv.item_id = 131089
AND pasv.asl_id = padv.asl_id
AND pasv.asl_id = paav.asl_id
ORDER BY pasv.vendor_name
pasv.vendor_site_codeThere seems to be a problem with the 'COVER' in the first SQL. Even if it is that a field of VARCHAR2 in the APEX database doesn't. It works somehow the other tool we use.
-
Why this project generates endless seen during rendering?
Summary:
I have a sequence with three video tracks and a track audio discrete, all synchronized. If I change the order of the video tracks and press on "make in out", rendering never stops as new insights are continually being added to the queue of rendering!
Details:
I'm working on a project of three cameras. So far the key steps:
-three cams on three tracks 17 place video clips and synchronized to them.
-Added a track audio discrete it synced, then deleted the other audio tracks.
-Back up the track audio discrete position of "A1".
-Began rough cut three video tracks.
Soon, I saw that the Cup would be better with camera main, stacked on top, in the "V3" position, not on the bottom in the position "V1". So I just picked all V1, V3, up dragged taking care to snap into place to keep synchronized. Then I deleted the now empty V1 track, all three tracks moving down a position.
I hit "Render in to Out" before attempting to save the new arrangement of track. The render window popped up, showing 17 previews to display. So far so good.
I moved away, came back an hour later and the render said "Rendering 137 137!" window previews And the number has increased to the second! The green progress bar has been pinned to "99,32% complete" and would go no further.
I have let it run again 20 minutes and the window rendering said "Rendering 304 of 304 previews" or something, the number continues to climb.
So I cancelled the operation. I sketched a similar experiment project. Whenever I tried the same maneuver - travel one video track to a position higher - I had the same problem.
I could start this project with the cams in the right order, but that would be a pain. In addition, I would like to know why this does not work, for later use.
Thanks for your time.
Very nice report, but you let it point to a given key. What body version are you running? A bug that looks like a Dead Ringer for you a statement has been fixed in the 2014.0.1 update that was released last week.
Here is a thread to discuss the issue which has been fixed: Re: number of video previews goes up infinitely then made
-
Why this SQL does not work?
The following code does not work when I try to delete rows from a table of test. The test table has no unique or primary key on it and is defined as test (identification number). Can you explain to me why it doesn't work?
delete from test a where a.rowid in (select b.rowid from test b where b.id = a.id and b.rowid != a.rowid);
When I run the subquery (selection) with replacement of the actual values of a.rowid and the table queried a.id (IE.
select b.rid from test2 b where b.id = 1 and b.rid != 'XXX'
), the subquery returns exactly as expected (that is to say, it gives the rowid is different from that which went from subquery). And as although I know the internal subquery must return the result for each row of the table in the outside circle delete statement, and only after that should execute the delete statement. For example, for the first row of the table in the external suppression, the delete statement must send the ID of the first row in the internal subquery and then wait the result which should return. And then runs the delete statement, in which case the subquery must return the rowid is different from that which went from subquery (ie.
). Am I wrong? What is the error in this statement.b.rowid != a.rowid
P.S. The sql is also not working if we replace remove it with the update or select
in this case, the subquery must return the rowid is different from that which went from subquery (IE.
b.rowid != a.rowid
). Am I wrong? What is the error in this statement.
You are right that this subquery should return other than past rowid thr. But you used the IN clause as well as below:
where a.rowid in
What States remove the line if rowid returned by the subquery contains the identifier for the row whose ID was passed. As the inner query is to return another rowid, therefore, no row is deleted.
To remove duplicate lines, try the query (Replace tablename/columns with your) below:
DELETE FROM emp A
WHERE A.ROWID > ALL (SELECT B.ROWID
PEM'S B
WHERE A.empno = B.empno);
-
Why this CASE statement would not work?
If I use a CASE in my SELECT statement and met a strange thing and just need help to understand why he did it.
When I type this, it does not work:
CASE TRIM (Column1)
WHEN NULL THEN Column2
WHEN 'foo' THEN Column2
Of ANOTHER Column1
END AS NewColName
I use this query in an Oracle procedure to insert data into another table. The data inserted in the column of NewColName end up being 4 empty spaces, located in Column1. In the logic of this, TRIM must remove all the empty spaces, and he should get mapped to the first statement WHEN, who must insert the value of Column2, but that does not occur. I tried the following versions of the first line as well:
LTRIM (RTRIM (Column1)) CASE
CASE of REPLACE (Column1, ' ', ")
and they all produce the same result. I also tried to change WHEN NULL for WHEN " and it changed nothing. However, when I rewrite the statement in this way it works the way it should:
CASE
WHEN TRIM (Column1) IS NULL, Column2
WHEN TRIM (Column1) = 'foo' THEN Column2
Of ANOTHER Column1
END AS NewColName
In my mind, it seems that these two methods are trying the same thing, why we could work and the other not? Only, it has no sense to me.
Thank youHello
Welcome to the forum.
In your first statement, you have
WHEN NULL THEN.
This is the same as x = NULL.
Nothing is never equal to NULL, if you find yourself in your ELSE clause.
Concerning
Peter -
Why this query produces no output?
Why this query produces no output?
select * from ( SELECT 40 as startvalue, (24 * 60)*(To_Date('00:40', 'HH24:MI') - To_Date('00:00', 'HH24:MI')) as c FROM dual di ) q where q.c = q.startvalue
And just to show that it works if round you...
SQL> ed Wrote file afiedt.buf 1 select * from 2 ( 3 SELECT 40 as startvalue, round((24 * 60)*(To_Date('00:40', 'HH24:MI') - To_Date('00:00', 'HH24:MI')),0) as c 4 FROM dual di 5 ) q 6* where q.c = q.startvalue SQL> / STARTVALUE C ---------- ---------- 40 40
I certainly wouldn't say using TRIM as PS has suggested. TRIM is a string function, not a digital function.
-
Why this simple script script does not work
I'm pretty new to actionscript, I have learned from books, in fact I still am.
The script that I'll try to work on my site, worked well in the teachings of the books.
I don't think that my buttons are different, but why don't they work then.
Can someone figure this.
my script:
Stop();
whoweare.addEventListener (MouseEvent.MOUSE_UP, onNavigate);
function onNavigate (evt:MouseEvent): Void {}
gotoAndPlay ("contact");
}
whatwedo.addEventListener (MouseEvent.MOUSE_UP, onNavigate);
function onNavigate (evt:MouseEvent): Void {}
gotoAndPlay ("slideshow");
}Error: the class or interface 'MouseEvent' could not be loaded.
Help?
Dirkhou,
void not Void in AS3
-
Please tell me why this script does not work with Firefox. It works with Safari. Here is the page that includes the script: www.lionsgatehoa.org/newslettertest.html. Thank you. Tom Engleman
Here's the script in my html document:
< embed src = "News2008Fall.pdf" width = '615' height = '3200' > < / embed > "
Edit: removed # phone
Works for me on Linux.
Your system details list does not display the Adobe Reader plugin, so you'll have to (re) install this program.See:
Maybe you are looking for
-
I use the latest version of firefox, use it awhile.recently, he began to act up, where I get it open, then shut down for one reason or another and he won't start at all (which gives the indicated response).I did a batch file to kill the process for m
-
How can I remove the 0 in this table? Its been a while and I always try to know how to do this. Thank you
-
Microsoft xbox 360 controller for windows problem with NFS
Hi, I brought yesterday Microsoft xbox 360 controller for windows. I installed and the end driver. The problem is that when I play NFS Most Wanted & NFS Carbon, cars automatically starts left thin when I accelerate? Why is - this problem to occur, an
-
How can I change the size of the font of the qml Editor?
-
I just got a call from someone who said they were with Windows and I had a bad infection on my computer, they identified as computer Solutions.