本文介绍了批次的序号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一种情况,我有多个批次,每批都是 序列号。对于每批,数字应从1开始。 例如: Col.no1 Col.no2 - ---- ------- batch1 1 batch1 2 batch1 3 批次2 1 批次2 2 批次3 1 批次4 1 ..... ..... 在创建表时,在DB2中有一种简单的方法吗? DB2中的Identity列只是按顺序创建数字。 请指教 JigneshHi,I have a situation where i have multiple batch and the each batch aresequence numbers. For each batch, the number should start with 1.For example:Col.no1 Col.no2------ -------batch1 1batch1 2batch1 3batch 2 1batch 2 2batch 3 1batch4 1..... .....Is there a easy way to do it in DB2 while creating a table?Identity column in DB2 simply creates numbers in sequence.Please adviseJignesh推荐答案 您的批次是否有限?您可以创建一个序列/批处理并编写一个 函数来执行动态SQL以使用适当的序列。 否则你可以使用thr ROW_NUMBER()OVER( PARTITION by < batchcolumn>)OLAP函数可能会在插入之前被 批次的最大数量抵消。 干杯 Serge - Serge Rielau DB2解决方案开发 IBM多伦多实验室Are your batches finite? You could create a sequence/batch and write afunction doing dynamic SQL to use the appropriate sequence.Otherwise you could use thr ROW_NUMBER() OVER(PARTITION BY<batchcolumn>) OLAP function possibly offset by the max number for thebatch before the insert.CheersSerge--Serge RielauDB2 Solutions DevelopmentIBM Toronto Lab 这篇关于批次的序号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
06-24 04:59