Click here to Skip to main content
15,902,837 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello

I have create a query for creating auto generate no i.e:
SQL
select  row_number() over(order by O.Col_Id) as SlNo,  O.Col_Date,Account_No,Scheme_Name,O.Col_No,Instalment_Amount,O.No_Of_Instalment,O.Col_Amount ,Permanent_Address,
 (select sum(Col_Amount) from t_Customer_Deposit where Col_Id <= O.Col_Id and Col_Customer_Id=1) as 'Running_Total'
 from t_customer_account inner join t_customer_deposit O on t_customer_account.customer_id=O.col_customer_id inner join
 t_scheme_master on t_customer_account.scheme_id=t_scheme_master.scheme_id where customer_id=1

It is creating auto generate no and working fine but i want to create, after completion of 20 record the slno will start from 1.

If any solution then please help me.
Thanks
Posted
Updated 14-Jan-13 3:45am
v2

1 solution

Please, read about ranking functions[^], especially about NTILE[^] function.
 
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