简化mysql select CASE WHEN #{company_type} not in ('Downstream', 'Shipment', 'Supplier') then (SELECT count(1) FROM scf_custom_company WHERE id <> #{id} AND tenant_id = #{_tenantId} AND bcm_deleted = 'N' AND company_type = #{company_type} AND company_credit_code = #{companyCreditCode} ) ELSE ( SELECT count(1) FROM scf_custom_company WHERE id <> #{id} AND tenant_id = #{_tenantId} AND bcm_deleted = 'N' AND company_type = #{company_type} AND (parent_org_code <> #{parentOrgCode} or parent_org_code is null) AND company_credit_code = #{companyCreditCode} ) end
时间: 2023-11-27 22:49:26 浏览: 153
这是一条 MySQL 查询语句,根据不同的条件选择不同的查询方式,可以简化为以下代码:
```
SELECT count(1) FROM scf_custom_company
WHERE id <> #{id} AND tenant_id = #{_tenantId} AND bcm_deleted = 'N'
AND company_type = #{company_type} AND company_credit_code = #{companyCreditCode}
AND (
(#{company_type} NOT IN ('Downstream', 'Shipment', 'Supplier') AND parent_org_code = #{parentOrgCode})
OR
(#{company_type} IN ('Downstream', 'Shipment', 'Supplier') AND (parent_org_code <> #{parentOrgCode} OR parent_org_code IS NULL))
)
```
其中,`#{}` 表示占位符,需要在实际执行查询时替换成具体的值。这条语句的作用是统计符合条件的记录数。
相关问题
how to use utils.save_checkpoint for downstream task
To use utils.save_checkpoint for a downstream task, you need to first define the model and optimizer for your task, and then checkpoint your current model and optimizer using the provided function. Here is an example:
First, define your model and optimizer:
model = MyDownstreamModel()
optimizer = torch.optim.Adam(model.parameters(), lr=0.001)
Then, train your model and periodically save checkpoints:
for epoch in range(num_epochs):
# train your model
# ...
# save checkpoint
utils.save_checkpoint({
'epoch': epoch + 1,
'state_dict': model.state_dict(),
'optimizer': optimizer.state_dict(),
})
This will save your model's state_dict and your optimizer's state_dict to a file named 'checkpoint.pth.tar' in the current directory. You can load this checkpoint later by using the provided utils.load_checkpoint function.
Software must not have the PTM Enable bit Set in the PTM Control register on a Function associated with an Upstream Port unless the associated Downstream Port on the Link already has the PTM Enable bit Set in its associated PTM Control register. PTM support by a Function is indicated by the presence of a PTM Extended Capability structure. It is not required that all Endpoints in a hierarchy support PTM, and it is not required for software to enable PTM in all Endpoints that do support it. If a PTM Message is received by a Port that does not support PTM, or by a Downstream Port when the PTM Enable bit is clear, the Message must be treated as an Unsupported Request. This is a reported error associated with the Receiving Port (see Section 6.2 ). A Properly formed PTM Response received by an Upstream Ports that support PTM, but for which the PTM Enable bit is clear, must be silently discarded.
如果与上行端口相关联的功能的PTM控制寄存器中未设置PTM使能位,则软件不能在其中设置PTM控制寄存器中的PTM使能位,除非链接上的关联下行端口已经在其关联的PTM控制寄存器中设置了PTM使能位。支持PTM的功能通过PTM扩展能力结构的存在进行指示。并不要求层次结构中的所有端点都支持PTM,也不要求在所有支持PTM的端点中启用PTM。如果一个不支持PTM的端口或者当PTM使能位被清除时,一个下行端口接收到了PTM消息,则该消息必须被视为不支持的请求。这是与接收端口相关联的报告错误(参见第6.2节)。对于支持PTM的上行端口而言,如果PTM响应的PTM使能位被清除,则必须默默地丢弃它。
阅读全文