SQLZOO知识点补充

本文是对SQLZOO练习中遇到的重要知识点的补充,包括round函数的使用、left函数的操作、处理特殊字符的方法、排序技巧、concat函数的结合、查找各州最大面积国家的查询、group by与order by的区别、coalesce函数的空值处理、group by 1的含义以及case when语句的应用。通过实例解析,帮助读者深入理解这些SQL概念。
摘要由CSDN通过智能技术生成

背景

目前复习sql语言,在前几篇博客详细描述了sql的语法,但是在刷sqlzoo过程中遇到一些没有学习的知识点,在这篇博客进行总结。

之前的复习笔记,可以作为参考:https://blog.csdn.net/Foools/article/details/109248894



一、round函数

ROUND 函数用于把数值字段舍入为指定的小数位数。decimals可以设置为负数。

SQL ROUND() 语法
SELECT ROUND(column_name,decimals) FROM table_name

例题
Show the name and population in millions and the GDP in billions for the countries of the continent ‘South America’. Use the ROUND function to show the values to two decimal places.
For South America show population in millions and GDP in billions both to 2 decimal places.

select name,round(population/1000000,2),round(gdp/1000000000,2) from world 
where continent='South America'

二、left函数

You can use the function LEFT to isolate the first character.本质上是一个截断操作,string类型的数据,进行从左端开始截取。

例题
Show the name and the capital where the first letters of each match. Don’t include countries where the name and the capital are the same word.

SELECT name,  capital
FROM world
where 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值