34,873
社区成员
发帖
与我相关
我的任务
分享--> 测试数据:[tb]
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([id] int,[code] varchar(14),timestamp)
insert [tb]([id],[code])
select 1,'SLSD' union all
select 2,'SLSD' union all
select 3,'XTGS' union all
select 4,'WZBD'
select * from [tb] where timestamp>0x0000000000000FBF--不用加引号
/*
id code timestamp
----------- -------------- ------------------
4 WZBD 0x0000000000000FC0
(1 行受影响)
*/select * from tb
/**
no gid value col
----- ----------- ----------- ------------------
00001 1 10 0x00000000000AB8F0
00002 2 11 0x00000000000AB8F1
00003 2 11 0x00000000000AB8F2
00004 3 9 0x00000000000AB8F3
00005 4 8 0x00000000000AB8F4
00006 4 10 0x00000000000AB8F5
(6 行受影响)
**/
select * from tb t
where not exists(select 1 from tb where gid=t.gid and col>t.col)
/**
no gid value col
----- ----------- ----------- ------------------
00001 1 10 0x00000000000AB8F0
00003 2 11 0x00000000000AB8F2
00004 3 9 0x00000000000AB8F3
00006 4 10 0x00000000000AB8F5
(4 行受影响)
**/= > < !=