Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
5.00/5 (1 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
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
PratikShah2366 3-Oct-12 5:49am    
select idno = row_number() OVER(PARTITION BY cltcode ORDER BY defaultbank DESC,LEN(ACCNO) desc) into #bank from .....

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
 
Share this answer
 
part of query

idno = row_number() OVER(PARTITION BY cltcode ORDER BY defaultbank DESC,LEN(ACCNO) desc)
 
Share this answer
 
please any 1 can help...to find the solution
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900