无重复最低价格 select top 1 price from table group by price where count(price)=1 order by price
select top 1 price from table group by price where count(price)=1 order by price
select top 1 price from t group by price having count(Price)=1 order by price
group by 后面跟 where ?
select @minprice=min(price) from table select @maxprice=max(price) from table where @minprice<=@maxprice begin set @minprice=@minprice+0.01 select @count=count(*) from table where price=@minprice if @count=0 beign insert into table (price) valuse (@minprice) --要怎么插入自己看着办 end end --记得把变量定义好
接受改正 select top 1 price from table group by price having count(price)=1 order by price
select min(a.price) from (select 0.00 as price union all select price from t) a where not exists(select 1 from t where price-0.01 in(select price from (select 0.00 as price union all select price from t) a )
我日啊,数据库Price字段为字符串型,上面结果不对
不是,我觉得应该用一些类似numeric这个函数转换一下吧,学习中!
select min(a.price)-0.01 from (select 0.00 as price union all select price from t) a where not exists(select 1 from t where price-0.01 in(select price from (select 0.00 as price union all select price from t) a ))
select top 1 price from table
group by price
where count(price)=1
order by price
group by price
where count(price)=1
order by price
from t
group by price
having count(Price)=1
order by price
select @maxprice=max(price) from table
where @minprice<=@maxprice
begin
set @minprice=@minprice+0.01
select @count=count(*) from table where price=@minprice
if @count=0
beign
insert into table (price) valuse (@minprice) --要怎么插入自己看着办
end
end
--记得把变量定义好
select top 1 price from table
group by price
having count(price)=1
order by price
from (select 0.00 as price union all
select price from t) a
where not exists(select 1
from t
where price-0.01 in(select price
from (select 0.00 as price union all
select price from t) a
)
from (select 0.00 as price union all
select price from t) a
where not exists(select 1
from t
where price-0.01 in(select price
from (select 0.00 as price union all
select price from t) a
))