Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 22nd, 2012, 03:03 AM
hamed88 hamed88 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 hamed88 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #2  
Old December 11th, 2012, 09:42 AM
LKBrwn_DBA's Avatar
LKBrwn_DBA LKBrwn_DBA is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2006
Posts: 751 LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 2 h 56 m 5 sec
Reputation Power: 348
Thumbs down

Quote:
Originally Posted by hamed88
Hello EveryBody!
I tried to make my Query as simple as possible but also it contains the problem:
. . . Etc . . .
what's wrong in my sql query?

Normally the problem can be found between the chair and the keyboard.
Try this:
Code:
SELECT a.id, a.attachment, a.createdatetime, a.no
     , ROW_NUMBER () OVER (ORDER BY b.of0) AS rownumber
  FROM (SELECT a.id, a.attachment, a.createdatetime, a.no, b.of0
          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) a
/

__________________

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Oracle problem with using Both OrderBy & ROwNum

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap