一、数据库管理 1.1查询所有数据库 mysql> show databases; +--------------------+ Database +--------------------+ information_schema-- mysql元数据,基础数据 mysql--mysql配置数据库,其中包含用户信息。(用户名和密码,权限管理) performance_schema--mysql数据库软件的运行数据,日志信息,性能数据 test--测试数据库。空的 +-------------------
前言:在当前的数据分析岗位中,多数人在做着SQL-Boy\SQL-Girl的工作,在数据分析面试中,SQL是必不可少的一环,对于SQL不仅有常见函数用法的考察,更多时候面试官喜欢出一些编程类题目,本文我们来了解一下那些典型的SQL面试题。(文中的问题均以MySQL为例)
所有要进行操作的文件下载链接: https://pan.baidu.com/s/10VtUZw8G-Ly-r4VypntjiA 密码: y5qu 下载成功后,整个文件夹如下图所示。
前些时间,写过一篇文章《PQ-M及函数:合并列的陷阱及动态化处理方法》,其中所用的数据均为文本,因此,合并过程中修改公式也相对简单,只要把其中生成的固定列名给改成动态提取的即可,如下图所示:
原标题:oracle的wm_concat()和mysql的group_concat()合并同列变成一行的用法以及和concat()合并不同列的区别
我觉得对于SQL语句,清楚知道它执行的顺序,对于写sql语句非常重要
List 元素的追加 方式1-在列表的最后增加数据 方式2-在列表的最前面增加数据
对应的是限制条件(格式类似“field<op>consant”, field表示列对象,op是操作符如"="、">"等)。
要处理成这个样子(栅格内主服务小区CGI中可能包含50多个CGI,只提取前15个)
相信用过MySQL的朋友都知道,MySQL中也有开窗函数的存在。开窗函数的引入是为了既显示聚集前的数据,又显示聚集后的数据。即在每一行的最后一列添加聚合函数的结果。
本文中带来的是LeetCode-SQL的第178题,讲解的是关于MySQL中的排名问题,非常重要和实用的一篇文章,真心建议搜藏保存:
爱可生 DBA 团队成员,擅长故障分析、性能优化,个人博客:https://www.jianshu.com/u/a95ec11f67a8,欢迎讨论。
这是因为: 1 、 在dos窗口中,默认的编码格式gbk,而mysql服务器软件使用的编码utf8 2、在dos窗口输入一个指令,模糊查询当前mysql数据库中所有带有”character”字符集的变 量全部出来 SHOW VARIABLES LIKE ‘%character%’ ;
在 MySQL 8.x 版本中,MySQL 提供了窗口函数,窗口函数是一种在查询结果的特定窗口范围内进行计算的函数。
1、此题比较简单,考察聚合函数sum。常用的聚合函数还有count、max、min
Step-6:以换行符#(lf)【小写L和F】合并列(因目前Power Query在合并列功能中不支持直接选择特殊字符,因此,可以先选择“制表符”,然后修改)
聚合函数是一类在数据库中用于对多个行进行计算并返回单个结果的函数。它们能够对数据进行汇总、统计和计算,常用于提取有关数据集的摘要信息。聚合函数在 SQL 查询中广泛应用,包括统计总数、平均值、最大值、最小值等。
当我开始学习 Python 的时候,并不知道它是多么的灵活和优雅。在阅读和编写了大量代码之后,我越来越喜欢 Python。因为即使是一个普通的操作也可以有许多不同的实现。合并列表是一个很好的例子,至少有5种方法可以做到这一点。本文将介绍它们,并展示在引擎盖下的技巧。
在使用数据库制作各种统计数据的时候,需要对数据进行排序,比如按照分数、销量、人数等数值进行排序,通常排序的方法有两种:
编写一个 SQL 查询,查询每位学生获得的最高成绩和它所对应的科目, 若科目成绩并列,取 course_id 最小的一门。 查询结果需按 student_id 增序进行排序。
create table grade ( id int(10) primary key auto_increment comment '主键', stu_id int(10) comment '学生id', class_id int(10) comment '班级id', course_id int(3) comment '课程id', score int(3) comment '学生分数', unique key (stu_id, course_id) ) engine = innodb charset = utf8; insert into grade (stu_id, class_id, course_id, score) values ('1', 1, 1, 90), ('4', 1, 1, 90), ('7', 1, 1, 84), ('10', 1, 1, 84), ('13', 1, 1, 88), ('1', 1, 2, 67), ('4', 1, 2, 85), ('7', 1, 2, 90), ('10', 1, 2, 88), ('13', 1, 2, 86); insert into grade (stu_id, class_id, course_id, score) values ('2', 2, 1, 83), ('5', 2, 1, 94), ('8', 2, 1, 81), ('11', 2, 1, 91), ('14', 2, 1, 79), ('2', 2, 2, 99), ('5', 2, 2, 80), ('8', 2, 2, 82), ('11', 2, 2, 76), ('14', 2, 2, 66); insert into grade (stu_id, class_id, course_id, score) values ('3', 3, 1, 98), ('6', 3, 1, 92), ('9', 3, 1, 76), ('12', 3, 1, 73), ('15', 3, 1, 83), ('3', 3, 2, 95), ('6', 3, 2, 91), ('9', 3, 2, 86), ('12', 3, 2, 87), ('15', 3, 2, 68); 这里就是建立了一个成绩表,然后往表中插入了15个学生,他们来自三个班级,每个学生学习了两门课程。
把源数据汇总后,为了满足质量要求的数据,需要做数据清洗。PQ就好像变形金刚(英文版PowerBI的转换选项卡恰好也叫“Transform”),在转换选项卡中,集成了各类变形功能。使用频率最高的一般有12个小招: 首行作标题、修改数据类型、删除(重复、错误、空项目)、拆分、提取、合并、替换、填充、移动、排序、格式、逆透视。
本文 GitHub github.com/ponkans/F2E 已收录,有一线大厂面试点思维导图,也整理了很多我的文档,欢迎Star和完善,大家面试可以参照考点复习。文末有福利~~
SQL是结构化查询语言的缩写,是一种用于管理关系型数据库的计算机语言。通过使用SQL语句,可以对数据库中的表格进行查询、更新、删除等操作。
那9个字,犹如一声惊雷,在这个热情的群里炸开了锅...
当然,对于表头单元格,我有可能会使用 td 来代替 th,但不建议这样做。 因为在HTML语义化中了解到:学习 HTML 的目的就是在需要的地方使用恰当的标签(也就是语义化)。
本文中主要是介绍LeetCode中关于SQL的练习题,从易到难,循序渐进。文中会介绍题目和提供尽可能多的解答方案。从本文开始属于\color{red}{中等}难度
窗口:记录集合 窗口函数:在满足某些条件的记录集合上执行的特殊函数,对于每条记录都要在此窗口内执行函数。有的函数随着记录的不同,窗口大小都是固定的,称为静态窗口;有的函数则相反,不同的记录对应着不同的窗口,称为滑动窗口。
在SQL中分拆列值和合并列值老生常谈了,从网上搜刮了一下并记录下来,以便不时之需 :)
索引合并是MySQL查询优化器在处理复杂查询条件时使用的一种技术。简单来说,当WHERE子句中有多个条件,并且每个条件都可以利用不同的索引时,优化器会考虑将这些索引的扫描结果合并,从而得到最终的结果集。
含义:窗口函数也叫OLAP函数(Online Anallytical Processing,联机分析处理),可以对数据进行实时分析处理。
https://wangcy6.github.io/post/plan/oceanbase_day1/
内容为慕课网的"高并发 高性能 高可用 MySQL 实战"视频的学习笔记内容和个人整理扩展之后的笔记,本节内容讲述的索引优化的内容,另外本部分内容涉及很多优化的内容,所以学习的时候建议翻开《高性能Mysql》第六章进行回顾和了解,对于Mysql数据的开发同学来说大致了解内部工作机制是有必要的。
MYSQL-深入到精通mysql教程,请进入知识星球-spark技术学院获取 ---- 基本操作语句创建查看 1,创建数据库: 进入MySql数据库环境后,就可以使用CREATE DATABASE语句创建自己的数据库了。 CREATE DATABASE 数据库名;>create database study; 注1:数据库名可以由任意字母、数字、下面(_)和美元符号($)组成,但不能由单独的数字组成,也不能为MySQL关键字,而且长度还不能超过64个字符。在windows系统下,数据库名不区分大小写,在
可以看到,EXCEL的表头行,有几列属于同一组,会合并产生了两行表头,这样其他不需要分组的需要两行表头合并。
现有用户登录时间表,记录每个用户的id,姓名,邮箱地址和用户最后登录时间。表如下:
在某些应用场景中,我们经常会遇到一些排名的问题,比如按成绩或年龄排名。排名也有多种排名方式,如直接排名、分组排名,排名有间隔或排名无间隔等等,这篇文章将总结几种MySQL中常见的排名问题。
在Excel中通过Ctrl+E组合,用户在首行输入的内容,可以智能识别用户需求,对所有行进行相应填充。
有很多功能,同时在【转换】和【添加】两个菜单中都存在,而且,通常来说,它们得到的结果列是一样的,只是在【转换】菜单中的功能会将原有列直接“转换”为新的列,原有列消失;而在【添加】菜单中的功能,则是在保留原有列的基础上,“添加”一个新的列。
上一篇《SparkCore快速入门系列(5)》,下面给大家更新一篇SparkSQL入门级的讲解。
Python 语言里有许多(而且是越来越多)的高级特性,是 Python 发烧友们非常喜欢的。在这些人的眼里,能够写出那些一般开发者看不懂的高级特性,就是高手,就是大神。
在视频课里,我强调过,Power Query虽然在很大程度上给用户实现报表的自动化(随源数据的增减动态一键刷新得结果)提供了很好的功能。
如果用过MSSQL或者是Oracle中的窗口函数(Oracle中叫分析函数),然后再使用MySQL 8.0之前的时候,就知道需要在使用窗口函数处理逻辑的痛苦了,虽然纯SQL也能实现类似于窗口函数的功能,但是这种SQL在可读性和以及使用方式上大打折扣,看起来写起了都比较难受。
1)rank函数:这个例子中是5位,5位,5位,8位,也就是如果有并列名次的行,会占用下一名次的位置。比如正常排名是1,2,3,4,但是现在前3名是并列的名次,结果是:1,1,1,4。
背景 1. MySQL执行流程 MySQL的执行过程包括多个子阶段:语法分析、语义检查、逻辑优化、物理优化和执行。其中逻辑优化和物理优化统称为查询优化。一个查询优化器的输入是查询树,输出是查询执行计划。 逻辑优化也称为基于规则的查询优化(Rule Based Optimization,简称RBO)。主要是对查询进行逻辑上的等价变换,目的是通过这些变换提高查询的性能。 物理优化也称为基于代价的查询优化(Cost-based Optimization,简称CBO)。主要是通过一些模型,预测一个查询使用某种
领取专属 10元无门槛券
手把手带您无忧上云