服務熱線
153 8323 9821
sql server :
在取數據庫前幾條記錄時會碰到取到記錄與語句不符的情況:如select top 5本來取5條記錄但是確顯示了5條以上的記錄,這是由于在排序時遇到字段值相同的記錄。解決辦法例:select top 5*from(select top 5*from(select*from nnes here nrole 2order by ntime desc)order by nsho desc)這是一個雙字段排序語句nsho是我自己定義的一個排序字段,經常出現重復現象,造成top語句不起作用把select top 5*from(select*from nnes here nrole 2order by ntime desc)order by nsho desc在它嵌套在select top 5*from中就解決了top語句不起作用的現象。
access top語句:SELECT TOP 8 id, qname, img, yw
FROM (SELECT TOP 8 id, qname, img, yw
FROM co
WHERE (sh = 1) AND (zd = 1)) derivedtbl
access語句只需在后面加上 derivedtbl。