批次的序号 [英] Sequence number for a Batch

查看:94
本文介绍了批次的序号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一种情况,我有多个批次,每批都是

序列号。对于每批,数字应从1开始。

例如:


Col.no1 Col.no2

- ---- -------

batch1 1

batch1 2

batch1 3


批次2 1

批次2 2

批次3 1


批次4 1

..... .....


在创建表时,在DB2中有一种简单的方法吗?


DB2中的Identity列只是按顺序创建数字。


请指教

Jignesh

Hi,

I have a situation where i have multiple batch and the each batch are
sequence numbers. For each batch, the number should start with 1.
For example:

Col.no1 Col.no2
------ -------
batch1 1
batch1 2
batch1 3

batch 2 1
batch 2 2

batch 3 1

batch4 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 advise
Jignesh

推荐答案

*********** @ gmail .com 写道:


我有一种情况,我有多个批次,每批都是序列号。对于每批,数字应从1开始。
例如:

Col.no1 Col.no2
------ ------- <批次1 1批次1批次1批次2批次2 1批次2批次3 1
批次3 1

batch4 1
..... .....

在创建表时,有没有简单的方法在DB2中执行它?
DB2中的Identity列只是按顺序创建数字。

请建议
Jignesh
Hi,

I have a situation where i have multiple batch and the each batch are
sequence numbers. For each batch, the number should start with 1.
For example:

Col.no1 Col.no2
------ -------
batch1 1
batch1 2
batch1 3

batch 2 1
batch 2 2

batch 3 1

batch4 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 advise
Jignesh



您的批次是否有限?您可以创建一个序列/批处理并编写一个

函数来执行动态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 a
function 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 the
batch before the insert.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


批次是否会删除项目?如果是,他们是否需要重新订购?


您可能需要一个功能来为您重新排序所有内容。如果

序列中的间隙无关紧要,可以使用SEQEUNCE。


B.

Will the batches ever have items removed? If they are, will they need
reordering?

You may need a FUNCTION to reorder everything for you. If gaps in the
sequence to not matter, a SEQEUNCE can be used.

B.


嗨Serge,


不,我的批次是无限的。我创建了一个序列但它只是

即使在有一个新批次之后也会增加序列号。


请指教。

Jignesh
Hi Serge,

Nopes, my batch are infinite. I created a sequence but it just
increments the sequence number even after a having a new batch.

Please advise.
Jignesh
你的批次是否有限?你可以创建一个序列/批处理并编写一个执行动态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 a
function 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 the
batch before the insert.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab






这篇关于批次的序号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆