我的数据格式如下:
ORD_NO ITEM FULFILL_ID
SA1 1000 1
SA1 2000 2
SA2 2000 1
SA2 3000 2
SA2 9000 3
我想填写FULFILL_ID列的值,该列应以1开头并增加到一个特定ORD NO的行数,如上所述。
怎么做?
答案 0 :(得分:2)
这是UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
UIView *controllerView = imagePickerController.view;
controllerView.alpha = 0.0;
controllerView.transform = CGAffineTransformMakeScale(0.5, 0.5);
[[[[UIApplication sharedApplication] delegate] window] addSubview:controllerView];
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
controllerView.alpha = 1.0;
}
completion:nil];
的作用:
ROW_NUMBER()
这将返回值作为查询。更新需要稍微不同的查询。
编辑:
更新可以这样完成:
select ord_no, item,
row_number() over (partition by ord_no order by item) as fulfill_id
from table t;
此版本假定update table t
set fulfill_id = (select count(*)
from table t2
where t2.ord_no = t.order_no and
t2.item <= t.item
);
的相同值item
不同。
答案 1 :(得分:2)
您可以使用此语句的合并声明
merge into table1 t3 using
(
select ord_no, item,
row_number() over (partition by ord_no order by item) as fulfill_id
from table1
) s
on
(t3.ORD_NO=s.ORD_NO and t3.ITEM=s.ITEM)
when matched then
update set t3.FULFILL_ID=s.fulfill_id