[thelist] MS SQL Syntax Help

Means, Eric D eric.d.means at boeing.com
Tue Apr 16 12:16:00 CDT 2002


SELECT TOP 10 *
FROM my_table
ORDER BY col_name_1 DESC

-----Original Message-----
From: Joshua Olson [mailto:joshua at waetech.com]
Sent: Tuesday, April 16, 2002 12:28 PM
To: thelist at lists.evolt.org
Subject: [thelist] MS SQL Syntax Help


I've seen queries such as this in a few different database examples:

SELECT *
FROM   (SELECT * FROM my_table ORDER BY col_name_1 DESC)
WHERE  ROWNUM < 10;

This example works in Oracle, as far as I know, to return the top 10 rows in
a table..  In MS SQL 2k, however, the parser does not seem to like having
the inner select within the FROM clause.  I understand that there are
usually other ways to accomplish a task not involving this syntax, but I'm
still curious.  Does anyone know a trick to use SELECT's in the FROM clause
in MS SQL 2k?

TIA,

-joshua

ref: http://www.orafaq.com/faqsql.htm#TOP


--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !




More information about the thelist mailing list