Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 秩和日期更改大小写表达式_Sql Server - Fatal编程技术网

Sql server 秩和日期更改大小写表达式

Sql server 秩和日期更改大小写表达式,sql-server,Sql Server,我试图展示下面的第二部分。如果一个人从高到低是好的,但如果他们从低到高是坏的。有没有关于我如何做到这一点的想法?我有返回顶部部分的SQL,但不确定如何获取第二部分 你可能在寻找函数 对于全局资源,请使用自连接: select curr.membno, prev.rancs, curr.rancs , case when prev.rancs > curr.rancs then 'GOOD' when prev.rancs < curr.rancs then 'BAD'

我试图展示下面的第二部分。如果一个人从高到低是好的,但如果他们从低到高是坏的。有没有关于我如何做到这一点的想法?我有返回顶部部分的SQL,但不确定如何获取第二部分

你可能在寻找函数

对于全局资源,请使用自连接:

select curr.membno, prev.rancs, curr.rancs
, case 
   when prev.rancs > curr.rancs then 'GOOD' 
   when prev.rancs < curr.rancs then 'BAD'
   else 'i do''n know'
   end second_part
from something curr 
left join something prev on curr.membno = prev.membno and curr.date_rank = prev.date_rank + 1
where not exists (select 1 from something pres where pres.membno = curr.membno and curr.date_rank + 1 = pres.date_rank)

你的意思还不完全清楚。但是,对于初学者来说,由于您有返回顶部的sql,您可能想发布它?对于membno 1234,它从4变为3非常好,而6789从3变为4,这是不好的。
select curr.membno, prev.rancs, curr.rancs
, case 
   when prev.rancs > curr.rancs then 'GOOD' 
   when prev.rancs < curr.rancs then 'BAD'
   else 'i do''n know'
   end second_part
from something curr 
left join something prev on curr.membno = prev.membno and curr.date_rank = prev.date_rank + 1
where not exists (select 1 from something pres where pres.membno = curr.membno and curr.date_rank + 1 = pres.date_rank)