Google
 

Kamis, 05 Juli 2007

FB Partial Select

Firebird has capability to get only N data from database. The syntax is like this:
"SELECT [FIRST N] [SKIP M] * FROM [TABLE/ VIEW/ STORED PROCEDURE]"

For example, if we want to get the 5 top employee by their salary then we can do
"SELECT FIRST 5 * FROM EMPLOYEE ORDER BY SALARY DESC"

The "skip" keyword is functioned to skip M data from the top of data that we retrieve through query. For example if we want to get the runner up position for some contestant we can do
"SELECT FIRST 1 SKIP 1 FROM CONTESTANT ORDER BY SCORE DESC"

Tidak ada komentar: