gpt4 book ai didi

sql - 将 SQL 转换为 ACCESS

转载 作者:行者123 更新时间:2023-12-04 23:47:42 25 4
gpt4 key购买 nike

这是一个常规的 SQL 语句:

SELECT SUM(CASE WHEN [Column2] = 'Cylinder' THEN 1 ELSE 0 END) as 'Cylinder count',
SUM(CASE WHEN [Column2] = 'Snap' THEN 1 ELSE 0 END) as 'Snap count',
SUM(CASE WHEN [Column2] = 'Tip' THEN 1 ELSE 0 END) as 'Tip count',
SUM(CASE WHEN [Column2] = 'Other' THEN 1 ELSE 0 END) as 'Other count'
FROM [TableName]
WHERE [Column1] = '1.9 QNS-Quantity Not Sufficient'

你能把它转换成 ms-access 吗??

基于这个问题:

https://stackoverflow.com/questions/3153829/question-on-complex-select-statement

最佳答案

Microsoft Access 不支持 CASE,但您可以改用 IIF:

SELECT
SUM(IIF([Column2] = 'Cylinder', 1, 0)) as 'Cylinder count',
SUM(IIF([Column2] = 'Snap', 1, 0)) as 'Snap count',
SUM(IIF([Column2] = 'Tip', 1, 0)) as 'Tip count',
SUM(IIF([Column2] = 'Other', 1, 0)) as 'Other count'
FROM [TableName]
WHERE [Column1] = '1.9 QNS-Quantity Not Sufficient'

引用资料

关于sql - 将 SQL 转换为 ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3153916/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com