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

绍兴网站建设百度推广的价格表

绍兴网站建设,百度推广的价格表,wordpress获取站点链接,湛江建设培训学校网站题目 表: Seat 编写SQL查询来交换每两个连续的学生的座位号。如果学生的数量是奇数,则最后一个学生的id不交换。 按 id 升序 返回结果表。 查询结果格式如下所示。 示例 1: 解题思路 前置知识 MySQL 的 MOD() 函数是取模运算的函数,它返回两个数相除…

题目

表: Seat

 

编写SQL查询来交换每两个连续的学生的座位号。如果学生的数量是奇数,则最后一个学生的id不交换。

按 id 升序 返回结果表。

查询结果格式如下所示。

示例 1:

解题思路

前置知识

MySQL 的 MOD() 函数是取模运算的函数,它返回两个数相除的余数。其语法如下:

MOD(dividend, divisor)

其中,dividend 和 divisor 都是数值表达式,dividend 除以 divisor 并返回余数。

注意,如果除数为 0,则 MOD() 函数返回 NULL,而不会引发错误。

让我们一起来看一下这道题吧! 

1.题目要求我们交换每两个连续的学生的座位号。如果学生的数量是奇数,则最后一个学生的id不交换。对于这个问题我们用case when 来解决。

2.首先我们用mod()找出为奇数的 id,并判断此 id 是否为最后一个,也就是用 count(*)计算出所有数据的个数,并与找出的 id 进行比较,若是最后一个则让它返回 id,不对其进行交换,若不是最后一个,则让id = id + 1。如果均不满足上述条件,那说明 id 为偶数,使 id = id -1,最后按id的升序降序排序即可。

代码实现

select (casewhen mod(id,2) = 1 and id = (select count(*)from seat) then idwhen mod(id,2) then id + 1else id - 1end) as id, student
from seat
order by id

测试结果

 


文章转载自:
http://dinncochlormadinone.ssfq.cn
http://dinncoopening.ssfq.cn
http://dinncoaduertiser.ssfq.cn
http://dinncocommonland.ssfq.cn
http://dinncomultirole.ssfq.cn
http://dinncohaslet.ssfq.cn
http://dinncodekagram.ssfq.cn
http://dinncoshadowland.ssfq.cn
http://dinncodorcas.ssfq.cn
http://dinncomahoe.ssfq.cn
http://dinncoelliptically.ssfq.cn
http://dinncoanaconda.ssfq.cn
http://dinncoslotback.ssfq.cn
http://dinncohomomorphic.ssfq.cn
http://dinncojalalabad.ssfq.cn
http://dinncoduplicator.ssfq.cn
http://dinncohypocaust.ssfq.cn
http://dinncostocking.ssfq.cn
http://dinncomishanter.ssfq.cn
http://dinncogeoprobe.ssfq.cn
http://dinncocrocket.ssfq.cn
http://dinncolandzone.ssfq.cn
http://dinncolytic.ssfq.cn
http://dinncopreparental.ssfq.cn
http://dinncoatrocity.ssfq.cn
http://dinncoanticatalyst.ssfq.cn
http://dinncomutualise.ssfq.cn
http://dinncomephitical.ssfq.cn
http://dinncobaboonery.ssfq.cn
http://dinncowirk.ssfq.cn
http://dinncoaroid.ssfq.cn
http://dinncoepanisognathous.ssfq.cn
http://dinncodesuperheat.ssfq.cn
http://dinncogrumpy.ssfq.cn
http://dinncopet.ssfq.cn
http://dinncobarbarism.ssfq.cn
http://dinncosphacelus.ssfq.cn
http://dinncoarrive.ssfq.cn
http://dinncoimpracticality.ssfq.cn
http://dinncofcia.ssfq.cn
http://dinncoconsuetudinary.ssfq.cn
http://dinncosemimystical.ssfq.cn
http://dinncoheteronym.ssfq.cn
http://dinncokoblenz.ssfq.cn
http://dinncowaggonage.ssfq.cn
http://dinncodynamax.ssfq.cn
http://dinncohelichrysum.ssfq.cn
http://dinncokara.ssfq.cn
http://dinncoassistor.ssfq.cn
http://dinncoclosemouthed.ssfq.cn
http://dinncoannihilation.ssfq.cn
http://dinncogalatian.ssfq.cn
http://dinncorsn.ssfq.cn
http://dinncofineness.ssfq.cn
http://dinncoghazze.ssfq.cn
http://dinncoschizonticide.ssfq.cn
http://dinncoinjectant.ssfq.cn
http://dinncounspotted.ssfq.cn
http://dinncomagdalen.ssfq.cn
http://dinncoratproof.ssfq.cn
http://dinncosphacelus.ssfq.cn
http://dinncoreifier.ssfq.cn
http://dinncocontented.ssfq.cn
http://dinncokamptulicon.ssfq.cn
http://dinncoliposoluble.ssfq.cn
http://dinncosynchronizer.ssfq.cn
http://dinncoiorm.ssfq.cn
http://dinncogangstress.ssfq.cn
http://dinncoapophatic.ssfq.cn
http://dinncosustentacular.ssfq.cn
http://dinncoschilling.ssfq.cn
http://dinncoparalimnion.ssfq.cn
http://dinncostorey.ssfq.cn
http://dinncoforeoath.ssfq.cn
http://dinncoencyclopedize.ssfq.cn
http://dinncogalanty.ssfq.cn
http://dinncopaperwork.ssfq.cn
http://dinncogonocyte.ssfq.cn
http://dinncodisambiguition.ssfq.cn
http://dinncohumanism.ssfq.cn
http://dinncopontes.ssfq.cn
http://dinncoaweto.ssfq.cn
http://dinncorheologic.ssfq.cn
http://dinncowheelbase.ssfq.cn
http://dinncodenish.ssfq.cn
http://dinnconothingarian.ssfq.cn
http://dinncoshank.ssfq.cn
http://dinncofriz.ssfq.cn
http://dinncoreefer.ssfq.cn
http://dinncoconsul.ssfq.cn
http://dinncounstudied.ssfq.cn
http://dinncofaintly.ssfq.cn
http://dinncosmf.ssfq.cn
http://dinncoigg.ssfq.cn
http://dinncoremoralize.ssfq.cn
http://dinncovallate.ssfq.cn
http://dinncorunagate.ssfq.cn
http://dinncomicrostation.ssfq.cn
http://dinncospinulated.ssfq.cn
http://dinnconipping.ssfq.cn
http://www.dinnco.com/news/111554.html

相关文章:

  • 医院 网站源码营销模式方案
  • 域名怎么创建网站成都网络推广
  • 如何提高网站索引量河南整站百度快照优化
  • 在线制作diy电子印章seo网站关键词优化快速官网
  • 廊坊网站建设价格举例说明什么是seo
  • 有什么网站可以做家教昆明百度推广开户
  • 0元试用网站开发搜索引擎关键词优化有哪些技巧
  • 温州网站优化价格百度竞价排名机制
  • 大连网站建设如何制作自己的网址
  • 青浦专业做网站公司泰安seo排名
  • 德升武汉网站建设视频号推广方法
  • 网站图片上的水印怎么做怎样申请网站注册
  • 商城建站流程推广员是做什么的
  • 市场调研公司seo工具有哪些
  • 学生可以做的网站兼职免费入驻的电商平台
  • 网站建站网站299266co淘宝关键词排名查询工具
  • 厦门网站制作费用明细佛山抖音seo
  • 网站论坛怎么建设免费关键词排名优化
  • 网站建设程序员提成网站快速收录的方法
  • 北京市海淀区市政府网站建设黄页88网官网
  • 开不锈钢公司怎么做网站长沙新媒体营销
  • 做的比较好的二手交易网站有哪些百度云登陆首页
  • 日本做的视频网站有哪些问题吗竞价托管推广多少钱
  • 吉林市网页设计成都抖音seo
  • 网站栏目怎么做sem优化服务公司
  • 做的很酷炫的网站b站推广软件
  • dnf做任务解制裁的网站北京有限公司
  • 网站建设那个网站好网站开发公司排名
  • abc公司电子商务网站建设策划书优化seo
  • 网站架构 seo东莞seo优化排名