SQL SERVER 获取第一个不为0.00的日期

img


如果是这个情况top1也不可以了

SQL SERVER 获取第一个不为0.00的日期,一个月中可能有多个0.00,取G的数据判断
要求求到红色的2021.1.7是正确的


select  c列  from table  where G列 != 0.00 order by c列 asc limit 1
select top 1  c from table  where G <> 0.00 order by c asc

limit 1是MySQL中取第一条的写法。

select top 1 c列 from table where G列 >0 order by c列 asc

查询语句前边加SELECT TOP 1试试


select top 1 c列 from table where G列 !=0 order by c列 asc

搞不懂你的意思,第一个不为零?第一条就不为零