我需要把一个条件,只得到CP7(邮政编码),其中街道不是空Where条件的SQL Server
select top 1 cp7
from codigospostais
order by newid()
我已尝试添加一个WHERE条件,但它没有工作(不正确的语法附近关键字'where'):
where street is not null
你能帮助找到正确的方法来限制它吗?
谢谢
我需要把一个条件,只得到CP7(邮政编码),其中街道不是空Where条件的SQL Server
select top 1 cp7
from codigospostais
order by newid()
我已尝试添加一个WHERE条件,但它没有工作(不正确的语法附近关键字'where'):
where street is not null
你能帮助找到正确的方法来限制它吗?
谢谢
它来的from
段之后和之前的order by
部分:
select top 1 cp7 from codigospostais where street is not null
select top 1 cp7
from codigospostais
where street is not null
order by newid()
不能使用其中ORDER BY子句后,试试这个
SELECT top 1 cp7 FROM codigospostais WHERE ISNULL(street,'') <> '' ORDER BY NEWID()
您不能在order by子句后面写'where'。请尝试先学习sql。这不是学习网站。 – Munavvar