当前位置:网站首页>SQL Server2005中SUM函数内嵌套IF语句
SQL Server2005中SUM函数内嵌套IF语句
2022-06-30 06:57:00 【CSDN问答】
问题遇到的现象和发生背景
想要在表【MouldDetail】中通过SUM函数查询列【生产数量】的2个结果
1、生产数量的合计数量SUM(生产数量),已完成
2、生产数量的历史数据(剔除SUM(生产数量)中<0的数据即可),但是语句是SUM(IF(生产数量>0,生产数量,0)一直报错。
表结构:

我的语句是:
select 车型,模号,SUM(生产数量)'合计数量',SUM(IF(生产数量)>0,生产数量,0)'历史数据' from MouldDetail GROUP BY 车型,模号
SUM(IF(生产数量)>0,生产数量,0)'历史数据'这里一直报错,去掉这一段就没问题。
报错信息是:
消息 156,级别 15,状态 1,第 1 行
关键字 'IF' 附近有语法错误。
消息 102,级别 15,状态 1,第 1 行
',' 附近有语法错误。
请大家帮忙看看错误出在哪里?
边栏推荐
- SOC项目AHB_SD_HOST控制器设计
- 1.9 - Cache
- Egret P2 pit encountered by physical engine (1)
- ROS system problem: rosdep init
- [daily question] 535 Encryption and decryption of tinyurl
- Vscode returns the previous cursor (previous browse position)
- 如果我在珠海,到哪里开户比较好?另外,手机开户安全么?
- Finished product upgrade procedure
- 0基础转行软件测试,如何实现月薪9.5k+
- Record one time of Tencent Test Development Engineer's automation interface test practice experience
猜你喜欢

Class templates and friends

1.8 - multi level storage

Linux服务器安装Redis
![[my advanced OpenGL learning journey] about the access methods of vector and matrix classification of OpenGL shaders: xyzw/rgba/stpq and array subscripts](/img/ed/76db436ab5e35fba742dc287402fe3.png)
[my advanced OpenGL learning journey] about the access methods of vector and matrix classification of OpenGL shaders: xyzw/rgba/stpq and array subscripts

Relevant database questions.

Class template case - encapsulation of array classes

【转】存储器结构、cache、DMA架构分析

【每日一题】535. TinyURL 的加密与解密

Assembly language learning I (with stack co process, 32-bit registers and related instructions, to be continued 06/29)

明天!“移动云杯”大赛空宣会开播!
随机推荐
Four tips in numpy
记录一次腾讯测试开发工程师自动化接口测试实践经验
Determine whether the picture is in JPG picture format
2022年6月29日--使用C#迈出第一步--使用 C# 中的“if”、“else”和“else if”语句向代码添加决策逻辑
SOC项目AHB_SD_HOST控制器设计
【模糊神经网络】基于模糊神经网络的移动机器人路径规划
Go installation and configuration (1)
【我的OpenGL学习进阶之旅】关于OpenGL的着色器的向量和矩阵分类的访问方式: xyzw/rgba/stpq以及数组下标
[fuzzy neural network] mobile robot path planning based on Fuzzy Neural Network
SOC_SD_CLK
Egret engine P2 physics engine (2) - Funny physical phenomenon of small balls hitting the ground
Record one time of Tencent Test Development Engineer's automation interface test practice experience
How does the CPU recognize the code?
IDEA import导入的类明明存在,却飘红?
Graphic octet, really top
How to set the hot deployment of idea web project
【已解决】Failed! Error: Unknown error 1130
元宇宙由哪些底层技术支撑?
Ftplib+ tqdm upload and download progress bar
我开户后把账号忘记了咋办?股票在网上开户安全吗?