当前位置:网站首页>SQL learning notes (I)
SQL learning notes (I)
2022-07-03 12:53:00 【ElsaWu1998】
( This article is being updated )
Some great advanced tutorials
- SQL Advanced techniques https://zhuanlan.zhihu.com/p/139856374
Include content :SQL The writing standard of 、SQL Some advanced use skills of ( Skillfully use CASE WHEN Make statistics & to update 、 Skillfully use HAVING Clause 、 Self join 、 Skillfully use COALESCE function )、SQL Performance optimization skills . - mysql Video combat tutorial online learning - database - Frog lesson net https://www.wkcto.com/courses.html?list=mysql
Some points to think about when brushing questions
I want to master it recently SQL, But undergraduate teachers teach relatively shallow , And most of them have been forgotten , So I finished it in one day SQL Basic tutorials for , Here is an easy-to-use self-study SQL Website ( It can run in real time ): self-taught SQL network . At the same time, I also did a little practice LeetCode
This article will record the important points in the learning process , For future study reference .
Pay attention to the writing order . The typical correct sequence is as follows :
SELECT DISTINCT column, AGG_FUNC(column_or_expression) FROM mytable JOIN another_table ON mytable.column = another_table.column WHERE constraint_expression GROUP BY column HAVING constraint_expression ORDER BY column ASC/DESC LIMIT count OFFSET COUNT;If you don't have to
GROUP BYgrammar , ordinaryWHEREThat's enough. .If you want to separate statistics according to two dimensions , stay
GROUP BYJust put two inside . for example :select role,count(*),(case when Building is not null then 1 else 0 end) bn from employees group by role,bnQuery execution order :
FROMandJOIN;WHERE;GROUP BY;HAVING;SELECT;DISTINCT
If there are duplicate data rows DISTINCT Will be responsible for weight removal .ORDER BY
When the result set is determined ,ORDER BY Sort the results . because SELECT The expression in has been executed . You can use AS Alias .LIMIT / OFFSET
Last LIMIT and OFFSET Intercept some data from the sorting results .When selecting the highest data , If you need to display a null value , have access to
IFNULL(...,NULL)LIMIT The parameter of cannot be a formula , If you need to change a value, you can use the statement
SET N = N-1;If you need to update the table , Can cooperate withUPDATEUse . for example :UPDATE Salaries SET salary = CASE WHEN salary >= 10000 THEN salary * 0.9 WHEN salary < 10000 THEN salary * 1.2 ELSE salary END;
边栏推荐
- Public and private account sending prompt information (user microservice -- message microservice)
- GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈
- Express abstract classes and methods
- Flinksql can directly create tables and read MySQL or Kafka data on the client side, but how can it automatically flow and calculate?
- idea将web项目打包成war包并部署到服务器上运行
- Differences between initial, inherit, unset, revert and all
- [exercice 7] [principe de la base de données]
- 01 three solutions to knapsack problem (greedy dynamic programming branch gauge)
- Swift5.7 扩展 some 到泛型参数
- GCN thinking - word2vec directly calculates text classification
猜你喜欢

记录自己vulnhub闯关记录

01 three solutions to knapsack problem (greedy dynamic programming branch gauge)

Glide question you cannot start a load for a destroyed activity

公纵号发送提示信息(用户微服务--消息微服务)

ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹

Swift bit operation exercise

With pictures and texts, summarize the basic review of C language in detail, so that all kinds of knowledge points are clear at a glance?

Solve the problem of VI opening files with ^m at the end

initial、inherit、unset、revert和all的区别
![[data mining review questions]](/img/96/00f866135e06c4cc0d765c6e499b29.png)
[data mining review questions]
随机推荐
Dojo tutorials:getting started with deferrals source code and example execution summary
[comprehensive question] [Database Principle]
CVPR 2022 图像恢复论文
How to stand out quickly when you are new to the workplace?
The latest version of lottery blind box operation version
Apache Mina开发手册
The best shortcut is no shortcut
Use Tencent cloud IOT platform to connect custom esp8266 IOT devices (realized by Tencent continuous control switch)
【数据库原理及应用教程(第4版|微课版)陈志泊】【第三章习题】
Analysis of the influence of voltage loop on PFC system performance
I'm too lazy to write more than one character
C graphical tutorial (Fourth Edition)_ Chapter 20 asynchronous programming: examples - using asynchronous
社交社区论坛APP超高颜值UI界面
Low code platform international multilingual (I18N) technical solution
RedHat5 安装Socket5代理服务器
Record your vulnhub breakthrough record
【R】【密度聚类、层次聚类、期望最大化聚类】
Sword finger offer05 Replace spaces
[review questions of database principles]
Swift bit operation exercise