34,575
社区成员
发帖
与我相关
我的任务
分享
----------------------------------------------------------------
-- Author :DBA_HuangZJ(發糞塗牆)
-- Date :2014-07-31 15:25:31
-- Version:
-- Microsoft SQL Server 2012 - 11.0.5058.0 (X64)
-- May 14 2014 18:34:29
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)
--
----------------------------------------------------------------
--> 测试数据:[ABC]
if object_id('[ABC]') is not null drop table [ABC]
go
create table [ABC]([Title] varchar(2),[Date] datetime)
insert [ABC]
select 'T1','2014-03-08' union all
select 'T2','2014-12-12'
--------------开始查询--------------------------
select CASE WHEN [date]<=GETDATE() THEN 0 ELSE 1 END
from [ABC]
WHERE title='t1'
----------------结果----------------------------
/*
-----------
0
*/