阿里云瑶池数据库SQL挑战令题目三

简介: 阿里云瑶池数据库SQL挑战令题目三
题目:

该表的每一行包含一个点的三维坐标,写一个sql查询,计算每个三角形的面积,保留两位小数。

解题思路:

首先需要知道关于三维坐标的三角形面积的求解公式,然后才能进行计算,否则的话就没有办法进行计算处理:

DM的处理

计提思路:

第一步、先进行行转列的处理

select t.id,

(select p.x from Point p where  t.`pointId1` =p.id) as px1,

(select p.y from Point p where  t.`pointId1` =p.id) as py1,

(select p.z from Point p where  t.`pointId1` =p.id) as pz1,

(select p.x from Point p where  t.`pointId2` =p.id) as px2,

(select p.y from Point p where  t.`pointId2` =p.id) as py2,

(select p.z from Point p where  t.`pointId2` =p.id) as pz2,

(select p.x from Point p where  t.`pointId3` =p.id) as px3,

(select p.y from Point p where  t.`pointId3` =p.id) as py3,

(select p.z from Point p where  t.`pointId3` =p.id) as pz3

from `triangle`  t   where  t.id=1

第二步,代入公式计算是否正确:

select id as TriangleId ,round(((px2-px1)*(px3-px1)*(py2-py1)*(py3-py1)*(pz2-pz1)*(pz3-pz1))/2,2) as Area from (

select t.id,

(select p.x from Point p where  t.`pointId1` =p.id) as px1,

(select p.y from Point p where  t.`pointId1` =p.id) as py1,

(select p.z from Point p where  t.`pointId1` =p.id) as pz1,

(select p.x from Point p where  t.`pointId2` =p.id) as px2,

(select p.y from Point p where  t.`pointId2` =p.id) as py2,

(select p.z from Point p where  t.`pointId2` =p.id) as pz2,

(select p.x from Point p where  t.`pointId3` =p.id) as px3,

(select p.y from Point p where  t.`pointId3` =p.id) as py3,

(select p.z from Point p where  t.`pointId3` =p.id) as pz3

from `triangle`  t  )  tt

相关文章
|
6月前
|
存储 NoSQL Redis
阿里云高性能数据库Tair(兼容 Redis)收费价格,稳定可靠成本低
阿里云高性能云数据库Tair兼容Redis,提供Redis开源版和Tair企业版,支持多种存储介质与灵活扩展,适用于高并发场景。Tair具备亚毫秒级稳定延迟,保障业务连续性。价格方面,Redis开源版年费从72元起,Tair企业版年费从1224元起,具体费用根据配置不同有所变化。
|
6月前
|
关系型数据库 MySQL 数据库
阿里云数据库RDS费用价格:MySQL、SQL Server、PostgreSQL和MariaDB引擎收费标准
阿里云RDS数据库支持MySQL、SQL Server、PostgreSQL、MariaDB,多种引擎优惠上线!MySQL倚天版88元/年,SQL Server 2核4G仅299元/年,PostgreSQL 227元/年起。高可用、可弹性伸缩,安全稳定。详情见官网活动页。
1127 152
|
6月前
|
关系型数据库 MySQL 数据库
阿里云数据库RDS支持MySQL、SQL Server、PostgreSQL和MariaDB引擎
阿里云数据库RDS支持MySQL、SQL Server、PostgreSQL和MariaDB引擎,提供高性价比、稳定安全的云数据库服务,适用于多种行业与业务场景。
861 156
|
6月前
|
SQL 人工智能 Linux
SQL Server 2025 RC1 发布 - 从本地到云端的 AI 就绪企业数据库
SQL Server 2025 RC1 发布 - 从本地到云端的 AI 就绪企业数据库
595 5
SQL Server 2025 RC1 发布 - 从本地到云端的 AI 就绪企业数据库
|
5月前
|
SQL 存储 监控
SQL日志优化策略:提升数据库日志记录效率
通过以上方法结合起来运行调整方案, 可以显著地提升SQL环境下面向各种搜索引擎服务平台所需要满足标准条件下之数据库登记作业流程综合表现; 同时还能确保系统稳健运行并满越用户体验预期目标.
327 6
|
6月前
|
关系型数据库 MySQL 分布式数据库
阿里云PolarDB云原生数据库收费价格:MySQL和PostgreSQL详细介绍
阿里云PolarDB兼容MySQL、PostgreSQL及Oracle语法,支持集中式与分布式架构。标准版2核4G年费1116元起,企业版最高性能达4核16G,支持HTAP与多级高可用,广泛应用于金融、政务、互联网等领域,TCO成本降低50%。
|
6月前
|
SQL 关系型数据库 MySQL
阿里云的云数据库RDS简介
阿里云关系型数据库RDS(Relational Database Service)是一种安全稳定、高性价比、可弹性伸缩的在线数据库服务。支持MySQL、SQL Server、PostgreSQL和MariaDB引擎,提供容灾、备份、恢复、监控、迁移等全套解决方案,帮助用户轻松应对数据库运维挑战。RDS具备高可用性、高安全性、轻量运维和弹性伸缩等优势,适用于各类业务场景,助力企业降低成本、提升效率。
|
关系型数据库 MySQL 网络安全
5-10Can't connect to MySQL server on 'sh-cynosl-grp-fcs50xoa.sql.tencentcdb.com' (110)")
5-10Can't connect to MySQL server on 'sh-cynosl-grp-fcs50xoa.sql.tencentcdb.com' (110)")

热门文章

最新文章