Quote:
quote:Originally posted by planoie
I learned this from my buddy Imar just this morning!
Try:
SELECT TOP 10 * FROM ORArticles WHERE ISNULL(Photo1, '') <> '' ORDER NEWID()
This generates a new GUID for every row and orders by that. Because GUIDs are generated in, for all intents and purposes, a random way, it works very well for "randomizing" a set or rows.
Peter
------------------------------------------------------
Work smarter, not harder.
|
This works in any implementation which does not require that the ORDER BY column be present in the SELECT column list (like SQL Server).
The OP wanted just one from the top 10 list, as I read his post:
Code:
SELECT TOP 1 * FROM (SELECT TOP 10 * ORArticles WHERE COALESCE(Photo1, '') <> '' ORDER BY NewID()) as T1
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com