Alina_0229
Alina_0229
全部文章
分类
题解(129)
归档
标签
去牛客网
登录
/
注册
Alina_0229的博客
全部文章
(共77篇)
题解 | #计算总和#
select order_num,sum(item_price * quantity) total_price from OrderItems group by order_num having total_price>=1000 order by order_num having 的使用是对...
Mysql
2022-03-08
0
352
题解 | #返回订单数量总和不小于100的所有订单的订单号#
select order_num from OrderItems group by order_num having sum(quantity)>=100 order by order_num 先进行分组,然后使用having进行过滤,然后再进行排序,产生误区的是容易把sum(quantity...
Mysql
2022-03-08
6
603
题解 | #返回每个订单号各有多少行数#
select order_num,count(order_num) order_lines from OrderItems group by order_num order by order_lines #返回每个订单号各有多少行数# 利用group by 进行分组,对分组数据进行统计,然后进行排序
Mysql
2022-03-08
0
320
题解 | #确定已售出产品项 BR01 的总数#
使用group by 写法,先分组然后再添加过滤条件 select sum(quantity) from OrderItems group by prod_id having prod_id="BR01" 直接使用where语句写 select sum(quantity) from OrderIte...
Mysql
2022-03-08
0
296
题解 | #返回 2020 年 1 月的所有订单的订单号和订单日期#
year,month 写法 select * from Orders where year(order_date)=2020 and month(order_date)=01 order by order_date #date_format写法 select order_num,order_date...
Mysql
2022-03-08
6
367
题解 | #顾客登录名#
select cust_id,cust_name, CONCAT(upper(left(cust_name,2)),upper(left(cust_city,3))) as user_login from Customers mysql 字符串的拼接concat(str1,str2),其中登录名全部...
Mysql
2022-03-08
0
255
题解 | #打折#
select prod_id,prod_price,prod_price*0.9 sale_price from Products 若想保留几位小数的写法 select prod_id,prod_price,round(prod_price*0.9,1) sale_price from Produc...
Mysql
2022-03-08
2
335
题解 | #别名#
带as写法 select vend_id, vend_name as vname, vend_address as vaddress, vend_city as vcity from Vendors order by vname as 可以省略,直接写别名 select vend_id, vend_...
Mysql
2022-03-08
25
788
题解 | #返回更高价格的产品#
第一种写法:因为是等于或者高于9美元,直接用>= select prod_id,prod_name from Products where prod_price>=9 第二种写法:where or 两者条件中的一个 select prod_id,prod_name from Produc...
Mysql
2022-03-08
5
496
题解 | #检查SQL语句#
SELECT vend_name, FROM Vendors ORDER vend_name DESC; 以上语句中: order by 缺少by select 查询单个字段时不应添加, SELECT vend_name FROM Vendors ORDER by vend_name DESC
Mysql
2022-03-08
4
595
首页
上一页
1
2
3
4
5
6
7
8
下一页
末页