求sql语句理解
表A
卡号 时间
1 null
2 null
3 null
表B
卡号 时间
1 2008-1-6
1 2004-5-3
2 2005-5-6
3 2003-5-9
3 2001-2-3
问题:更新 表A里的 相应卡号的时间为 表B里相应卡号的(最小)时间
正确的结果:
1 2004-5-3(最小)
2 2005-5-6
3 2001-2-3(最小)
liangCK:
SQL code:
update a set
时间 = b.时间
from tb1 as a
join tb2 as b
on a.卡号= b.卡号
where not exists(select * from tb2
where 卡号=b.卡号 and 时间> b.时间)
b 内表
1 2007 1 2007
1 2008 1 2008
1 2004 1 2004
2007 = <all N
2008 = <all
相关问答:
小弟是个新手 现在有个问题一直不能解决
例如
procedure produce_proc
@p001 nvarchar(8000),
@p002 nvarchar(8000),
@p003 nvarchar(8000),
& ......
两种错误:
1.如果我这样申明:ResultSet rs;错误提示如下:
An error occurred at line: 51 in the jsp file: /index.jsp
The local variable rs may not have been initialized
48: ......
sql2005
select *from v_ddxx where d_sfsc='0' and (g_ssbm='1001' or g_ssbm='1002') and (xxf>0 and xxfwzf <>0 ),执行速度慢的要死,但是如果把(xxf>0 and ......
我有一个月和日组成的数字,有两组月和日
想在身份证号中挑选出在该该两组月日之间出生的人,不知道应该怎么写.
身份证号有可能是15位或者18位
月日组合的形式如下
10-17/04-20
月-日/月- ......
pln_id memo
1 我是
1 你好
2 你是
2 我好
结果
pln_id memo
......