SQL复杂查询问题!
我现在有一个表,有一个头痛的查询问题,看看哪个朋友可以帮忙划解一下!
表1 ID name mobile state times
1 刘一 8888888 0 2009-09-17
2 李一 8777888 0 2009-09-16
3 刘一 8888888 0 2009-09-17
4 赵一 8888866 1 2009-09-18
5 刘一 8888888 0 2009-09-17
6 李一 8777888 0 2009-09-15
7 刘一 8888888 1 2009-09-14
我现在想按手机号分组,更新相同记录的最新一条记录的时间并且把所有对应的state至1,其它相同记录时间不变,
SQL code:
UPDATE A SET
times = GETDATE(),
state = 1
from tb AS A
WHERE NOT EXISTS(SELECT * from tb
WHERE mobile = A.mobile AND times > A.times);
是这个意思吗?
NOT去掉.
{{----}
相关问答:
with adod_dict do
begin
close;
commandtext:='select bgqxcode,count(*) wjsl from wscl_wsda_file where wjnd=:tnd group by bgqxcode'; ......
PB中开发的。
DateTime startTime=DateTime(em_1.Text)
DateTime endTime=DateTime(em_2.Text)
string sql
sql = dw_1.GetSQLSelect()+"Where (StartTime> '"+startTime+&q ......
(1)string ConnString = "server=localhost;integrated security=sspi;database=pubs;";
(2)string strConnection="user uid=sa;pwd=123456;Database=test;Server=test;Connect ......
请问:
1,如何将一张dbf表导入到sql server2000中的一张表。使用DTS该怎样实现?
2,使用网上代码:
Insert Into Tb_cj Select * from openrowset('MSDASQL','Driver=Microsoft Visual FoxPro D ......