sql问题,急

知道vdsdf 2015-11-17 02:21:58
string sql12=string.Format(@"update Entity_69052 set differencefe=t.chazhi from (
select slotnum
,MAX(CAST(ContentFe AS FLOAT))-MIN(CAST(ContentFe AS FLOAT)) as chazhi
,MAX(ExamineTime) as maxtime from Entity_69052 where ExamineTime<(select Max(ExamineTime) from Entity_69052 where Entity_69051_FK ='{0}')
group by slotnum) t
where Entity_69052.slotnum = t.slotnum and ExamineTime = t.maxtime and t.chazhi is not null",KeyOID);


想求出Entity_69052 中 某一时间与某一时间的ContentFe差,赋值给 differencefe ,可是没有赋值,求解答

...全文
103 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Yole 2015-11-17
  • 打赏
  • 举报
回复

update a  set a.differencefe=t.chazhi
from Entity_69052 a,
(
select slotnum
,MAX(CAST(ContentFe AS FLOAT))-MIN(CAST(ContentFe AS FLOAT)) as chazhi
,MAX(ExamineTime) as maxtime from Entity_69052  where ExamineTime<(select Max(ExamineTime) from Entity_69052 where Entity_69051_FK ='{0}')
group by slotnum
) t
where a.slotnum = t.slotnum and a = t.maxtime and t.chazhi is not null
语法上没问题~不知道数据是啥样的
知道vdsdf 2015-11-17
  • 打赏
  • 举报
回复
引用 1 楼 u010192842 的回复:

select differencefe
 from (
select slotnum
,MAX(CAST(ContentFe AS FLOAT))-MIN(CAST(ContentFe AS FLOAT)) as chazhi
,MAX(ExamineTime) as maxtime from Entity_69052  where ExamineTime<(select Max(ExamineTime) from Entity_69052 where Entity_69051_FK ='{0}')
group by slotnum) t
where Entity_69052.slotnum = t.slotnum and ExamineTime = t.maxtime and t.chazhi is not null
这个语句您能查到值么?查不到的话自然就没法赋值啊。
感谢你回答我的问题,我想问我写的对不对,,,数据库影噶能查到这个数据,我应该是写错了,求改写 [quote=引用 1 楼 u010192842 的回复:]

select differencefe
 from (
select slotnum
,MAX(CAST(ContentFe AS FLOAT))-MIN(CAST(ContentFe AS FLOAT)) as chazhi
,MAX(ExamineTime) as maxtime from Entity_69052  where ExamineTime<(select Max(ExamineTime) from Entity_69052 where Entity_69051_FK ='{0}')
group by slotnum) t
where Entity_69052.slotnum = t.slotnum and ExamineTime = t.maxtime and t.chazhi is not null
这个语句您能查到值么?查不到的话自然就没法赋值啊。[/quote 感谢你回答我的问题,我想问我写的对不对,,,数据库影噶能查到这个数据,我应该是写错了,求改写
Yole 2015-11-17
  • 打赏
  • 举报
回复

select differencefe
 from (
select slotnum
,MAX(CAST(ContentFe AS FLOAT))-MIN(CAST(ContentFe AS FLOAT)) as chazhi
,MAX(ExamineTime) as maxtime from Entity_69052  where ExamineTime<(select Max(ExamineTime) from Entity_69052 where Entity_69051_FK ='{0}')
group by slotnum) t
where Entity_69052.slotnum = t.slotnum and ExamineTime = t.maxtime and t.chazhi is not null
这个语句您能查到值么?查不到的话自然就没法赋值啊。

22,300

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧