1 Star 0 Fork 0

逸扬/leetcode-hub-mysql

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lc-1459.test 751 Bytes
一键复制 编辑 原始数据 按行查看 历史
# $1459. 矩形面积
# https://leetcode-cn.com/problems/rectangles-area/
# SQL架构
Create table If Not Exists Points (id int, x_value int, y_value int);
Truncate table Points;
insert into Points (id, x_value, y_value) values ('1', '2', '7');
insert into Points (id, x_value, y_value) values ('2', '4', '8');
insert into Points (id, x_value, y_value) values ('3', '2', '10');
# Write your MySQL query statement below
select
p1.id as p1,
p2.id as p2,
abs(p2.x_value - p1.x_value) * abs(p2.y_value - p1.y_value) as area
from
Points p1
inner join Points p2 on p1.id < p2.id
where
(p2.x_value - p1.x_value) != 0
and (p2.y_value - p1.y_value) != 0
order by
area desc,
p1.id,
p2.id;
# clean-up
drop table Points;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gdut_yy/leetcode-hub-mysql.git
git@gitee.com:gdut_yy/leetcode-hub-mysql.git
gdut_yy
leetcode-hub-mysql
leetcode-hub-mysql
master

搜索帮助