问一个SQL语句的问题

来源:百度知道 编辑:UC知道 时间:2024/06/04 04:47:19
select * from list where hide = '1' and time2>#2009-7-1#
如何让这语句中的 time2>#2009-7-1#成立则执行akeCoin<28不成立不执行
有什么方法实现
本人假想
select * from list where hide = '1' and if time2>#2009-7-1# then akeCoin<28 end if

if exists(select * from list where hide='1' and exists(select time2 from list where time2 >'2009-7-1'))
begin
---执行akeCoin<28????
if(akeCoin<28)
begin
---more code here
end
end

要写存储过程
create proc sel
(
@time datetime --传进来你的日期
if @time > '2009-7-1'
begin
select * from list where hide = '1' and time2>'2009-7-1' and akeCoin<28
end
else
begin
select * from list where hide = '1' and time2>'2009-7-1'
end
)
虽然不知道你这么写有什么意义。。。

select * from list where hide = '1' and case when time2>#2009-7-1# then akeCoin<28
else
1=1
end

试试看