日期:2014-05-18 浏览次数:20554 次
IF EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name = 'tba') BEGIN DROP TABLE tba END GO CREATE TABLE tba ( no INT, sno VARCHAR(10), ino VARCHAR(10), useid VARCHAR(10) ) GO INSERT INTO tba SELECT 11, '111-1', '11-1', 'xxx' UNION SELECT 11, '111-2', '11-2', 'yyy' UNION SELECT 12, '112-1', '12-1', 'jjj' UNION SELECT 12, '112-2', '12-2', 'kkk' UNION SELECT 12, '112-3', '12-3', 'uuu' SELECT * FROM tba AS T WHERE (SELECT COUNT(1) FROM tba WHERE t.no = no AND sno > t.sno) < 1 no sno ino useid 11 111-2 11-2 yyy 12 112-3 12-3 uuu