当前位置:网站首页>sql server 2008使用over(PARTITION BY..ORDER BY.. ) 显示有语法错误
sql server 2008使用over(PARTITION BY..ORDER BY.. ) 显示有语法错误
2022-04-22 00:34:00 【CSDN问答】

sql是求每月一项字段的累加,按照日期与月份分组的,请指点,谢谢

这是在另一个数据库运行的,语法没有错误,但在sql server 2008R2 就报错了,请指点
采纳答案:
sql server 2005引入Row_number()
over(PARTITION BY..ORDER BY.. ) 不能用Sum
用sum要Group By
我只修正over(PARTITION BY..ORDER BY.. )
不清楚你要查什么,所以没有修正其它语法错误,比如没有Group by
select * from (select t.jh, mth, sum (ryou_ sum) as ryou_suml,Row_number() over (PARTITION BY jh ORDER BY mth ) num from(select jh, month (rq) mth, sum (ryou) ryou_ sum from CSJING_ SCSJBwhere rq >='2022-01-01' and rq<='2022-12-31' group by month(rq),jh) t) ttpivot (max (ryou_ sum1 )for mth in ([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12])) as x
版权声明
本文为[CSDN问答]所创,转载请带上原文链接,感谢
https://ask.csdn.net/questions/7691728
边栏推荐
- L2-040 zhe playing games (25 points) simulation
- 闭包的原理及应用
- 七朋元视界打破常规的社交模式构建多样化场景社群
- 华为云云主机体验有感:你的软件收纳专家
- Ideal one finally replaced? Brand new product sequence named L8, heavily camouflaged road test exposure
- Haskell Monoid(幺半群)的介绍
- Material UI中JSS的写法(随手笔记)
- Why does the web login need a verification code?
- Probe architecture of open source project kindling based on ebpf Technology
- High expansion and high availability engineering practice of recommended resource bits related to short video app
猜你喜欢

MySQL basic collection

Why does the web login need a verification code?

See how the project manager brings a project to ruin

智汀如何连接华为智能音箱?
![[knowledge atlas] tushare data acquisition and display (1 / *)](/img/c7/52fefae0cb0e8a7a2a22854521b880.png)
[knowledge atlas] tushare data acquisition and display (1 / *)

短视频APP相关推荐资源位的高扩展高可用工程实践

华为云云主机体验有感:你的软件收纳专家

How to select Bi tools? These three questions are the key!

【音视频】RTCP

. net treasure API: ihostedservice, background task execution
随机推荐
Cloud native enthusiast weekly: looking for open source alternatives to netlify
【acwing】165. Kitten climbing (DFS pruning)
MySQL基础合集
智汀如何连接华为智能音箱?
R语言广义线性模型GLM:线性最小二乘、对数变换、泊松、二项式逻辑回归分析冰淇淋销售时间序列数据和模拟
云原生爱好者周刊:寻找 Netlify 开源替代品
What are the main constraints on the development of mobile phone hardware performance
自动化测试框架有哪些优势?
Force buckle 55 Jumping game
[knowledge atlas] tushare data acquisition and display (1 / *)
【音视频】RTCP
logstash导入movielens测试数据
七朋元视界打破常规的社交模式构建多样化场景社群
Watch mechanism of redis
Solve the problem that prettier is invalid after svelte project uses pnpm
物聯網專業未來沒有前途了嗎?
Addition, deletion, modification and query of MySQL advanced table
How can devices of different brands be compatible and interconnected? Yiwen teaches you to understand
[observation] purple light cloud: homogeneous hybrid cloud is upgraded to distributed cloud, making cloud and intelligence everywhere
China venture capital, winter is coming