2009-06-24 13 views
5

Abbiamo un database Interbase 7.1 e sto cercando di capire come limitare il numero di record restituiti dalla query a solo 1. Ho solo bisogno di conoscere un codice evento dall'ultimo record, in cui la query restituire centinaia di record se non riesco a fare una sorta di limite.Come si limita il numero di record restituiti per Interbase 7.1?

Grazie in anticipo!

risposta

11

Penso di aver capito. Bisogno di fare qualcosa di simile ...

SELECT * FROM tabella ORDER BY RIGHE Col 1

4

Come per la risposta accettata:

SELECT * FROM table ORDER BY col ROWS 1 

restituirà un solo risultato. Ci sono anche diverse altre opzioni di limitazione delle righe disponibili:

 
ROWS n  Returns the first n rows of the result set, or n percent if used with PERCENT 
ROWS m TO n Returns rows m through n, inclusive or the mth to nth percent 
ROWS n BY p Returns every pth row of the first n rows 

Ciò è particolarmente utile per i risultati di paging.

Dalla guida SQL incorporata nella pagina InterBase Product Documentation: