Randomize Top Five Stories in Descending order

Randomize Top Five Stories in Descending order

am 13.07.2005 21:48:28 von jason

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

am 13.07.2005 21:58:05 von unknown

No SQL expert here!

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

wrote in message
news:uweHaP%23hFHA.576@tk2msftngp13.phx.gbl...
> 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

am 13.07.2005 22:35:46 von jason

That seems excessive...surely I can adapt the NewID() statement...it seems
more elegant?


"Ray Costanzo [MVP]" wrote in
message news:%23h7JwU%23hFHA.1948@TK2MSFTNGP12.phx.gbl...
> No SQL expert here!
>
> 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
>
> wrote in message
> news:uweHaP%23hFHA.576@tk2msftngp13.phx.gbl...
>> 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

am 14.07.2005 01:31:03 von Bob Lehmann

>> That seems excessive...
Why do you say that?

>> surely I can adapt the NewID() statement...
If you are so sure, why are you asking the question?

>> it seems more elegant?
Elegance trumps functionality?

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

Bob Lehmann

wrote in message
news:u8FW2p%23hFHA.3436@tk2msftngp13.phx.gbl...
> That seems excessive...surely I can adapt the NewID() statement...it seems
> more elegant?
>
>
> "Ray Costanzo [MVP]" wrote in
> message news:%23h7JwU%23hFHA.1948@TK2MSFTNGP12.phx.gbl...
> > No SQL expert here!
> >
> > 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
> >
> > wrote in message
> > news:uweHaP%23hFHA.576@tk2msftngp13.phx.gbl...
> >> 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

am 14.07.2005 17:09:14 von jason

I apologize. I thought the NewID() statement could be extended.

"Bob Lehmann" wrote in message
news:%233ar9LAiFHA.720@TK2MSFTNGP14.phx.gbl...
>>> That seems excessive...
> Why do you say that?
>
>>> surely I can adapt the NewID() statement...
> If you are so sure, why are you asking the question?
>
>>> it seems more elegant?
> Elegance trumps functionality?
>
> Why do people ask for advice and then proceed to challenge the advice they
> are given?
>
> Bob Lehmann
>
> wrote in message
> news:u8FW2p%23hFHA.3436@tk2msftngp13.phx.gbl...
>> That seems excessive...surely I can adapt the NewID() statement...it
>> seems
>> more elegant?
>>
>>
>> "Ray Costanzo [MVP]" wrote in
>> message news:%23h7JwU%23hFHA.1948@TK2MSFTNGP12.phx.gbl...
>> > No SQL expert here!
>> >
>> > 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
>> >
>> > wrote in message
>> > news:uweHaP%23hFHA.576@tk2msftngp13.phx.gbl...
>> >> 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

am 20.07.2005 00:04:44 von Roland Hall

wrote in message news:eOcJZDJjFHA.3064@TK2MSFTNGP15.phx.gbl...
:I apologize. I thought the NewID() statement could be extended.

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

am 22.07.2005 20:23:51 von jason

Lol - Indeed!

"Roland Hall" wrote in message
news:eZnKg3KjFHA.1464@TK2MSFTNGP14.phx.gbl...
> wrote in message news:eOcJZDJjFHA.3064@TK2MSFTNGP15.phx.gbl...
> :I apologize. I thought the NewID() statement could be extended.
>
> 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
>
>