SQL查询排序,自我比较,启动程序

    System.Diagnostics.Process.Start(@"D:\FoxMail\Foxmail.exe");

select *
from MonthlyEnterpriseMonitor
where cast([Year] AS nvarchar(10))+'-0'+cast([Month] AS nvarchar(10))+'-01 00:00:00'
between '2009-01-01 00:00:00' and '2009-02-28 23:59:59'


declare @t table(id int,   name varchar(10),   Time1 datetime,     Time2 datetime)
insert @t select 1,'AA','2008-5-10','2009-1-1'
insert @t select 2,'AA','2008-11-5',null
insert @t select 3,'BB','2008-5-10','2009-2-14'
insert @t select 4,'BB','2008-8-23','2009-1-5'
insert @t select 5,'BB','2008-9-14','2009-4-1'
insert @t select 6,'CC','2009-2-22',null
insert @t select 7,'CC','2008-10-10','2009-1-10'

select * from @t t where not exists(select 1 from @t where name=t.name and (time1>t.time1 or time2>t.time2))

/*
id          name       Time1                   Time2
----------- ---------- ----------------------- -----------------------
2           AA         2008-11-05 00:00:00.000 NULL
5           BB         2008-09-14 00:00:00.000 2009-04-01 00:00:00.000
6           CC         2009-02-22 00:00:00.000 NULL

(3 行受影响)
*/

 

http://www.cikuu.com/contact.html


select * from dbo.T_Question

where (tag like N'%卡%充积分%' and tag  not like N'%充积分%')

or (tag not like N'%卡%充积分%' and tag  like N'%充积分%')

你可能感兴趣的:(sql)