Re: random selection

From: Ashley Miramar (anonymous_at_discussions.microsoft.com)
Date: 05/26/04


Date: Wed, 26 May 2004 15:37:33 -0700

Aaron,

Thank you so much for your suggestions. I will take that
into consideration when writing the querry. As far as
what type of search I want, I like to get a random number
of rows without any order. Please see if you can send me
the query. Thanks.

Ashley.

>-----Original Message-----
>> However, I like to be able to select random number of
>> rows - not from the top or bottom.
>
>You want a random number of rows, or 10 rows in any order?
>
>I'll assume the latter:
>
>ORDER BY NEWID()
>
>(See http://www.aspfaq.com/2132)
>
>> Also, on which columns do you suggest
>> I create indexes? Thank you.
>
>Well if you're going to be running queries against a
DATETIME /
>SMALLDATETIME column, that is usually a no-brainer. In
fact, most of my
>database applications have multiple tables with clustered
indexes on the
>[small]datetime columns, because that is such a heavy
query requirement.
>
>A couple of other suggestions:
>
>You might want to avoid BETWEEN for date range queries,
as the results can
>often be ambiguous. In this case, if your posteddate has
time information,
>your query will include rows posted on 20040228 at
midnight, but not at
>12:01 am. See http://www.aspfaq.com/2280 for more info.
>
>I'm also surprised that you're joining on posteddate...
if this is really
>necessary, I hope that you are merely storing the date,
because if this
>includes time information, you are storing redundant
data. The join should
>only be on sequence or seqno, if this is a
primary/foreign key relationship.
>(Which reminds me to suggest that you keep column names
the same... figuring
>out that seqno and sequence have the same meaning would
drive me batty!)
>
>--
>Aaron Bertrand
>SQL Server MVP
>http://www.aspfaq.com/
>
>
>
>
>"Ashley Miramar" <anonymous@discussions.microsoft.com>
wrote in message
>news:12e2d01c44364$c8b433a0$a401280a@phx.gbl...
>> Friends, I have written the following script to select
the
>> top 10 rows of this table.
>>
>> Select top 10 t.CASE, t.AMOUNT, t.DLASTNAME,
t.DFIRSTNAME,
>> t.DMIDNAME,
>> t.DSUFFIX, t.FILINGTYPE, t.JUDGMENTDATE, t.PLASTNAME,
>> t.PFIRSTNAME,
>> t.PMIDNAME from tablecates t (nolock) inner join
eRecords
>> e (nolock)
>> on t.sequence = e.SeqNo and t.Posteddate = e.Posteddate
>> where t.type = 'UMM' and t.ResearchNo = '12565555' and
>> t.posteddate
>> between '20040101' and '20040228'
>>
>> However, I like to be able to select random number of
>> rows - not from the top or bottom. Can you please show
me
>> what script or store procedure will do this? I am so
new
>> in writing scripts. Also, on which columns do you
suggest
>> I create indexes? Thank you.
>>
>> Ashley
>>
>
>
>.
>



Relevant Pages

  • Re: [WR] round tuits
    ... Jackson Pillock wrote: ... I do, too many projects going, not enough time, priorities lean toward ... I started writing a precinct drama set in a locked psychiatric ward. ... Sent off my script. ...
    (misc.writing)
  • Re: crisis Perl
    ... As to writing good code to begin with, ... the top of the script. ... the "use warnings;" line won't actually change ... recommended declaring variables IN AS SMALL AS SCOPE AS POSSIBLE. ...
    (comp.lang.perl.misc)
  • Marginally archaeaology: Eight scripts that still cant be read
    ... WRITING is one of the greatest inventions in human history. ... literate civilisation at the time of the ... So how do you decipher an unknown script? ... there must be some link to a known language. ...
    (sci.archaeology)
  • Re: Vinca script, cross bar angle - Ki Ri Ke
    ... of the Goddess, since the English title of the second book ... sacred script in The Goddesses and Gods of Old Europe, ... not exactly a scholarly publisher. ... writing scholars call "ideograms," and hence not as writing. ...
    (sci.lang)
  • Re: Vinca script, cross bar angle - Ki Ri Ke
    ... writing to anyone who studies writing carefully. ... Numbers are part of every language, ... you read chapter 8, The Sacred Script, of The Civilization ... The Language of the Goddess is about symbols "only." ...
    (sci.lang)