当前位置: 首页 > news >正文

阿里云 全国网站建设平面设计免费软件

阿里云 全国网站建设,平面设计免费软件,网站注册域名后怎么做,谷歌sem推广大家好#xff0c;我是空空star#xff0c;本篇带大家了解一道中等的力扣sql练习题。 文章目录前言一、题目#xff1a;608. 树节点二、解题1.正确示范①提交SQL运行结果2.正确示范②提交SQL运行结果3.正确示范③提交SQL运行结果4.正确示范④提交SQL运行结果5.其他总结前言 … 大家好我是空空star本篇带大家了解一道中等的力扣sql练习题。 文章目录前言一、题目608. 树节点二、解题1.正确示范①提交SQL运行结果2.正确示范②提交SQL运行结果3.正确示范③提交SQL运行结果4.正确示范④提交SQL运行结果5.其他总结前言 一、题目608. 树节点 给定一个表 treeid 是树节点的编号 p_id 是它父节点的 id 。 ---------- | id | p_id | ---------- | 1 | null | | 2 | 1 | | 3 | 1 | | 4 | 2 | | 5 | 2 | ----------树中每个节点属于以下三种类型之一 叶子如果这个节点没有任何孩子节点。 根如果这个节点是整棵树的根即没有父节点。 内部节点如果这个节点既不是叶子节点也不是根节点。 写一个查询语句输出所有节点的编号和节点的类型并将结果按照节点编号排序。上面样例的结果为 ---------- | id | Type | ---------- | 1 | Root | | 2 | Inner| | 3 | Leaf | | 4 | Leaf | | 5 | Leaf | ----------解释 节点 ‘1’ 是根节点因为它的父节点是 NULL 同时它有孩子节点 ‘2’ 和 ‘3’ 。 节点 ‘2’ 是内部节点因为它有父节点 ‘1’ 也有孩子节点 ‘4’ 和 ‘5’ 。 节点 ‘3’, ‘4’ 和 ‘5’ 都是叶子节点因为它们都有父节点同时没有孩子节点。 样例中树的形态如下 注意 如果树中只有一个节点你只需要输出它的根属性。 二、解题 1.正确示范① 提交SQL select id, case when p_id is null then Root when id in (select p_id from tree) then Inner else Leaf end Type from tree order by id;运行结果 2.正确示范② 提交SQL select id, if(p_id is null,Root,if(id in (select p_id from tree),Inner,Leaf)) Type from tree order by id;运行结果 3.正确示范③ 提交SQL select id,Root Type from tree where p_id is null union all select id,Inner Type from tree where id in(select p_id from tree ) and p_id is not null union all select id,Leaf Type from tree where id not in(select p_id from tree where p_id is not null ) and p_id is not null order by id;运行结果 4.正确示范④ 提交SQL select id,Root Type from tree where p_id is null union select id,Inner Type from tree where id in(select p_id from tree ) and p_id is not null union select id,Leaf Type from tree where id not in(select p_id from tree where p_id is not null ) and p_id is not null order by id;运行结果 5.其他 总结 正确示范①思路 采用case when 语句 case when p_id is null then Root when id in (select p_id from tree) then Inner else Leaf end Type 正确示范②思路 采用 if 语句 if(p_id is null,Root,if(id in (select p_id from tree),Inner,Leaf)) Type 正确示范③思路 采用union all 语句 正确示范④思路 采用 union 语句
http://www.hkea.cn/news/14463149/

相关文章:

  • 广州做网站最好的公司网站开发教程 布局
  • 云南微网站搭建费用做网站网站会被判多久
  • 定制网站模板网站不备案可以建设吗
  • 自已建设网站流程wordpress自定义文章类型如何调用
  • 自己做免费手机网站软件网站建设基本流程
  • wordpress主题 动漫从百万到千万 网站怎么优化
  • 常见cms网站源码下载网站弹出广告gif出处
  • 营销网站的建立网站建设力度
  • 河源哪里做网站网站开发和运行 法律
  • 数字货币网站开发需求wordpress搭建cms网站
  • 怎么搭建网站视频教程网站销售怎么样
  • 购物网站运作建筑平面设计图
  • wordpress删除用户下所有文章上海网站营销seo电话
  • 没有网站怎么做排名优化网页怎么制作二维码
  • wordpress网站建设教程海外seo网站推广
  • 营销型网站跟云网站网站建设与规划专业
  • 免费做网站表白电商网站设计欣赏
  • 怎么创建网站要钱吗做复印机的模板网站
  • 教育网站图片中国学校网站前台模板
  • 找公司开发网站美容院做免费推广哪个网站
  • 像淘宝购物网站建设需要哪些专业人员?电子商务网站详细设计
  • 网站集约化建设优点wordpress 聚合6
  • 微信营销微网站建设石家庄网站建设网站
  • 深圳市住建局网站网上营销手段
  • 搭建网站的价格怎么修改自己公司网站
  • 广东省工程建设注册中心网站哪里有网站设计学
  • 网站开发路径一个公司的官网怎么做
  • 一站式建站价格襄阳建设21网站
  • 教育培训网站模板下载h5制作软件 知乎
  • 检测设备技术支持东莞网站建设能够免费换友链的平台