all groups > inetserver asp db > july 2005 >
You're in the

inetserver asp db

group:

Randomize Top Five Stories in Descending order


Randomize Top Five Stories in Descending order jason NO[at]SPAM catamaranco.com
7/13/2005 3:48:28 PM
inetserver asp db: Could soneone help me extend the following select statement to selet the top
five recently published news stories in descending order but RANDOMIZED. I
already have the NewID() doing the donkey work but I am having trouble using
an ORDER BY after it...is it possible? At the moment it randomizes through
the entire table...I want it restricted to the last five stores by date....



CREATE Procedure spr_GetTop5Stories

As
set nocount on
select Top 5* from Story order by NewID()
return
GO

Thanks in advance
Jason

Re: Randomize Top Five Stories in Descending order Ray Costanzo [MVP]
7/13/2005 3:58:05 PM
<disclaimer>No SQL expert here!</disclaimer>

Create a #temp table, insert your five most recent stories in there, and
then select all from that #temp table in random order.

Ray at work

[quoted text, click to view]

Re: Randomize Top Five Stories in Descending order jason NO[at]SPAM catamaranco.com
7/13/2005 4:35:46 PM
That seems excessive...surely I can adapt the NewID() statement...it seems
more elegant?


"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:%23h7JwU%23hFHA.1948@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

Re: Randomize Top Five Stories in Descending order Bob Lehmann
7/13/2005 5:31:03 PM
[quoted text, click to view]
Why do you say that?

[quoted text, click to view]
If you are so sure, why are you asking the question?

[quoted text, click to view]
Elegance trumps functionality?

Why do people ask for advice and then proceed to challenge the advice they
are given?

Bob Lehmann

[quoted text, click to view]

Re: Randomize Top Five Stories in Descending order jason NO[at]SPAM catamaranco.com
7/14/2005 11:09:14 AM
I apologize. I thought the NewID() statement could be extended.

[quoted text, click to view]

Re: Randomize Top Five Stories in Descending order Roland Hall
7/19/2005 5:04:44 PM
[quoted text, click to view]

Well, let that be a lesson to you. Tuesday's crowd is rough. Try us again
on Friday. Friday's crowd is a lot more receptive but it's because most of
those with answers are out drinking somewhere abusing others. (O:=

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp

Re: Randomize Top Five Stories in Descending order jason NO[at]SPAM catamaranco.com
7/22/2005 2:23:51 PM
Lol - Indeed!

[quoted text, click to view]

AddThis Social Bookmark Button