
November 22nd, 2012, 03:03 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 1
Time spent in forums: 6 m 15 sec
Reputation Power: 0
|
|
|
Oracle problem with using Both OrderBy & ROwNum
Hello EveryBody!
I tried to make my Query as simple as possible but also it contains the problem:
Code:
SELECT A.Id,A.Attachment,A.CreateDateTime,A.No
,rownum as RowNumber
FROM (
SELECT A.Id,A.Attachment,A.CreateDateTime,A.No FROM GOutgoingLetter A ,
(
SELECT B.Id, B.createdatetime as of0 FROM GOutgoingLetter B
WHERE
Exists
(Select BC.id
From XCase BC, GOutgoingLetterCase BG
Where
-- BG.CaseMechanizeState=1 And
B.id=BG.GOutgoingLetterId
-- And BG.RelatedCaseID=BC.Id
-- And BC.LASTEMPEXPERTMANID='EF38398F7291491898AF63AC0249DDBF'
)
-- OR A.RegistrarUserId = '392182A64BD5499685FFAA2E570344D9'
)B
WHERE A.Id = B.Id
ORDER BY B.of0
)A
the problem is :
when I use Both Order By And RowNum in my Query, Two columns of final Select Are Null: NO & Attachment. whereas this Columns aren't empty.
when I comment each one of "ORDER BY B.of0" or ",rownum as RowNumber " everything is correct!!!
what's wrong in my sql query? 
|