Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-server-2005
when i use row_number() with over(partition by) it works fine but when i use the same query at another time i get slightly different output and the reason is order by clause in the partition by clause.
Posted 2-Oct-12 22:54pm
Comments
Achha Insan at 3-Oct-12 5:32am
   
nothing is impossible. you can do it.
Abhijit Parab at 3-Oct-12 5:39am
   
please post your query here
Member 8310253 at 3-Oct-12 5:49am
   
select idno = row_number() OVER(PARTITION BY cltcode ORDER BY defaultbank DESC,LEN(ACCNO) desc) into #bank from .....
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

please let me know some alternate solution...i store the row_number values and use only top 3 values for further calculation...so each time i run the query i get different value. for eg
 
Bank Name rowid
----------------------------
IDBI LTD. 1
YES BANK LTD 2
IDBI LTD. 3
STATE BANK OF INDIA 4
 

first when i ran the query
 
Bank Name rowid
----------------------------
IDBI LTD. 1
IDBI LTD. 2
YES BANK LTD 3
STATE BANK OF INDIA 4
 
second time when i ran the query
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

part of query
 
idno = row_number() OVER(PARTITION BY cltcode ORDER BY defaultbank DESC,LEN(ACCNO) desc)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

please any 1 can help...to find the solution
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 355
1 _Amy 235
2 Peter Leow 185
3 Andreas Gieriet 180
4 Dave Kreskowiak 155
0 OriginalGriff 7,540
1 Sergey Alexandrovich Kryukov 6,462
2 Maciej Los 3,849
3 Peter Leow 3,653
4 CHill60 2,712


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100