ReadVitamin

Blogging on Teradata SQL and More

4 Comments

mygif
Rastislav Said in Sunday, October 21st, 2007 @1:54 pm  

would SAMPLE work the same way?
e. g. SELECT * FROM emp ORDER BY emp_id SAMPLE 3;

mygif
admin Said in Monday, October 22nd, 2007 @7:09 pm  

Hi Rastislav,

The query SELECT * FROM emp ORDER BY emp_id SAMPLE 3; would NOT produce the same result as you see by using .set retlimit 3. The reason being that SAMPLE returns random sample rows, at all time. When you force a “retlimit”, it discards rest of the rows after it has selected its limit, which most of the time are TOP rows. You can use the following query to get the same result.

SELECT TOP 3 * FROM emp;

mygif
mdain Said in Wednesday, July 9th, 2008 @2:31 am  

that’s not true. as long as you add the order by clause, you’d have the same results using sample

mygif
mdain Said in Wednesday, July 9th, 2008 @2:35 am  

actually i take it back… you’re right. the results are different. my mistake, thanks for the idea

Leave Your Comments Here

Popular Articles