当前位置:网站首页>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 行
',' 附近有语法错误。
请大家帮忙看看错误出在哪里?
边栏推荐
- Cmake post makefile:32: * * * missing separator Stop.
- RT thread Kernel Implementation (II): critical area, object container
- Class templates and friends
- 2021-07-02
- Google Earth Engine(GEE)——墨累全球潮汐湿地变化 v1 (1999-2019) 数据集
- Idea shortcut key
- Base64 encoding method implemented by native JS
- 【已解决】Failed! Error: Unknown error 1130
- 元宇宙由哪些底层技术支撑?
- RT thread Kernel Implementation (V): timer
猜你喜欢

第一行代码(第三版)学习笔记

Pay attention to this live broadcast and learn about the path to achieve the dual carbon goal of the energy industry

记录一次腾讯测试开发工程师自动化接口测试实践经验

【我的OpenGL学习进阶之旅】关于OpenGL的着色器的向量和矩阵分类的访问方式: xyzw/rgba/stpq以及数组下标

SOC project AHB_ SD_ Host controller design

1.9 - Classification of memory

Go installation and configuration (1)

Numpy中的四个小技巧

Xshell传输文件

2021-07-02
随机推荐
[Hot100]10. 正则表达式匹配
随机网络,无标度网络,小世界网络以及NS小世界的性能对比matlab仿真
1.8 - multi level storage
明天!“移动云杯”大赛空宣会开播!
【json-tutorial】第一章学习笔记
ROS system problem: rosdep init
RT thread Kernel Implementation (VI): time slice
ETL为什么经常变成ELT甚至LET?
Win10踩坑-开机0xc0000225
ROS service communication programming
ftplib+ tqdm 上传下载进度条
Record one time of Tencent Test Development Engineer's automation interface test practice experience
Ffmplay is not generated during the compilation and installation of ffmpeg source code
GO安装以及配置(1)
Servlet principle
[fuzzy neural network] mobile robot path planning based on Fuzzy Neural Network
【Hot100】15. Sum of three numbers
freemarker
[datawhale team learning] task02: mathematical operation, string and text, list
ROS program compilation, like no compilation, refers to the execution of the old compiled executable program