如何在sql server中创建autogen no [英] How to create autogen no in sql server
本文介绍了如何在sql server中创建autogen no的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我创建了一个创建自动生成no的查询,即:
Hello
I have create a query for creating auto generate no i.e:
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
这是创建自动生成否和工作正常,但我想创建,完成20记录后slno将从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
推荐答案
请阅读黑客函数 [ ^ ],尤其是关于 NTILE [ ^ ]功能。
Please, read about ranking functions[^], especially about NTILE[^] function.
这篇关于如何在sql server中创建autogen no的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文