-1
Create Table Active1 (Name Varchar(20), ID int IDENTITY(1,1))
Select * from Active1
NAME ID
-------------------- ----------------------
vj 102
vj 103
vj 104
vj 105
vj 106
swami 108
swami 109
需要輸出對於
如何獲得ID字段中的最大值並將該值設置爲同名(列)值,動態可能嗎?
vj 106
vj 106
vj 106
vj 106
vj 106
vj 106
vj 106
vj 106
vj 106
swami 108
swami 109
(動態獲取和更新值)
Update Active1 SET ID=(select MAX(ID) from Active1 where Name = (select NAME from Active1) group by name HAVING count(name) > 1);
Update Active1 SET ID=(select MAX(ID) from Active1) where name= 'select NAME from Active1' where name= 'select NAME from Active1';
[我怎麼問** *好* question?](http://stackoverflow.com/help/how-to-ask) –