sql语句含义

[复制链接]
查看11 | 回复2 | 2009-4-18 08:34:30 | 显示全部楼层 |阅读模式
update da_czk set ye=ye-zckxf.xf from
(select id as card_no ,sum(amt) as xf from xs_003 where id'' andbdate='2007-03-08'
group by id
) zckxf where da_czk.card_no=zckxf.card_no

回复

使用道具 举报

千问 | 2009-4-18 08:34:30 | 显示全部楼层
select id as card_no ,sum(amt) as xf from xs_003 where id'' and bdate='2007-03-08' group by id 第一我们先看这句话:这是用id分组,取 amt字段的和,且id不能为空,和日期bdate是2007-03-08的.这个查询可以出来一个结果集合,我们给他起名为:zckxf这样我们的sql语句就变成了:update da_czk set ye=ye-zckxf.xf from zckxf where da_czk.card_no=zckxf.card_no这样我们就能看懂了通过card_no把da_czk和我们刚才取的结果集(z...
回复

使用道具 举报

千问 | 2009-4-18 08:34:30 | 显示全部楼层
update da_czk set ye=ye-zckxf.xf from (select id as card_no ,sum(amt) as xf from xs_003 where id'' and bdate='2007-03-08' group by id ) zckxf where da_czk.card_no=zckxf.car...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行