更新语句
update Basic_CustMember set watchNoSignalTime = b.countNum,WatchWeakSignalTime = b.ylDiastolic,WatchWrongTakeTime = b.ylSystolic where CustNo = 4
查询语句
select count(*) countNum,avg(cast(YLdiastolic as int)) ylDiastolic,avg(cast(YLsystolic as int)) ylSystolic
from Basic_CustYLLog b where YLBeginDateTime >= '2013-02-01 02:20:45' and YLBeginDateTime <= '2013-12-09' and CustNo = 4
如何用一句sql完成以下内容。
sql server 2000 如何查询出来后更新到某个字段
答案:2 悬赏:30
解决时间 2021-02-22 18:32
- 提问者网友:猖狂醉薇
- 2021-02-21 21:01
最佳答案
- 二级知识专家网友:转身→时光静好
- 2021-02-21 22:19
按照你的语句改写如下(但只能更改CUSTNO=4的一条记录):
update Basic_CustMember set
watchNoSignalTime = b.countNum,
WatchWeakSignalTime = b.ylDiastolic,
WatchWrongTakeTime = b.ylSystolic
FROM Basic_CustMember,
(select count(*) countNum,avg(cast(YLdiastolic as int)) ylDiastolic,avg(cast(YLsystolic as int)) ylSystolic
from Basic_CustYLLog b where YLBeginDateTime >= '2013-02-01 02:20:45' and YLBeginDateTime <= '2013-12-09' and CustNo = 4
) A
where Basic_CustMember.CustNo = 4
这样可以按CUSTNO更改所有数据
update Basic_CustMember set
watchNoSignalTime = b.countNum,
WatchWeakSignalTime = b.ylDiastolic,
WatchWrongTakeTime = b.ylSystolic
FROM Basic_CustMember,
(select custno,count(*) countNum,avg(cast(YLdiastolic as int)) ylDiastolic,avg(cast(YLsystolic as int)) ylSystolic
from Basic_CustYLLog b where YLBeginDateTime >= '2013-02-01 02:20:45' and YLBeginDateTime <= '2013-12-09' group by custno
) A
where Basic_CustMember.CustNo =A.CustNo
update Basic_CustMember set
watchNoSignalTime = b.countNum,
WatchWeakSignalTime = b.ylDiastolic,
WatchWrongTakeTime = b.ylSystolic
FROM Basic_CustMember,
(select count(*) countNum,avg(cast(YLdiastolic as int)) ylDiastolic,avg(cast(YLsystolic as int)) ylSystolic
from Basic_CustYLLog b where YLBeginDateTime >= '2013-02-01 02:20:45' and YLBeginDateTime <= '2013-12-09' and CustNo = 4
) A
where Basic_CustMember.CustNo = 4
这样可以按CUSTNO更改所有数据
update Basic_CustMember set
watchNoSignalTime = b.countNum,
WatchWeakSignalTime = b.ylDiastolic,
WatchWrongTakeTime = b.ylSystolic
FROM Basic_CustMember,
(select custno,count(*) countNum,avg(cast(YLdiastolic as int)) ylDiastolic,avg(cast(YLsystolic as int)) ylSystolic
from Basic_CustYLLog b where YLBeginDateTime >= '2013-02-01 02:20:45' and YLBeginDateTime <= '2013-12-09' group by custno
) A
where Basic_CustMember.CustNo =A.CustNo
全部回答
- 1楼网友:情窦初殇
- 2021-02-21 22:34
可用两种方法,一种是在microsoft sql server manager studio中的图形界面查询,另一种是语句查询。
方法1:
1、使用microsoft sql server manager studio登录数据库。
2、在左边树找到要查的表,并点击前边的“+”
3、点击“列”前边的“+”
4、然后就可以看到要查的字段的类型了,如图:
方法2:
直接用语句查询,如要查student表中的所有字段类型:
select a.name 表名,b.name 字段名,c.name 字段类型,c.length 字段长度 from sysobjects a,syscolumns b,systypes c where a.id=b.id
and a.name='student' and a.xtype='u'
and b.xtype=c.xtype结果截图:
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯