当前位置:网站首页>MySQL如何将列合并?
MySQL如何将列合并?
2022-06-30 12:47:00 【CSDN问答】
需求是这样的:
有会员表vip和订单表order,
现可以通过count函数以及where语句限定时间段,来统计出每个会员在特定期间内交易了多少单。
结果比如这样的(select count(1) from order where 时间=第1周 group by vip_name):
会员名 第1周
甲 3
乙 7
丙 12
丁 17
戊 2
如果将时间指定在第二周,会出现如下结果(数据都是随机的):
select count(1) from order where 时间=第2周 group by vip_name
会员名 第2周
甲 5
乙 2
丙 1
丁 29
戊 12
现在想做的是,把第1周的数据,第2周的数据合并在同一张表里,即这样:
会员名 第1周 第二周
甲 3 5
乙 7 2
丙 12 1
丁 17 29
戊 2 12
我目前不管怎么写都无法跑出正确的结果。请问这样子的应该通过什么样的思路来实现?
边栏推荐
- Js根据相同值将数组转换为二维数组
- Ffmpeg miscellaneous
- JS converts an array to a two-dimensional array based on the same value
- ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accurately
- 黑马笔记---集合(Collection的常用方法与遍历方式)
- JMeter's performance test process and performance test focus
- On the simplification and acceleration of join operation
- [qnx hypervisor 2.2 user manual]6.2.3 communication between guest and external
- 杭州电子商务研究院:官网(网站)是私域的唯一形态
- Sqlserver query code is 936 simplified Chinese GBK. Should I write 936 or GBK?
猜你喜欢

一篇文章读懂关于企业IM的所有知识点

Open source of xinzhibao applet

微信小程序报错:TypeError: Cannot read property ‘setData‘ of undefined

A keepalived high availability accident made me learn it again!

Postman automatically generates curl code snippets

深度长文探讨Join运算的简化和提速

WTM重大更新,多租户和单点登录

腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?

电机控制park变换公式推导

写信宝小程序开源
随机推荐
ABAP toolbox v1.0 (with implementation ideas)
Sqlserver query code is 936 simplified Chinese GBK. Should I write 936 or GBK?
一文讲清楚什么是类型化数组、ArrayBuffer、TypedArray、DataView等概念
Package based on thinkphp5 -tronapi- wave field interface - source code without encryption - can be opened twice - interface document attached - detailed guidance of the author - June 30, 2022 08:45:2
Methodology for troubleshooting problems (applicable to troubleshooting problems arising from any multi-party cooperation)
Unity脚本程序的开发
【精选】资源变现资讯、新闻、自媒体、博客小程序(可引流,开通流量主,带pc后台管理)
App wechat payment unicloud version of uniapp payment (with source code)
WTM重大更新,多租户和单点登录
rxjs Observable 两大类操作符简介
60 divine vs Code plug-ins!!
jmeter 学习笔记
golang文件的写入、追加、读取、复制操作:bufio包的使用示例
Rk356x u-boot Institute (command section) 3.3 env related command usage
Definition of variables and assignment of variables in MySQL
黑马笔记---包装类,正则表达式,Arrays类
正则系列之断言Assertions
一条查询SQL是如何执行的
ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accurately
Apache Doris Compaction优化百科全书