Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LIMIT ROWS RETRIEVED USING SQL 1

Status
Not open for further replies.

Queryman

Programmer
Nov 4, 2002
243
US
Can someone post an example of how to limit the number of rows retrieved, not sure what the command is (LIMIT, TOP etc). Needs to be ANSI SQL.
Thanks!

QueryMan

 
SELECT TOP 100 * FROM emp


SELECT TOP 50 PERCENT salary FROM emp ORDER BY salary DESC -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 

mike, he said ansi sql, TOP is microsoft P-)

queryman, you can't do it in ansi sql unless you give a column to sort on, and then it becomes a variation of the &quot;top ten&quot; query (which, by the way, is not very efficient):

SELECT PERSON, SCORE
FROM SAMPLETABLE XXX
WHERE 10 >
( SELECT COUNT(*)
FROM SAMPLETABLE
WHERE SCORE > XXX.SCORE )

rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top