我有一个表名Student,属性名称为RegistrationNo,我正在尝试从表中获取最大的注册ID并将其与当前日期年份连接起来。例如,如果注册号为45且当前年份为2018,那么在连接之后看起来例如45-2018 ..
我使用+运算符将它们连接起来,但是它将年和最大注册数相加。
select (isnull(max(Reg),0)+1) + '-' + CONVERT(int,Year(getdate())) as NextCode
from Admission;
答案 0 :(得分:2)
我不知道您要做什么,但是您可以将其简化为:
* def response =
"""
{
"userProfileId":"12313123123",
"items": {
"47961": {
"products": {
"productNumber":"0000",
"productSummary": {
"productSubTotal":"$68.64",
"quantity":3,
"productPrice":"$22.88"
}
}
},
"47962": {
"products": {
"productNumber":"12345",
"productSummary": {
"productSubTotal":"$68.64",
"quantity":3,
"productPrice":"$22.88"
}
}
}
}
}
"""
* def fun = function(k, v){ response.items[k].products.productSummary.quantity = 100 }
* eval karate.forEach(response.items, fun)
* match each response..quantity == 100
但是,select max(Reg) + '-' + cast(year(getdate()) as varchar(4)) as NextCode
from Admission;
可以简化:
concat()