我不知道如何從以下查詢中選擇前8行。我對SQL很陌生。從隨機選擇中選擇前8行SQLSERVER
SELECT TOP 100 PERCENT * FROM (
select TEXT, ID, Details
from tblTEXT
where (ID = 12 or ID = 13 or ID =15)
) X
order by newid()
此查詢給我31個隨機行,但我想選擇前8
我使用下列但它不工作
select top 8
from
(
SELECT TOP 100 PERCENT * FROM (
select TEXT, ID, Details
from tblTEXT
where (ID = 12 or ID = 13 or ID =15)
) X
order by newid()
)
謝謝:)是的,它解決了 – Kamran