-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey, BT.

If you're just interested in a random 5 items from a straight SELECT statement,
try:

SELECT TOP 5 item_id
FROM base_table
ORDER BY NEWID()

:)

Or, a more ANSI-SQL compliant syntax:

SELECT TOP 5 item_id, newid() as new_id
FROM base_table
ORDER BY new_id

Either way, SQL server creates an aliased column of data type uniqueidentifier.

HTH!

Joe


> -----Original Message-----
> From: BT [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 01, 2001 10:47 AM
> To: CF-Talk
> Subject: Random in SQL
> 
> 
> 
> 
> 
> 
> I am trying to get a random 5 items in SQL on SQL7 instead of 
> on the cf side....
> 
> 
> 
> Anyone know?

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBO2hSB9CGp5RuWHIBEQJbfQCg+Xwx9sIm8z0lwTJrIgmjjyh9B1cAoKgL
/6k1hXmONZY8Sr7C1h5npV8r
=tEQO
-----END PGP SIGNATURE-----

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to