当前位置:网站首页>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;
边栏推荐
- [exercise 5] [Database Principle]
- Alibaba is bigger than sending SMS (user microservice - message microservice)
- 自抗扰控制器七-二阶 LADRC-PLL 结构设计
- Seven second order ladrc-pll structure design of active disturbance rejection controller
- Enable SASL authentication for memcached
- 【数据库原理及应用教程(第4版|微课版)陈志泊】【第四章习题】
- 电压环对 PFC 系统性能影响分析
- C graphical tutorial (Fourth Edition)_ Chapter 15 interface: interfacesamplep271
- Record your vulnhub breakthrough record
- Swift return type is a function of function
猜你喜欢

Integer case study of packaging
![[comprehensive question] [Database Principle]](/img/d7/8c51306bb390e0383a017d9097e1e5.png)
[comprehensive question] [Database Principle]

Dojo tutorials:getting started with deferrals source code and example execution summary

Xctf mobile--app3 problem solving

Powerful avatar making artifact wechat applet

Application of ncnn Neural Network Computing Framework in Orange Pi 3 Lts Development Board

Two solutions of leetcode101 symmetric binary tree (recursion and iteration)

Application of ncnn neural network computing framework in orange school orangepi 3 lts development board

Xctf mobile--app2 problem solving

ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹
随机推荐
Gan totem column bridgeless boost PFC (single phase) seven PFC duty cycle feedforward
[network counting] Chapter 3 data link layer (2) flow control and reliable transmission, stop waiting protocol, backward n frame protocol (GBN), selective retransmission protocol (SR)
CVPR 2022 图像恢复论文
Analysis of the influence of voltage loop on PFC system performance
Seven second order ladrc-pll structure design of active disturbance rejection controller
Differences and connections between final and static
Powerful avatar making artifact wechat applet
Kung Fu pays off, and learning is done
Tensorflow binary installation & Failure
ImportError: No module named examples. tutorials. mnist
Idea packages the web project into a war package and deploys it to the server to run
[exercise 7] [Database Principle]
【习题六】【数据库原理】
Oh my Zsh + TMUX installation
Application of ncnn neural network computing framework in orange school orangepi 3 lts development board
低代码平台国际化多语言(i18n)技术方案
Keep learning swift
强大的头像制作神器微信小程序
CNN MNIST handwriting recognition
Integer case study of packaging