我正在尝试运行以下代码来复制所有行中的订单量总和。我试图在过去的两个星期中这样做,这意味着我应该获得14行数据。但是,我得到了很多重复项,并且GROUP BY无法正常工作。有人可以帮我吗?谢谢!
SELECT
TO_CHAR(DATE_TRUNC('week',START_OF_PERIOD_LOCAL),'YYYY-MM-DD') AS WEEK,
TO_CHAR(START_OF_PERIOD_LOCAL , 'DY') AS DAY_OF_WEEK,
sum(ORDERS_DELIVERED) over () as total_orders
FROM p
WHERE
CITY_NAME='Hong Kong' AND
DATEDIFF('DAY',DATE_TRUNC('DAY',CURRENT_TIMESTAMP),DATE_TRUNC('DAY',START_OF_PERIOD_LOCAL)) BETWEEN -14 AND 0
GROUP BY 1,2
ORDER BY 1
答案 0 :(得分:0)
要删除重复项,您需要使用distinct。请尝试以下操作:
func encrypty(data value: String) -> EncryptionResult {
guard var messageData = value.data(using: .utf8), var key = getSecretkey()?.data(using: .utf8) else {
return EncryptionResult.failure
}
//iv ata
guard let ivData = generateRandomBytes(of: Int32(SecurityConstants.blockSize))?.data(using: .utf8) else {
return EncryptionResult.failure
}
//output
var outputData = Data(count: (messageData.count + SecurityConstants.blockSize + ivData.count))
var localOutput = outputData
//output length
var outputLength: size_t = 0
//encyrption
let status = key.withUnsafeBytes { keyBytes in
messageData.withUnsafeBytes { messageBytes in
localOutput.withUnsafeMutableBytes { mutableOutput in
ivData.withUnsafeBytes { ivDataBytes in
CCCrypt( CCOperation(kCCEncrypt),
CCAlgorithm(kCCAlgorithmAES128),
CCOptions(kCCOptionPKCS7Padding),
keyBytes,
key.count,
ivDataBytes,
messageBytes,
messageData.count,
mutableOutput,
outputData.count,
&outputLength)
}
}
}
}
guard status == Int32(kCCSuccess) else {
logError("Error in encryption")
return EncryptionResult.failure
}
outputData.count = outputLength
return EncryptionResult.success(value: outputData.base64EncodedString())
}