当前位置: 首页 > news >正文

成都网站建设116web天津seo技术教程

成都网站建设116web,天津seo技术教程,用ps做网站设计,b s网站开发技术超级聚合,是在group by的基础上,再次进行聚合。 它再次聚合的列,是select中没有用到聚合函数的列。 文章目录 例子1解释例子2表以及数据 例子1 mysql> SELECT year, country, product, SUM(profit) AS profitFROM salesGROUP BY year, c…

超级聚合,是在group by的基础上,再次进行聚合。
它再次聚合的列,是select中没有用到聚合函数的列。

文章目录

  • 例子1
  • 解释
  • 例子2
  • 表以及数据


例子1

mysql> SELECT year, country, product, SUM(profit) AS profitFROM salesGROUP BY year, country, product;
+------+---------+------------+--------+
| year | country | product    | profit |
+------+---------+------------+--------+
| 2000 | Finland | Computer   |   1500 |
| 2000 | Finland | Phone      |    100 |
| 2000 | India   | Calculator |    150 |
| 2000 | India   | Computer   |   1200 |
| 2000 | USA     | Calculator |     75 |
| 2000 | USA     | Computer   |   1500 |
| 2001 | Finland | Phone      |     10 |
| 2001 | USA     | Calculator |     50 |
| 2001 | USA     | Computer   |   2700 |
| 2001 | USA     | TV         |    250 |
+------+---------+------------+--------+
mysql> SELECT year, country, product, SUM(profit) AS profitFROM salesGROUP BY year, country, product WITH ROLLUP;
+------+---------+------------+--------+
| year | country | product    | profit |
+------+---------+------------+--------+
| 2000 | Finland | Computer   |   1500 |
| 2000 | Finland | Phone      |    100 |
| 2000 | Finland | NULL       |   1600 |
| 2000 | India   | Calculator |    150 |
| 2000 | India   | Computer   |   1200 |
| 2000 | India   | NULL       |   1350 |
| 2000 | USA     | Calculator |     75 |
| 2000 | USA     | Computer   |   1500 |
| 2000 | USA     | NULL       |   1575 |
| 2000 | NULL    | NULL       |   4525 |
| 2001 | Finland | Phone      |     10 |
| 2001 | Finland | NULL       |     10 |
| 2001 | USA     | Calculator |     50 |
| 2001 | USA     | Computer   |   2700 |
| 2001 | USA     | TV         |    250 |
| 2001 | USA     | NULL       |   3000 |
| 2001 | NULL    | NULL       |   3010 |
| NULL | NULL    | NULL       |   7535 |
+------+---------+------------+--------+

解释

with rollup的工作原理就是在group by分组后,进行超级聚合。
它针对的是在group by后面出现的列,会把他们设置成null,表示不对这一列进行统计。
从最左边开始,找到不同的列值,把他们设置成null

在这里插入图片描述

例子2

SELECT year, country, product, SUM(profit) AS profit
FROM sales
GROUP BY country, year, product
在这里插入图片描述
超级聚合 with rollup后,
在这里插入图片描述

表以及数据

/*
Navicat MySQL Data TransferSource Server         : demo
Source Server Version : 50733
Source Host           : localhost:3306
Source Database       : demoTarget Server Type    : MYSQL
Target Server Version : 50733
File Encoding         : 65001Date: 2023-09-27 00:22:21
*/SET FOREIGN_KEY_CHECKS=0;-- ----------------------------
-- Table structure for `sales`
-- ----------------------------
DROP TABLE IF EXISTS `sales`;
CREATE TABLE `sales` (`country` varchar(20) DEFAULT NULL,`year` varchar(4) DEFAULT NULL,`product` varchar(20) DEFAULT NULL,`profit` int(4) DEFAULT NULL,`id` int(11) NOT NULL AUTO_INCREMENT,PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;-- ----------------------------
-- Records of sales
-- ----------------------------
INSERT INTO `sales` VALUES ('Finland', '2000', 'Computer', '1500', '1');
INSERT INTO `sales` VALUES ('Finland', '2000', 'Phone', '100', '2');
INSERT INTO `sales` VALUES ('India', '2000', 'Calculator', '150', '3');
INSERT INTO `sales` VALUES ('India', '2000', 'Computer', '1200', '4');
INSERT INTO `sales` VALUES ('USA', '2000', 'Calculator', '75', '5');
INSERT INTO `sales` VALUES ('USA', '2000', 'Computer', '1500', '6');
INSERT INTO `sales` VALUES ('Finland', '2001', 'Phone', '10', '7');
INSERT INTO `sales` VALUES ('USA', '2001', 'Calculator', '50', '8');
INSERT INTO `sales` VALUES ('USA', '2001', 'Computer', '2700', '9');
INSERT INTO `sales` VALUES ('USA', '2001', 'TV', '250', '10');
http://www.tj-hxxt.cn/news/62280.html

相关文章:

  • 想自己做淘宝有什么网站网络软文
  • 网站优化怎么做 有什么技巧关键词挖掘查询工具
  • 网站内容页设计专业软文发布平台
  • 学习软件的网站百度关键词seo年度费用
  • 网站建设计划书图片外链生成器
  • 哪个网站做代购seo中文意思
  • 广州微网站建设网络服务器的功能
  • 中国互联网协会会员重庆seo教程
  • 静安区网站开发营销网站建设教学
  • 网站开发路径百度seo关键词排名优化软件
  • 海口仿站定制模板建站seo海外
  • 深圳创业项目网络seo是什么
  • 手机网站管理工具推广策划方案模板
  • 开源网站模板网络营销pdf
  • 网站的相关搜索css代码怎么做百度手机浏览器
  • asp源码网站免费网站在线客服软件
  • dhru商城网站建设百度账号管家
  • 别人买了域名做违法网站网络推广公司如何做
  • 做电影网站选服务器网站关键词免费优化
  • 西安免费做网站公司百度搜索关键词排行榜
  • 哈尔滨建站做一个公司网站大概要多少钱
  • PHP+MySQL网站开发全程实例广州王牌seo
  • 威海外贸网站建设多少钱搜索引擎网络推广方法
  • 业务网站制作seo和sem的联系
  • 宝鸡市市政工程建设管理处网站东莞网站建设推广公司
  • 网新企业网站管理系统太原百度网站快速排名
  • 网站各个级别建设费用南宁在哪里推广网站
  • 网站后台上传图片做难吗长尾关键词挖掘熊猫
  • 宁波网站建站公司百度有刷排名软件
  • 不买域名怎么做网站百度热搜seo