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 ,可是没有赋值,求解答

...全文
83 3 点赞 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
当前发帖距今超过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
这个语句您能查到值么?查不到的话自然就没法赋值啊。
  • 打赏
  • 举报
回复
相关推荐
发帖
疑难问题
创建于2007-09-28

2.1w+

社区成员

MS-SQL Server 疑难问题
申请成为版主
帖子事件
创建了帖子
2015-11-17 02:21
社区公告
暂无公告