Click here to Skip to main content
12,691,231 members (30,708 online)
Rate this:
 
Please Sign up or sign in to vote.
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 23:54pm
Comments
Achha Insan 3-Oct-12 5:32am
   
nothing is impossible. you can do it.
Abhijit Parab 3-Oct-12 5:39am
   
please post your query here
Member 8310253 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170117.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2017
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