当前位置:网站首页>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
我目前不管怎么写都无法跑出正确的结果。请问这样子的应该通过什么样的思路来实现?
边栏推荐
- Qt读写Excel--QXlsx工作表显示/隐藏状态设置4
- QT read / write excel--qxlsx worksheet display / hide status setting 4
- 今日睡眠质量记录80分
- PG基础篇--逻辑结构管理(表继承、分区表)
- Clearing TinyMCE rich text cache in elementui
- 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
- Paper interpretation (AGC) attributed graph clustering via adaptive graph revolution
- 2022-06-23 sail soft part formula and SQL generation (month and quarter retrieval)
- Qt中的事件处理
- kaniko官方文档 - Build Images In Kubernetes
猜你喜欢

Postman génère automatiquement des fragments de code Curl

今日睡眠质量记录80分
![[qnx hypervisor 2.2 user manual]6.2.3 communication between guest and external](/img/ca/9065325ce8882d95fb24c82fb62abc.png)
[qnx hypervisor 2.2 user manual]6.2.3 communication between guest and external

Rk356x u-boot Institute (command section) 3.2 usage of help command

独立站即web3.0,国家“十四五“规划要求企业建数字化网站!

Resource realization applet opening traffic main tutorial

IDEA 2021.3 执行 golang 报错:RNING: undefined behavior version of Delve is too old for Go version 1.18

JS converts an array to a two-dimensional array based on the same value

Postman automatically generates curl code snippets

Qt读写Excel--QXlsx工作表显示/隐藏状态设置4
随机推荐
kaniko官方文档 - Build Images In Kubernetes
Prometheus 2.29.0 新特性
Substrate 源码追新导读: 修复BEEFY的gossip引擎内存泄漏问题, 智能合约删除队列优化
Illustration creating a stored procedure using Navicat for MySQL
Docker installation of mysql8 and sqlyong connection error 2058 solution [jottings]
Basic syntax of unity script (3) - accessing game object components
golang 基础 —— 字符串 与 int 、int64 互转
postman 自动生成 curl 代码片段
Today's sleep quality record 80 points
【C语言深度解剖】float变量在内存中存储原理&&指针变量与“零值”比较
Js根据相同值将数组转换为二维数组
Introduction to the new source code of substrat: fix the memory leak of the mission engine of beefy, and optimize the smart contract deletion queue
今日睡眠质量记录80分
Wechat applet reports an error: typeerror: cannot read property 'SetData' of undefined
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
Unity脚本的基础语法(1)-游戏对象的常用操作
波卡跨链通信源码探秘: 要素篇
Introduction to the renewal of substrate source code: the pledge amount is greatly reduced, and rocksdb can be completely disabled
Dark horse notes - common date API
ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accurately