sql季度平均量实现基本情况如题,SQL实现如下(主要是用到了case when<条件> then<结果>):

select jidu,avg(chanzhi)as chanzhi
from
(
select *,
case when id<4 then 1 when id<7 then 2
when(id>6 and id<10)then 3 when id>9 then 4 end as jidu
from tab1
)tab1new group by jidu

其中tab1为整个表名

二、

查找第三名:

select * from
(select *,row_number() over(order by score desc)as cid from status)aa
where aa.cid=3

三、

t1(id,name) t2(id,score)t2增加一个name怎么用第一张表name增加,里面name 的数据 跟 t1 的对应

update t2 set t2.name=(
 select top 1 name from t1 where t1.id=t2.id
)

 

相关文章:

  • 2021-06-05
  • 2021-05-17
  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
猜你喜欢
  • 2022-12-23
  • 2021-12-27
  • 2021-11-25
  • 2022-12-23
  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案