我需要把一個條件,只得到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