早教吧作业答案频道 -->其他-->
sql语句看不懂,今天看了朋友写的一个sql语句,没看懂什么意思,还望高手把它翻译成通俗易懂的中文DELETEFROMResumeStatsWHEREYMD=CONVERT(varchar(8),@Yesterday,112);WITHDayResumeStatsAS(SELECTCONVERT(varchar
题目详情
sql语句看不懂,今天看了朋友写的一个sql语句,没看懂什么意思,还望高手把它翻译成通俗易懂的中文
DELETE FROM ResumeStats WHERE YMD=CONVERT(varchar(8), @Yesterday, 112);
WITH DayResumeStats AS(
SELECT CONVERT(varchar(8), @Yesterday, 112) AS YMD,
ISNULL(SUM(CASE WHEN Created BETWEEN @Yesterday AND @Today THEN 1 ELSE 0 END),0) AS NewResumes,
ISNULL(SUM(CASE WHEN Refreshed BETWEEN @Yesterday AND @Today THEN 1 ELSE 0 END),0) AS RefreshedResumes,
ISNULL(SUM(CASE WHEN OpenType<>0 THEN 1 ELSE 0 END),0) AS OpenResumes,
ISNULL(SUM(CASE WHEN (Rank<60 and Created BETWEEN @Yesterday AND @Today) THEN 1 ELSE 0 END),0) AS LowRankResumes
FROM Resumes
)
DELETE FROM ResumeStats WHERE YMD=CONVERT(varchar(8), @Yesterday, 112);
WITH DayResumeStats AS(
SELECT CONVERT(varchar(8), @Yesterday, 112) AS YMD,
ISNULL(SUM(CASE WHEN Created BETWEEN @Yesterday AND @Today THEN 1 ELSE 0 END),0) AS NewResumes,
ISNULL(SUM(CASE WHEN Refreshed BETWEEN @Yesterday AND @Today THEN 1 ELSE 0 END),0) AS RefreshedResumes,
ISNULL(SUM(CASE WHEN OpenType<>0 THEN 1 ELSE 0 END),0) AS OpenResumes,
ISNULL(SUM(CASE WHEN (Rank<60 and Created BETWEEN @Yesterday AND @Today) THEN 1 ELSE 0 END),0) AS LowRankResumes
FROM Resumes
)
▼优质解答
答案和解析
这个应该是SQL2005以上版本的语句,且该语句用于临时用途;
with关键字从resume表生成一个CTE(用表表达式,仅作用于单个查询语句之内,可以认为是创建的命名临时表)DayResumeStats;该CTE中筛选出所有不符合条件的NewResumes,
RefreshedResumes,OpenResumes,和 LowRankResumes;(看字面是筛选出所有非新的、未更新的、未开放的和低级别的简历),
delete 语句从该DayResumeStats中删除所有YMD=@yesterday的记录;,
with关键字从resume表生成一个CTE(用表表达式,仅作用于单个查询语句之内,可以认为是创建的命名临时表)DayResumeStats;该CTE中筛选出所有不符合条件的NewResumes,
RefreshedResumes,OpenResumes,和 LowRankResumes;(看字面是筛选出所有非新的、未更新的、未开放的和低级别的简历),
delete 语句从该DayResumeStats中删除所有YMD=@yesterday的记录;,
看了sql语句看不懂,今天看了朋友...的网友还看了以下:
求一个简单的方程组的解我怎么都求不出来,求出来的解带入进去不对,请回答这个问题的验证一下你的答案, 2020-05-16 …
解cosA-1/(2COSA),cosA属于[1/2,1]的取值范围令t=cosA,则f(t)=t 2020-05-17 …
令文法G[E]为:E→T|E+T|E-TT→F|T*F|T/FF→(E)|i证明E+T*F是它的一 2020-07-08 …
针对程序段:IF(A||B||C)THENW=W/X,对于(A,B,C)的取值,(57)测试用例能 2020-07-10 …
变限积分[a,b]上的积分∫[f(x+h)-f(x)]dx令x+h=t,那原式=∫[a+h,b+h 2020-07-11 …
F(根号X+1)=x+2根号x求fx设√x+1=tx=(t-1)²f(√x+1)=f(t)=(t- 2020-07-18 …
求柱面的方程..准线为f(x,y)=0,z=0;母线的方向向量为s={l,m,n},则柱面的方程f 2020-07-31 …
求助微积分强人帮忙解这个二阶方程f"(t)=a1=(π〖d/2〗^2P(t)-k[x+f(t)]- 2020-07-31 …
关于高一函数的换元法已知f(x-1)=x²-2x,求f(x)老师给的解题过程:设t=x-1∵x∈R 2020-08-01 …
关于周期函数积分的问题,有一个定理理解不了,假定周期函数f(x)以T为周期,则f(x)的全体原函数 2020-08-01 …