|
|
Archives of the TeradataForum
Message Posted: Tue, 01 Jul 2003 @ 09:45:21 GMT
Subj: | | Re: How to fetch specific number of rows |
|
From: | | David Wellman |
Andy,
I accept that manuals aren't always 100%, absolutely accurate (but you've got to start somewhere). As per the manual, the SAMPLE clause
operates on the result of the SELECT statement, e.g. after the WHERE, GROUP BY, HAVING etc clauses have been applied. So if you have any
WHERE clause etc within your SELECT, the optimizer will generate the appropriate plan to answer that question FIRST, then apply the
sampling.
Whether this is what you really want or not is another matter, but that is what is happening. So the only way (that I've ever seen) to
get a quick SAMPLE when you have a WHERE clause is to code the SAMPLE clause in a derived/volatile table, and then supply the output from
that into another SELECT statement.
Dave
| |